Decompiled source of SnatchinBracken v1.5.1

SnatchingBracken.dll

Decompiled 3 months 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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using SnatchinBracken;
using SnatchinBracken.Patches;
using SnatchinBracken.Patches.data;
using SnatchingBracken;
using SnatchingBracken.NetcodePatcher;
using SnatchingBracken.Patches.dungeon;
using SnatchingBracken.Patches.network;
using SnatchingBracken.Patches.tasks;
using SnatchingBracken.Utils;
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("SnatchingBracken")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SnatchingBracken")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("afcd9203-dbdd-4b28-85a1-fb12890f0d98")]
[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")]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace SnatchinBracken
{
	[BepInPlugin("Ovchinikov.SnatchinBracken.Main", "SnatchinBracken", "1.5.1")]
	public class SnatchinBrackenBase : BaseUnityPlugin
	{
		private const string modGUID = "Ovchinikov.SnatchinBracken.Main";

		private const string modName = "SnatchinBracken";

		private const string modVersion = "1.5.1";

		private static SnatchinBrackenBase _instance;

		private readonly Harmony harmony = new Harmony("Ovchinikov.SnatchinBracken.Main");

		private static SnatchinBrackenBase instance;

		internal ManualLogSource mls;

		public static SnatchinBrackenBase Instance => _instance;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			if ((Object)(object)_instance == (Object)null)
			{
				_instance = this;
			}
			else if ((Object)(object)_instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			mls = Logger.CreateLogSource("Ovchinikov.SnatchinBracken.Main");
			mls.LogInfo((object)"Enabling SnatchinBracken");
			InitializeConfigValues();
			harmony.PatchAll(typeof(SnatchinBrackenBase));
			harmony.PatchAll(typeof(BrackenAIPatch));
			harmony.PatchAll(typeof(EnemyAIPatch));
			harmony.PatchAll(typeof(TeleporterPatch));
			harmony.PatchAll(typeof(LandminePatch));
			harmony.PatchAll(typeof(TurretPatch));
			harmony.PatchAll(typeof(PlayerPatch));
			harmony.PatchAll(typeof(DungeonGenPatch));
			harmony.PatchAll(typeof(StartOfRound));
			mls.LogInfo((object)"Finished Enabling SnatchinBracken");
			patcher();
		}

		private void InitializeConfigValues()
		{
			mls.LogInfo((object)"Parsing SnatchinBracken config");
			try
			{
				if (AppDomain.CurrentDomain.GetAssemblies().Any((Assembly a) => a.GetName().Name == "LethalConfig"))
				{
					LethalConfigAPIHook.InitializeConfig();
				}
				else
				{
					loadConfig();
				}
			}
			catch
			{
				mls.LogInfo((object)"LethalConfigAPI not found, using built-in BepInEx config stuff.");
				loadConfig();
			}
			mls.LogInfo((object)"Config finished parsing");
		}

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

		private void loadConfig()
		{
			mls.LogInfo((object)"LethalConfigAPI not found, using built-in BepInEx config stuff.");
			ConfigEntry<bool> dropItemsOption = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Drop Items on Snatch", true, "Should players drop their items when a Bracken grabs them?");
			SharedData.Instance.DropItems = dropItemsOption.Value;
			dropItemsOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.DropItems = dropItemsOption.Value;
				}
			};
			ConfigEntry<bool> turretOption = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Ignore Turrets on Snatch", true, "Should players be ignored by turrets when dragged?");
			SharedData.Instance.IgnoreTurrets = turretOption.Value;
			turretOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.IgnoreTurrets = turretOption.Value;
				}
			};
			ConfigEntry<bool> allowDraggedTps = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Allow teleports to save dragged players", true, "Should players be able to be saved through teleportation?");
			SharedData.Instance.AllowTeleports = allowDraggedTps.Value;
			allowDraggedTps.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.AllowTeleports = allowDraggedTps.Value;
				}
			};
			ConfigEntry<bool> monstersIgnorePlayersOption = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Enemies Ignore Dragged Players", true, "Should players be ignored by other monsters while being dragged?");
			SharedData.Instance.MonstersIgnorePlayers = monstersIgnorePlayersOption.Value;
			monstersIgnorePlayersOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.MonstersIgnorePlayers = monstersIgnorePlayersOption.Value;
				}
			};
			ConfigEntry<bool> stuckForceKillOption = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Stuck Force Kill", false, "If enabled, Brackens will force kill when stuck at the same spot for at least 5 seconds.");
			SharedData.Instance.StuckForceKill = stuckForceKillOption.Value;
			stuckForceKillOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.StuckForceKill = stuckForceKillOption.Value;
				}
			};
			ConfigEntry<bool> brackenRoomOption = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Force Set Favorite Location To Bracken Room", true, "If enabled, Brackens' favorite locations will be set to the Bracken room. The room sometimes doesn't spawn, so please don't be alarmed if they don't take you there if this is enabled.");
			SharedData.Instance.BrackenRoom = brackenRoomOption.Value;
			brackenRoomOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.BrackenRoom = brackenRoomOption.Value;
				}
			};
			ConfigEntry<bool> mineOption = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Ignore Mines on Snatch", true, "Should players ignore Landmines while being dragged?");
			SharedData.Instance.IgnoreMines = mineOption.Value;
			mineOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.IgnoreMines = mineOption.Value;
				}
			};
			ConfigEntry<int> instaKillPercentEntry = ((BaseUnityPlugin)this).Config.Bind<int>("SnatchinBracken Settings", "Chance for Insta Kill", 0, "Percent chance for insta kill, 0 to disable.");
			SharedData.Instance.PercentChanceForInsta = instaKillPercentEntry.Value;
			instaKillPercentEntry.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.PercentChanceForInsta = instaKillPercentEntry.Value;
				}
			};
			ConfigEntry<bool> allowSecondsUntilAutoKill = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Allow Seconds Until Auto Kill", true, "If disabled, the Bracken won't kill based on time configured in \"Seconds Until Auto Kill\" (although may still kill if auto stuck is toggled off).");
			SharedData.Instance.KillBasedOffOfTime = allowSecondsUntilAutoKill.Value;
			allowSecondsUntilAutoKill.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.KillBasedOffOfTime = allowSecondsUntilAutoKill.Value;
				}
			};
			ConfigEntry<int> brackenKillTimeEntry = ((BaseUnityPlugin)this).Config.Bind<int>("SnatchinBracken Settings", "Seconds Until Auto Kill", 60, "Time in seconds until Bracken automatically kills when grabbed. Range: 1-60 seconds.");
			SharedData.Instance.KillAtTime = brackenKillTimeEntry.Value;
			brackenKillTimeEntry.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.KillAtTime = brackenKillTimeEntry.Value;
				}
			};
			ConfigEntry<int> brackenNextAttemptEntry = ((BaseUnityPlugin)this).Config.Bind<int>("SnatchinBracken Settings", "Seconds Until Next Attempt", 5, "Time in seconds until Bracken is allowed to take another victim.");
			SharedData.Instance.SecondsBeforeNextAttempt = brackenNextAttemptEntry.Value;
			brackenNextAttemptEntry.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.SecondsBeforeNextAttempt = brackenNextAttemptEntry.Value;
				}
			};
			ConfigEntry<bool> doDamageOnIntervalEntry = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Do Gradual Damage", false, "Should players be hurt gradually while being dragged?");
			SharedData.Instance.DoDamageOnInterval = doDamageOnIntervalEntry.Value;
			doDamageOnIntervalEntry.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.DoDamageOnInterval = doDamageOnIntervalEntry.Value;
				}
			};
			ConfigEntry<int> damageDealtProgressively = ((BaseUnityPlugin)this).Config.Bind<int>("SnatchinBracken Settings", "Damage Dealt At Interval", 5, "This only applies if you have \"Do Gradual Damage\" enabled. While dragged, every second this configured amount of damage will be dealt to the player.");
			SharedData.Instance.DamageDealtAtInterval = damageDealtProgressively.Value;
			damageDealtProgressively.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.DamageDealtAtInterval = damageDealtProgressively.Value;
				}
			};
			ConfigEntry<bool> allowDistanceBasedKiller = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Allow Distance Until Auto Kill", true, "If disabled, the Bracken won't kill based on distance from favorite spot configured in \"Distance For Kill\" (although may still kill if auto stuck is toggled off).");
			SharedData.Instance.KillBasedOffOfDistance = allowDistanceBasedKiller.Value;
			allowDistanceBasedKiller.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.KillBasedOffOfDistance = allowDistanceBasedKiller.Value;
				}
			};
			ConfigEntry<int> distanceAutoKillerEntry = ((BaseUnityPlugin)this).Config.Bind<int>("SnatchinBracken Settings", "Distance For Kill", 1, "How far should the Bracken be from its favorite spot to initiate a kill?");
			SharedData.Instance.DistanceFromFavorite = distanceAutoKillerEntry.Value;
			distanceAutoKillerEntry.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.DistanceFromFavorite = distanceAutoKillerEntry.Value;
				}
			};
			ConfigEntry<bool> instaKillOption = ((BaseUnityPlugin)this).Config.Bind<bool>("SnatchinBracken Settings", "Instakill When Alone", false, "Should players be instantly killed if they're alone?");
			SharedData.Instance.InstantKillIfAlone = instaKillOption.Value;
			instaKillOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.InstantKillIfAlone = instaKillOption.Value;
				}
			};
		}
	}
}
namespace SnatchinBracken.Patches
{
	[HarmonyPatch(typeof(FlowermanAI))]
	internal class BrackenAIPatch
	{
		private const string modGUID = "Ovchinikov.SnatchinBracken.FlowermanAI";

		private static ManualLogSource mls;

		private static List<FlowermanAI> JustProcessed;

		static BrackenAIPatch()
		{
			JustProcessed = new List<FlowermanAI>();
			mls = Logger.CreateLogSource("Ovchinikov.SnatchinBracken.FlowermanAI");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyAI), "ChooseFarthestNodeFromPosition")]
		private static void FarthestNodeAdjustment(EnemyAI __instance, ref Transform __result, Vector3 pos, bool avoidLineOfSight = false, int offset = 0, bool doAsync = false, int maxAsyncIterations = 50, bool capDistance = false)
		{
			//IL_0049: 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)
			FlowermanAI val = (FlowermanAI)(object)((__instance is FlowermanAI) ? __instance : null);
			if (val != null && Object.op_Implicit((Object)(object)SharedData.Instance.BrackenRoomPosition) && (Object)(object)__result != (Object)null && SharedData.Instance.BrackenRoom)
			{
				if (__instance.SetDestinationToPosition(SharedData.Instance.BrackenRoomPosition.position, true))
				{
					__result = SharedData.Instance.BrackenRoomPosition;
				}
				else if (!__instance.SetDestinationToPosition(__result.position, true))
				{
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void PostfixStart(FlowermanAI __instance)
		{
			if ((((NetworkBehaviour)__instance).IsHost || ((NetworkBehaviour)__instance).IsServer) && SharedData.Instance.StuckForceKill)
			{
				((Component)__instance).gameObject.AddComponent<FlowermanLocationTask>();
			}
			if ((Object)(object)SharedData.Instance.BrackenRoomPosition != (Object)null && SharedData.Instance.BrackenRoom)
			{
				((EnemyAI)__instance).favoriteSpot = SharedData.Instance.BrackenRoomPosition;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("KillPlayerAnimationServerRpc")]
		private static bool PrefixKillPlayerAnimationServerRpc(FlowermanAI __instance, int playerObjectId)
		{
			mls.LogInfo((object)"Running kill Player animation");
			if (!((NetworkBehaviour)__instance).IsHost && !((NetworkBehaviour)__instance).IsServer)
			{
				return true;
			}
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			if ((CountAlivePlayers() <= 1 && SharedData.Instance.InstantKillIfAlone) || RollForChance(SharedData.Instance.PercentChanceForInsta))
			{
				return true;
			}
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerObjectId];
			if ((Object)(object)val == (Object)null)
			{
				return true;
			}
			if (SharedData.Instance.BindedDrags.ContainsKey(__instance))
			{
				return false;
			}
			if (SharedData.Instance.BindedDrags.ContainsValue(val))
			{
				return false;
			}
			if (SharedData.Instance.LastGrabbedTimeStamp.ContainsKey(__instance) && Time.time - SharedData.Instance.LastGrabbedTimeStamp[__instance] <= SharedData.Instance.SecondsBeforeNextAttempt)
			{
				return false;
			}
			if (SharedData.Instance.DropItems)
			{
				val.DropAllHeldItemsAndSync();
			}
			else if (!SharedData.Instance.DropItems)
			{
				DropDoubleHandedItem(val);
			}
			FlowermanBinding component = ((Component)val).GetComponent<FlowermanBinding>();
			component.PrepForBindingServerRpc(playerObjectId, ((NetworkBehaviour)__instance).NetworkObjectId);
			component.BindPlayerServerRpc(playerObjectId, ((NetworkBehaviour)__instance).NetworkObjectId);
			component.UpdateFavoriteSpotServerRpc(playerObjectId, ((NetworkBehaviour)__instance).NetworkObjectId);
			component.MufflePlayerVoiceServerRpc(playerObjectId);
			component.MakeInsaneServerRpc(playerObjectId, 49.9f);
			FlowermanLocationTask component2 = ((Component)__instance).gameObject.GetComponent<FlowermanLocationTask>();
			if ((Object)(object)component2 != (Object)null && !SharedData.Instance.DoDamageOnInterval)
			{
				component2.StartCheckStuckCoroutine(__instance, val);
			}
			if (!SharedData.Instance.GradualDamageCoroutineStarted.ContainsKey(__instance) && SharedData.Instance.DoDamageOnInterval)
			{
				((MonoBehaviour)__instance).StartCoroutine(GeneralUtils.DoGradualDamage(__instance, val, 1f, SharedData.Instance.DamageDealtAtInterval));
				SharedData.Instance.GradualDamageCoroutineStarted[__instance] = true;
			}
			((EnemyAI)__instance).SwitchToBehaviourStateOnLocalClient(1);
			if (((NetworkBehaviour)__instance).IsServer)
			{
				((EnemyAI)__instance).SwitchToBehaviourState(1);
			}
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(EnemyAI), "SetEnemyStunned")]
		private static void SetEnemyStunnedPrefix(EnemyAI __instance, bool setToStunned, float setToStunTime = 1f, PlayerControllerB setStunnedByPlayer = null)
		{
			FlowermanAI val = (FlowermanAI)(object)((__instance is FlowermanAI) ? __instance : null);
			if (val == null)
			{
				return;
			}
			if (SharedData.Instance.BindedDrags.ContainsKey(val))
			{
				PlayerControllerB valueSafe = GeneralExtensions.GetValueSafe<FlowermanAI, PlayerControllerB>(SharedData.Instance.BindedDrags, val);
				GeneralUtils.StopGradualDamageCoroutine(val, valueSafe);
			}
			if ((((NetworkBehaviour)val).IsHost || ((NetworkBehaviour)val).IsServer) && SharedData.Instance.BindedDrags.ContainsKey(val))
			{
				PlayerControllerB valueSafe2 = GeneralExtensions.GetValueSafe<FlowermanAI, PlayerControllerB>(SharedData.Instance.BindedDrags, val);
				int valueSafe3 = GeneralExtensions.GetValueSafe<PlayerControllerB, int>(SharedData.Instance.PlayerIDs, valueSafe2);
				SharedData.UpdateTimestampNow(val, valueSafe2);
				FlowermanLocationTask component = ((Component)val).gameObject.GetComponent<FlowermanLocationTask>();
				if ((Object)(object)component != (Object)null)
				{
					component.StopCheckStuckCoroutine();
				}
				GeneralUtils.ManuallyUnbindPlayer(val, valueSafe2);
				GeneralUtils.ManuallyDropPlayerOnHit(val, valueSafe2);
				FlowermanBinding component2 = ((Component)valueSafe2).GetComponent<FlowermanBinding>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.UnbindPlayerServerRpc(valueSafe3, ((NetworkBehaviour)__instance).NetworkObjectId);
					component2.ResetEntityStatesServerRpc(valueSafe3, ((NetworkBehaviour)__instance).NetworkObjectId);
					component2.UnmufflePlayerVoiceServerRpc(valueSafe3);
					component2.GiveChillPillServerRpc(valueSafe3);
				}
				JustProcessed.Add(val);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("HitEnemy")]
		private static void HitEnemyPostPatch(FlowermanAI __instance, int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false)
		{
			if (!((NetworkBehaviour)__instance).IsHost && !((NetworkBehaviour)__instance).IsServer && JustProcessed.Contains(__instance))
			{
				__instance.angerMeter = 0f;
				__instance.isInAngerMode = false;
				__instance.angerCheckInterval = 0f;
				JustProcessed.Remove(__instance);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("HitEnemy")]
		private static bool HitEnemyPrePatch(FlowermanAI __instance, int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false)
		{
			if (SharedData.Instance.BindedDrags.ContainsKey(__instance))
			{
				PlayerControllerB valueSafe = GeneralExtensions.GetValueSafe<FlowermanAI, PlayerControllerB>(SharedData.Instance.BindedDrags, __instance);
				GeneralUtils.StopGradualDamageCoroutine(__instance, valueSafe);
			}
			if (!((NetworkBehaviour)__instance).IsHost && !((NetworkBehaviour)__instance).IsServer)
			{
				return true;
			}
			if (SharedData.Instance.BindedDrags.ContainsKey(__instance))
			{
				mls.LogInfo((object)"Hit bracken, dropping");
				PlayerControllerB valueSafe2 = GeneralExtensions.GetValueSafe<FlowermanAI, PlayerControllerB>(SharedData.Instance.BindedDrags, __instance);
				int valueSafe3 = GeneralExtensions.GetValueSafe<PlayerControllerB, int>(SharedData.Instance.PlayerIDs, valueSafe2);
				SharedData.UpdateTimestampNow(__instance, valueSafe2);
				FlowermanLocationTask component = ((Component)__instance).gameObject.GetComponent<FlowermanLocationTask>();
				if ((Object)(object)component != (Object)null)
				{
					component.StopCheckStuckCoroutine();
				}
				GeneralUtils.ManuallyUnbindPlayer(__instance, valueSafe2);
				GeneralUtils.ManuallyDropPlayerOnHit(__instance, valueSafe2);
				FlowermanBinding component2 = ((Component)valueSafe2).gameObject.GetComponent<FlowermanBinding>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.UnbindPlayerServerRpc(valueSafe3, ((NetworkBehaviour)__instance).NetworkObjectId);
					component2.ResetEntityStatesServerRpc(valueSafe3, ((NetworkBehaviour)__instance).NetworkObjectId);
					component2.UnmufflePlayerVoiceServerRpc(valueSafe3);
					component2.GiveChillPillServerRpc(valueSafe3);
				}
				JustProcessed.Add(__instance);
			}
			return true;
		}

		private static int CountAlivePlayers()
		{
			return StartOfRound.Instance.livingPlayers;
		}

		[HarmonyPrefix]
		[HarmonyPatch("DropPlayerBody")]
		private static bool DropBodyPatch(FlowermanAI __instance)
		{
			if (!__instance.carryingPlayerBody || (Object)(object)__instance.bodyBeingCarried == (Object)null)
			{
				return false;
			}
			if (!SharedData.Instance.BindedDrags.ContainsKey(__instance))
			{
				return true;
			}
			PlayerControllerB val = SharedData.Instance.BindedDrags[__instance];
			if ((!((NetworkBehaviour)__instance).IsHost && !((NetworkBehaviour)__instance).IsServer) || (Object)(object)val == (Object)null)
			{
				return true;
			}
			if (!GeneralUtils.PrerequisiteKilling(__instance))
			{
				return false;
			}
			int valueSafe = GeneralExtensions.GetValueSafe<PlayerControllerB, int>(SharedData.Instance.PlayerIDs, val);
			if ((Object)(object)val == (Object)null)
			{
				SharedData.Instance.BindedDrags.Remove(__instance);
				return true;
			}
			if (!SharedData.Instance.DoDamageOnInterval)
			{
				val.inSpecialInteractAnimation = false;
				((Component)val).GetComponent<FlowermanBinding>().UnbindPlayerServerRpc(valueSafe, ((NetworkBehaviour)__instance).NetworkObjectId);
				FlowermanLocationTask component = ((Component)__instance).gameObject.GetComponent<FlowermanLocationTask>();
				if ((Object)(object)component != (Object)null)
				{
					component.StopCheckStuckCoroutine();
				}
				__instance.carryingPlayerBody = false;
				__instance.bodyBeingCarried = null;
				((EnemyAI)__instance).creatureAnimator.SetBool("carryingBody", false);
				GeneralUtils.FinishKillAnimationNormally(__instance, val, valueSafe);
			}
			return false;
		}

		private static bool RollForChance(int percentChance)
		{
			if (percentChance == 0)
			{
				return false;
			}
			if (percentChance < 0 || percentChance > 100)
			{
				throw new ArgumentOutOfRangeException("percentChance", "Percent chance must be between 0 and 100.");
			}
			int num = SharedData.RandomInstance.Next(1, 101);
			return num <= percentChance;
		}

		private static void DropDoubleHandedItem(PlayerControllerB player, bool itemsFall = true, bool disconnecting = false)
		{
			//IL_0011: 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)
			if (player.twoHanded)
			{
				player.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true);
			}
		}
	}
	[HarmonyPatch(typeof(EnemyAI))]
	internal class EnemyAIPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void FlowermanStart(EnemyAI __instance)
		{
			FlowermanAI val = (FlowermanAI)(object)((__instance is FlowermanAI) ? __instance : null);
			if (val != null)
			{
				SharedData.Instance.FlowermanIDs[((NetworkBehaviour)__instance).NetworkObjectId] = val;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("Update")]
		private static void UpdatePatcher(EnemyAI __instance)
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			FlowermanAI val = (FlowermanAI)(object)((__instance is FlowermanAI) ? __instance : null);
			if (val == null || !SharedData.Instance.BindedDrags.ContainsKey(val))
			{
				return;
			}
			PlayerControllerB valueSafe = GeneralExtensions.GetValueSafe<FlowermanAI, PlayerControllerB>(SharedData.Instance.BindedDrags, val);
			if ((Object)(object)valueSafe == (Object)null)
			{
				return;
			}
			if (valueSafe.isPlayerDead)
			{
				GeneralUtils.UnbindPlayerAndBracken(valueSafe, val);
				return;
			}
			UpdatePosition(val, valueSafe);
			if (!((NetworkBehaviour)__instance).IsHost && !((NetworkBehaviour)__instance).IsServer)
			{
				return;
			}
			int valueSafe2 = GeneralExtensions.GetValueSafe<PlayerControllerB, int>(SharedData.Instance.PlayerIDs, valueSafe);
			float num = SharedData.Instance.LastGrabbedTimeStamp[val];
			float num2 = Vector3.Distance(((Component)__instance).transform.position, __instance.favoriteSpot.position);
			if (((Time.time - num >= SharedData.Instance.KillAtTime && SharedData.Instance.KillBasedOffOfTime) || (num2 <= SharedData.Instance.DistanceFromFavorite && SharedData.Instance.KillBasedOffOfDistance)) && !SharedData.Instance.DoDamageOnInterval)
			{
				SharedData.UpdateTimestampNow(val, valueSafe);
				GeneralUtils.UnbindPlayerAndBracken(valueSafe, val);
				((Component)valueSafe).GetComponent<FlowermanBinding>().GiveChillPillServerRpc(valueSafe2);
				FlowermanLocationTask component = ((Component)__instance).gameObject.GetComponent<FlowermanLocationTask>();
				if ((Object)(object)component != (Object)null)
				{
					component.StopCheckStuckCoroutine();
				}
				GeneralUtils.FinishKillAnimationNormally(val, valueSafe, valueSafe2);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("MeetsStandardPlayerCollisionConditions")]
		private static bool OverrideCollisionCheck(EnemyAI __instance, Collider other, bool inKillAnimation = false, bool overrideIsInsideFactoryCheck = false)
		{
			if (!((NetworkBehaviour)__instance).IsHost)
			{
				return true;
			}
			FlowermanAI val = (FlowermanAI)(object)((__instance is FlowermanAI) ? __instance : null);
			if (val == null)
			{
				return true;
			}
			if (SharedData.Instance.LastGrabbedTimeStamp.ContainsKey(val))
			{
				if (Time.time - SharedData.Instance.LastGrabbedTimeStamp[val] <= SharedData.Instance.SecondsBeforeNextAttempt)
				{
					return false;
				}
				if (__instance.isEnemyDead)
				{
					return true;
				}
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !SharedData.Instance.BindedDrags.ContainsKey(val))
				{
					val.KillPlayerAnimationServerRpc((int)component.playerClientId);
				}
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("TargetClosestPlayer")]
		private static bool ClosestPlayerPatch(FlowermanAI __instance)
		{
			if (!((NetworkBehaviour)__instance).IsHost && !((NetworkBehaviour)__instance).IsServer)
			{
				return true;
			}
			return !SharedData.Instance.BindedDrags.ContainsKey(__instance);
		}

		[HarmonyPrefix]
		[HarmonyPatch("PlayerIsTargetable")]
		private static bool PlayerIsTargetablePatch(EnemyAI __instance, PlayerControllerB playerScript, bool cannotBeInShip = false)
		{
			if (SharedData.Instance.MonstersIgnorePlayers)
			{
				FlowermanAI val = (FlowermanAI)(object)((__instance is FlowermanAI) ? __instance : null);
				if (val != null)
				{
					if (SharedData.Instance.LastGrabbedTimeStamp.ContainsKey(val) && Time.time - SharedData.Instance.LastGrabbedTimeStamp[val] <= SharedData.Instance.SecondsBeforeNextAttempt)
					{
						return false;
					}
					return !SharedData.Instance.BindedDrags.ContainsKey(val);
				}
				return !SharedData.Instance.BindedDrags.ContainsValue(playerScript);
			}
			return true;
		}

		private static void UpdatePosition(FlowermanAI __instance, PlayerControllerB player)
		{
			//IL_000d: 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_001e: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			float num = -0.8f;
			Vector3 position = ((Component)__instance).transform.position + ((Component)__instance).transform.forward * num;
			((Component)player).transform.position = position;
		}
	}
	[HarmonyPatch(typeof(Landmine))]
	internal class LandminePatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("OnTriggerEnter")]
		private static bool PrefixTriggerEntry(Landmine __instance, Collider other)
		{
			if (!((NetworkBehaviour)__instance).IsHost && !((NetworkBehaviour)__instance).IsServer)
			{
				return true;
			}
			if (!SharedData.Instance.IgnoreMines)
			{
				return true;
			}
			FlowermanAI componentInParent = ((Component)other).gameObject.GetComponentInParent<FlowermanAI>();
			if ((Object)(object)componentInParent != (Object)null && SharedData.Instance.BindedDrags.ContainsKey(componentInParent))
			{
				return false;
			}
			PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
			if ((Object)(object)component != (Object)null && SharedData.Instance.BindedDrags.ContainsValue(component) && !component.isPlayerDead)
			{
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("OnTriggerExit")]
		private static bool PostfixTriggerExit(Landmine __instance, Collider other)
		{
			if (!SharedData.Instance.IgnoreMines)
			{
				return true;
			}
			FlowermanAI componentInParent = ((Component)other).gameObject.GetComponentInParent<FlowermanAI>();
			if ((Object)(object)componentInParent != (Object)null && SharedData.Instance.BindedDrags.ContainsKey(componentInParent))
			{
				return false;
			}
			PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
			if ((Object)(object)component != (Object)null && SharedData.Instance.BindedDrags.ContainsValue(component) && !component.isPlayerDead)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class TeleporterPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("TeleportPlayer")]
		private static bool PrefixTeleportPlayer(PlayerControllerB __instance, Vector3 pos, bool withRotation = false, float rot = 0f, bool allowInteractTrigger = false, bool enableController = true)
		{
			if (!((NetworkBehaviour)__instance).IsHost && !((NetworkBehaviour)__instance).IsServer)
			{
				return true;
			}
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			if (SharedData.Instance.BindedDrags.ContainsValue(__instance))
			{
				FlowermanAI val = GeneralUtils.SearchForCorrelatedFlowerman(__instance);
				if ((Object)(object)val != (Object)null)
				{
					if (!SharedData.Instance.AllowTeleports)
					{
						return false;
					}
					int playerId = SharedData.Instance.PlayerIDs[__instance];
					SharedData.UpdateTimestampNow(val, __instance);
					GeneralUtils.ManuallyUnbindPlayer(val, __instance);
					FlowermanBinding component = ((Component)__instance).gameObject.GetComponent<FlowermanBinding>();
					if ((Object)(object)component != (Object)null)
					{
						((Component)__instance).gameObject.GetComponent<FlowermanBinding>().ResetEntityStatesServerRpc(playerId, ((NetworkBehaviour)val).NetworkObjectId);
						((Component)__instance).gameObject.GetComponent<FlowermanBinding>().UnbindPlayerServerRpc(playerId, ((NetworkBehaviour)val).NetworkObjectId);
						((Component)__instance).gameObject.GetComponent<FlowermanBinding>().UnmufflePlayerVoiceServerRpc(playerId);
						((Component)__instance).gameObject.GetComponent<FlowermanBinding>().GiveChillPillServerRpc(playerId);
					}
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Turret))]
	internal class TurretPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("CheckForPlayersInLineOfSight")]
		private static void PostfixCheckForPlayersInLineOfSight(Turret __instance, ref PlayerControllerB __result, float radius, bool angleRangeCheck)
		{
			if (SharedData.Instance.IgnoreTurrets && (Object)(object)__result != (Object)null && SharedData.Instance.BindedDrags.ContainsValue(__result))
			{
				__result = null;
			}
		}
	}
}
namespace SnatchinBracken.Patches.data
{
	internal class SharedData
	{
		private static SharedData _instance;

		private static Random _random = new Random();

		public Dictionary<FlowermanAI, bool> GradualDamageCoroutineStarted = new Dictionary<FlowermanAI, bool>();

		public Dictionary<FlowermanAI, bool> InsanityCoroutineStarted = new Dictionary<FlowermanAI, bool>();

		public Dictionary<PlayerControllerB, float> DroppedTimestamp = new Dictionary<PlayerControllerB, float>();

		public static SharedData Instance => _instance ?? (_instance = new SharedData());

		public static Random RandomInstance => _random;

		public Dictionary<FlowermanAI, PlayerControllerB> BindedDrags { get; } = new Dictionary<FlowermanAI, PlayerControllerB>();


		public Dictionary<ulong, FlowermanAI> FlowermanIDs { get; } = new Dictionary<ulong, FlowermanAI>();


		public Dictionary<PlayerControllerB, int> PlayerIDs { get; } = new Dictionary<PlayerControllerB, int>();


		public Dictionary<int, PlayerControllerB> IDsToPlayerController { get; } = new Dictionary<int, PlayerControllerB>();


		public Dictionary<FlowermanAI, float> LastGrabbedTimeStamp { get; } = new Dictionary<FlowermanAI, float>();


		public bool DropItems { get; set; }

		public bool IgnoreTurrets { get; set; }

		public bool InstantKillIfAlone { get; set; }

		public bool IgnoreMines { get; set; }

		public bool AllowTeleports { get; set; }

		public bool DoDamageOnInterval { get; set; }

		public bool StuckForceKill { get; set; }

		public bool MonstersIgnorePlayers { get; set; }

		public bool BrackenRoom { get; set; }

		public bool KillBasedOffOfTime { get; set; }

		public float KillAtTime { get; set; }

		public float SecondsBeforeNextAttempt { get; set; }

		public int DamageDealtAtInterval { get; set; }

		public int PercentChanceForInsta { get; set; }

		public bool KillBasedOffOfDistance { get; set; }

		public float DistanceFromFavorite { get; set; }

		public Transform BrackenRoomPosition { get; set; }

		public static void UpdateTimestampNow(FlowermanAI flowermanAI, PlayerControllerB player)
		{
			Instance.LastGrabbedTimeStamp[flowermanAI] = Time.time;
			Instance.DroppedTimestamp[player] = Time.time;
		}

		public static void FlushDictionaries()
		{
			Instance.BindedDrags.Clear();
			Instance.FlowermanIDs.Clear();
			Instance.LastGrabbedTimeStamp.Clear();
			Instance.GradualDamageCoroutineStarted.Clear();
			Instance.DroppedTimestamp.Clear();
		}

		public static void GiveChillPillToAll()
		{
			foreach (KeyValuePair<FlowermanAI, PlayerControllerB> bindedDrag in Instance.BindedDrags)
			{
				int playerId = Instance.PlayerIDs[bindedDrag.Value];
				((Component)bindedDrag.Value).gameObject.GetComponent<FlowermanBinding>().GiveChillPillServerRpc(playerId);
			}
		}
	}
}
namespace SnatchingBracken
{
	internal class LethalConfigAPIHook
	{
		public static void InitializeConfig()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Expected O, but got Unknown
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Expected O, but got Unknown
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Expected O, but got Unknown
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Expected O, but got Unknown
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Expected O, but got Unknown
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Expected O, but got Unknown
			//IL_0329: Expected O, but got Unknown
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Expected O, but got Unknown
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Expected O, but got Unknown
			//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_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Expected O, but got Unknown
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Expected O, but got Unknown
			//IL_041c: Expected O, but got Unknown
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Expected O, but got Unknown
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0494: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Expected O, but got Unknown
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Expected O, but got Unknown
			//IL_04a7: Expected O, but got Unknown
			//IL_04af: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Expected O, but got Unknown
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			//IL_051f: Expected O, but got Unknown
			//IL_057a: 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_0587: Unknown result type (might be due to invalid IL or missing references)
			//IL_058e: Expected O, but got Unknown
			//IL_058f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0597: Expected O, but got Unknown
			//IL_059a: Expected O, but got Unknown
			//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a9: Expected O, but got Unknown
			//IL_060a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0611: Expected O, but got Unknown
			//IL_066c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0671: Unknown result type (might be due to invalid IL or missing references)
			//IL_0679: Unknown result type (might be due to invalid IL or missing references)
			//IL_0680: Expected O, but got Unknown
			//IL_0681: Unknown result type (might be due to invalid IL or missing references)
			//IL_0689: Expected O, but got Unknown
			//IL_068c: Expected O, but got Unknown
			//IL_0694: Unknown result type (might be due to invalid IL or missing references)
			//IL_069b: Expected O, but got Unknown
			//IL_06fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0704: Expected O, but got Unknown
			LethalConfigManager.SetModDescription("A mod that alters the behavior of the Bracken. The Bracken pulls players into a new spot before performing a kill. DON'T CHANGE SETTINGS WHILE THE BRACKEN IS ACTIVELY GRABBING!");
			ConfigEntry<bool> dropItemsOption = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Drop Items on Snatch", true, "Should players drop their items when a Bracken grabs them?");
			BoolCheckBoxConfigItem val = new BoolCheckBoxConfigItem(dropItemsOption);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val);
			SharedData.Instance.DropItems = dropItemsOption.Value;
			dropItemsOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.DropItems = dropItemsOption.Value;
				}
			};
			ConfigEntry<bool> turretOption = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Ignore Turrets on Snatch", true, "Should players be ignored by turrets when dragged?");
			BoolCheckBoxConfigItem val2 = new BoolCheckBoxConfigItem(turretOption);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
			SharedData.Instance.IgnoreTurrets = turretOption.Value;
			turretOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.IgnoreTurrets = turretOption.Value;
				}
			};
			ConfigEntry<bool> stuckForceKillOption = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Stuck Force Kill", false, "If enabled, Brackens will force kill when stuck at the same spot for at least 5 seconds.");
			BoolCheckBoxConfigItem val3 = new BoolCheckBoxConfigItem(stuckForceKillOption);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val3);
			SharedData.Instance.StuckForceKill = stuckForceKillOption.Value;
			stuckForceKillOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.StuckForceKill = stuckForceKillOption.Value;
				}
			};
			ConfigEntry<bool> brackenRoomOption = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Force Set Favorite Location To Bracken Room", true, "If enabled, Brackens' favorite locations will be set to the Bracken room. The room sometimes doesn't spawn, so please don't be alarmed if they don't take you there if this is enabled.");
			BoolCheckBoxConfigItem val4 = new BoolCheckBoxConfigItem(brackenRoomOption);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val4);
			SharedData.Instance.BrackenRoom = brackenRoomOption.Value;
			brackenRoomOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.BrackenRoom = brackenRoomOption.Value;
				}
			};
			ConfigEntry<bool> allowDraggedTps = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Allow teleports to save dragged players", true, "Should players be able to be saved through teleportation?");
			BoolCheckBoxConfigItem val5 = new BoolCheckBoxConfigItem(allowDraggedTps);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val5);
			SharedData.Instance.AllowTeleports = allowDraggedTps.Value;
			allowDraggedTps.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.AllowTeleports = allowDraggedTps.Value;
				}
			};
			ConfigEntry<bool> mineOption = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Ignore Mines on Snatch", true, "Should players ignore Landmines while being dragged?");
			BoolCheckBoxConfigItem val6 = new BoolCheckBoxConfigItem(mineOption);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val6);
			SharedData.Instance.IgnoreMines = mineOption.Value;
			mineOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.IgnoreMines = mineOption.Value;
				}
			};
			ConfigEntry<bool> monstersIgnorePlayersOption = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Enemies Ignore Dragged Players", true, "Should players be ignored by other monsters while being dragged?");
			BoolCheckBoxConfigItem val7 = new BoolCheckBoxConfigItem(monstersIgnorePlayersOption);
			SharedData.Instance.MonstersIgnorePlayers = monstersIgnorePlayersOption.Value;
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val7);
			monstersIgnorePlayersOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.MonstersIgnorePlayers = monstersIgnorePlayersOption.Value;
				}
			};
			ConfigEntry<int> instaKillPercentEntry = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<int>("SnatchinBracken Settings", "Chance for Insta Kill", 0, "Percent chance for insta kill, 0 to disable.");
			IntSliderOptions val8 = new IntSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<int>)val8).Min = 0;
			((BaseRangeOptions<int>)val8).Max = 100;
			IntSliderOptions val9 = val8;
			IntSliderConfigItem val10 = new IntSliderConfigItem(instaKillPercentEntry, val9);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val10);
			SharedData.Instance.PercentChanceForInsta = instaKillPercentEntry.Value;
			instaKillPercentEntry.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.PercentChanceForInsta = instaKillPercentEntry.Value;
				}
			};
			ConfigEntry<bool> allowSecondsUntilAutoKill = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Allow Seconds Until Auto Kill", true, "If disabled, the Bracken won't kill based on time configured in \"Seconds Until Auto Kill\" (although may still kill if auto stuck is toggled off).");
			BoolCheckBoxConfigItem val11 = new BoolCheckBoxConfigItem(allowSecondsUntilAutoKill);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val11);
			SharedData.Instance.KillBasedOffOfTime = allowSecondsUntilAutoKill.Value;
			allowSecondsUntilAutoKill.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.KillBasedOffOfTime = allowSecondsUntilAutoKill.Value;
				}
			};
			ConfigEntry<int> brackenKillTimeEntry = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<int>("SnatchinBracken Settings", "Seconds Until Auto Kill", 15, "Time in seconds until Bracken automatically kills when grabbed. Range: 1-60 seconds.");
			IntSliderOptions val12 = new IntSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<int>)val12).Min = 1;
			((BaseRangeOptions<int>)val12).Max = 60;
			IntSliderOptions val13 = val12;
			IntSliderConfigItem val14 = new IntSliderConfigItem(brackenKillTimeEntry, val13);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val14);
			SharedData.Instance.KillAtTime = brackenKillTimeEntry.Value;
			brackenKillTimeEntry.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.KillAtTime = brackenKillTimeEntry.Value;
				}
			};
			ConfigEntry<int> brackenNextAttemptEntry = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<int>("SnatchinBracken Settings", "Seconds Until Next Attempt", 5, "Time in seconds until Bracken is allowed to take another victim.");
			IntSliderOptions val15 = new IntSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<int>)val15).Min = 1;
			((BaseRangeOptions<int>)val15).Max = 60;
			IntSliderOptions val16 = val15;
			IntSliderConfigItem val17 = new IntSliderConfigItem(brackenNextAttemptEntry, val16);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val17);
			SharedData.Instance.SecondsBeforeNextAttempt = brackenNextAttemptEntry.Value;
			brackenNextAttemptEntry.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.SecondsBeforeNextAttempt = brackenNextAttemptEntry.Value;
				}
			};
			ConfigEntry<bool> doDamageOnIntervalEntry = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Do Gradual Damage", false, "Should players be hurt gradually while being dragged?");
			BoolCheckBoxConfigItem val18 = new BoolCheckBoxConfigItem(doDamageOnIntervalEntry);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val18);
			SharedData.Instance.DoDamageOnInterval = doDamageOnIntervalEntry.Value;
			doDamageOnIntervalEntry.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.DoDamageOnInterval = doDamageOnIntervalEntry.Value;
				}
			};
			ConfigEntry<int> damageDealtProgressively = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<int>("SnatchinBracken Settings", "Damage Dealt At Interval", 5, "This only applies if you have \"Do Gradual Damage\" enabled. While dragged, every second this configured amount of damage will be dealt to the player. Keep in mind, players still regenerate in critical condition.");
			IntSliderOptions val19 = new IntSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<int>)val19).Min = 1;
			((BaseRangeOptions<int>)val19).Max = 100;
			IntSliderOptions val20 = val19;
			IntSliderConfigItem val21 = new IntSliderConfigItem(damageDealtProgressively, val20);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val21);
			SharedData.Instance.DamageDealtAtInterval = damageDealtProgressively.Value;
			damageDealtProgressively.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.DamageDealtAtInterval = damageDealtProgressively.Value;
				}
			};
			ConfigEntry<bool> allowDistanceBasedKiller = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Allow Distance Until Auto Kill", true, "If disabled, the Bracken won't kill based on distance from favorite spot configured in \"Distance For Kill\" (although may still kill if auto stuck is toggled off).");
			BoolCheckBoxConfigItem val22 = new BoolCheckBoxConfigItem(allowDistanceBasedKiller);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val22);
			SharedData.Instance.KillBasedOffOfDistance = allowDistanceBasedKiller.Value;
			allowDistanceBasedKiller.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.KillBasedOffOfDistance = allowDistanceBasedKiller.Value;
				}
			};
			ConfigEntry<int> distanceAutoKillerEntry = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<int>("SnatchinBracken Settings", "Distance For Kill", 1, "How far should the Bracken be from its favorite spot to initiate a kill?");
			IntSliderOptions val23 = new IntSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<int>)val23).Min = 1;
			((BaseRangeOptions<int>)val23).Max = 60;
			IntSliderOptions val24 = val23;
			IntSliderConfigItem val25 = new IntSliderConfigItem(distanceAutoKillerEntry, val24);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val25);
			SharedData.Instance.DistanceFromFavorite = distanceAutoKillerEntry.Value;
			distanceAutoKillerEntry.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.DistanceFromFavorite = distanceAutoKillerEntry.Value;
				}
			};
			ConfigEntry<bool> instaKillOption = ((BaseUnityPlugin)SnatchinBrackenBase.Instance).Config.Bind<bool>("SnatchinBracken Settings", "Instakill When Alone", false, "Should players be instantly killed if they're alone?");
			BoolCheckBoxConfigItem val26 = new BoolCheckBoxConfigItem(instaKillOption);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val26);
			SharedData.Instance.InstantKillIfAlone = instaKillOption.Value;
			instaKillOption.SettingChanged += delegate
			{
				if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
				{
					SharedData.Instance.InstantKillIfAlone = instaKillOption.Value;
				}
			};
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("IHittable.Hit")]
		private static bool HitOverride(PlayerControllerB __instance, int force, Vector3 hitDirection, PlayerControllerB playerWhoHit, bool playHitSFX = false)
		{
			if (SharedData.Instance.BindedDrags.ContainsValue(__instance) || (SharedData.Instance.DroppedTimestamp.ContainsKey(__instance) && SharedData.Instance.DroppedTimestamp[__instance] + 1f >= Time.time))
			{
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("Awake")]
		private static void onAwake(PlayerControllerB __instance)
		{
			if ((Object)(object)((Component)__instance).gameObject.GetComponent<FlowermanBinding>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<FlowermanBinding>();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		private static void onStart(PlayerControllerB __instance)
		{
			if ((Object)(object)((Component)__instance).gameObject.GetComponent<FlowermanBinding>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<FlowermanBinding>();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("KillPlayer")]
		private static void KillPlayerPatch(PlayerControllerB __instance, Vector3 bodyVelocity, bool spawnBody = true, CauseOfDeath causeOfDeath = 0, int deathAnimation = 0)
		{
			if (!SharedData.Instance.BindedDrags.ContainsValue(__instance))
			{
				return;
			}
			FlowermanAI val = GeneralUtils.SearchForCorrelatedFlowerman(__instance);
			if ((Object)(object)val != (Object)null)
			{
				int playerId = SharedData.Instance.PlayerIDs[__instance];
				FlowermanBinding component = ((Component)__instance).gameObject.GetComponent<FlowermanBinding>();
				if ((Object)(object)component != (Object)null)
				{
					component.ResetEntityStatesServerRpc(playerId, ((NetworkBehaviour)val).NetworkObjectId);
					component.GiveChillPillServerRpc(playerId);
					component.UnbindPlayerServerRpc(playerId, ((NetworkBehaviour)val).NetworkObjectId);
				}
				GeneralUtils.StopGradualDamageCoroutine(val, __instance);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("SetPlayerSanityLevel")]
		private static bool SetSanityLevel(PlayerControllerB __instance)
		{
			if (SharedData.Instance.BindedDrags.ContainsValue(__instance))
			{
				return false;
			}
			return true;
		}
	}
}
namespace SnatchingBracken.Utils
{
	internal class GeneralUtils
	{
		private static GeneralUtils instance;

		public static GeneralUtils Instance
		{
			get
			{
				if (instance == null)
				{
					instance = new GeneralUtils();
				}
				return instance;
			}
		}

		public static FlowermanAI SearchForCorrelatedFlowerman(PlayerControllerB player)
		{
			foreach (KeyValuePair<FlowermanAI, PlayerControllerB> bindedDrag in SharedData.Instance.BindedDrags)
			{
				if (bindedDrag.Value.actualClientId == player.actualClientId)
				{
					return bindedDrag.Key;
				}
			}
			return null;
		}

		public static void ManuallyUnbindPlayer(FlowermanAI flowerman, PlayerControllerB player)
		{
			int valueSafe = GeneralExtensions.GetValueSafe<PlayerControllerB, int>(SharedData.Instance.PlayerIDs, player);
			player.inSpecialInteractAnimation = false;
			flowerman.carryingPlayerBody = false;
			((EnemyAI)flowerman).creatureAnimator.SetBool("killing", false);
			((EnemyAI)flowerman).creatureAnimator.SetBool("carryingBody", false);
			flowerman.FinishKillAnimation(false);
			((EnemyAI)flowerman).stunnedByPlayer = null;
			((EnemyAI)flowerman).stunNormalizedTimer = 0f;
			((EnemyAI)flowerman).favoriteSpot = null;
		}

		public static void ManuallyDropPlayerOnHit(FlowermanAI __instance, PlayerControllerB player)
		{
			player.inSpecialInteractAnimation = false;
			player.inAnimationWithEnemy = null;
			__instance.carryingPlayerBody = false;
			((EnemyAI)__instance).creatureAnimator.SetBool("killing", false);
			((EnemyAI)__instance).creatureAnimator.SetBool("carryingBody", false);
			__instance.angerMeter = 0f;
			__instance.isInAngerMode = false;
			((EnemyAI)__instance).stunnedByPlayer = null;
			((EnemyAI)__instance).stunNormalizedTimer = 0f;
			__instance.evadeStealthTimer = 0.1f;
			__instance.timesThreatened = 0;
			__instance.FinishKillAnimation(false);
		}

		public static void RemoveDictionaryReferences(FlowermanAI __instance, PlayerControllerB player, int playerId)
		{
			SharedData.Instance.GradualDamageCoroutineStarted.Remove(__instance);
			FlowermanBinding component = ((Component)player).gameObject.GetComponent<FlowermanBinding>();
			component.ResetEntityStatesServerRpc(playerId, ((NetworkBehaviour)__instance).NetworkObjectId);
			component.GiveChillPillServerRpc(playerId);
			component.UnbindPlayerServerRpc(playerId, ((NetworkBehaviour)__instance).NetworkObjectId);
		}

		public static void StopGradualDamageCoroutine(FlowermanAI flowermanAI, PlayerControllerB player)
		{
			if (SharedData.Instance.GradualDamageCoroutineStarted.ContainsKey(flowermanAI))
			{
				((MonoBehaviour)flowermanAI).StopCoroutine(DoGradualDamage(flowermanAI, player, 1f, SharedData.Instance.DamageDealtAtInterval));
				SharedData.Instance.GradualDamageCoroutineStarted.Remove(flowermanAI);
			}
		}

		public static IEnumerator DoGradualDamage(FlowermanAI flowermanAI, PlayerControllerB player, float damageInterval, int damageAmount)
		{
			while (!player.isPlayerDead && (Object)(object)flowermanAI != (Object)null && SharedData.Instance.BindedDrags.ContainsKey(flowermanAI))
			{
				yield return (object)new WaitForSeconds(damageInterval);
				if (!player.isPlayerDead && (Object)(object)flowermanAI != (Object)null && SharedData.Instance.BindedDrags.ContainsKey(flowermanAI))
				{
					if (player.health - damageAmount <= 0)
					{
						StopGradualDamageCoroutine(flowermanAI, player);
						player.inSpecialInteractAnimation = false;
						int id2 = SharedData.Instance.PlayerIDs[player];
						FlowermanBinding flowermanBinding = ((Component)player).gameObject.GetComponent<FlowermanBinding>();
						if ((Object)(object)flowermanBinding != (Object)null)
						{
							flowermanBinding.UnbindPlayerServerRpc(id2, ((NetworkBehaviour)flowermanAI).NetworkObjectId);
							flowermanBinding.ResetEntityStatesServerRpc(id2, ((NetworkBehaviour)flowermanAI).NetworkObjectId);
							flowermanBinding.UnmufflePlayerVoiceServerRpc(id2);
							flowermanBinding.GiveChillPillServerRpc(id2);
						}
						FlowermanLocationTask task = ((Component)flowermanAI).gameObject.GetComponent<FlowermanLocationTask>();
						if ((Object)(object)task != (Object)null)
						{
							task.StopCheckStuckCoroutine();
						}
						flowermanAI.carryingPlayerBody = false;
						flowermanAI.bodyBeingCarried = null;
						((EnemyAI)flowermanAI).creatureAnimator.SetBool("carryingBody", false);
						FinishKillAnimationNormally(flowermanAI, player, id2);
					}
					else
					{
						int id = SharedData.Instance.PlayerIDs[player];
						((Component)player).GetComponent<FlowermanBinding>().DamagePlayerServerRpc(id, damageAmount);
					}
				}
				else
				{
					StopGradualDamageCoroutine(flowermanAI, player);
				}
			}
		}

		public static void UnbindPlayerAndBracken(PlayerControllerB player, FlowermanAI __instance)
		{
			if (SharedData.Instance.PlayerIDs.ContainsKey(player))
			{
				int valueSafe = GeneralExtensions.GetValueSafe<PlayerControllerB, int>(SharedData.Instance.PlayerIDs, player);
				player.inSpecialInteractAnimation = false;
				player.inAnimationWithEnemy = null;
				__instance.carryingPlayerBody = true;
				((EnemyAI)__instance).creatureAnimator.SetBool("killing", false);
				((EnemyAI)__instance).creatureAnimator.SetBool("carryingBody", false);
				((EnemyAI)__instance).stunnedByPlayer = null;
				((EnemyAI)__instance).stunNormalizedTimer = 0f;
				__instance.angerMeter = 0f;
				__instance.isInAngerMode = false;
				__instance.timesThreatened = 0;
				__instance.FinishKillAnimation(false);
				RemoveDictionaryReferences(__instance, player, valueSafe);
			}
		}

		public static bool PrerequisiteKilling(FlowermanAI flowerman)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (SharedData.Instance.LastGrabbedTimeStamp.ContainsKey(flowerman))
			{
				float num = SharedData.Instance.LastGrabbedTimeStamp[flowerman];
				float num2 = Vector3.Distance(((Component)flowerman).transform.position, ((EnemyAI)flowerman).favoriteSpot.position);
				if (Time.time - num >= SharedData.Instance.KillAtTime || num2 <= SharedData.Instance.DistanceFromFavorite)
				{
					return true;
				}
			}
			return false;
		}

		public static void FinishKillAnimationNormally(FlowermanAI __instance, PlayerControllerB playerControllerB, int playerId)
		{
			((EnemyAI)__instance).inSpecialAnimationWithPlayer = playerControllerB;
			playerControllerB.inSpecialInteractAnimation = true;
			__instance.KillPlayerAnimationClientRpc(playerId);
		}
	}
}
namespace SnatchingBracken.Patches.tasks
{
	public class FlowermanLocationTask : MonoBehaviour
	{
		private Coroutine checkStuckCoroutine;

		public void StartCheckStuckCoroutine(FlowermanAI flowermanAI, PlayerControllerB player)
		{
			checkStuckCoroutine = ((MonoBehaviour)this).StartCoroutine(CheckIfStuck(flowermanAI, player));
		}

		public void StopCheckStuckCoroutine()
		{
			if (checkStuckCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(checkStuckCoroutine);
				checkStuckCoroutine = null;
			}
		}

		private IEnumerator CheckIfStuck(FlowermanAI flowermanAI, PlayerControllerB player)
		{
			Vector3 lastPosition = ((Component)flowermanAI).transform.position;
			while ((Object)(object)flowermanAI != (Object)null)
			{
				yield return (object)new WaitForSeconds(5f);
				Vector3 currentPosition = ((Component)flowermanAI).transform.position;
				if (Vector3.Distance(lastPosition, currentPosition) <= 1f)
				{
					HandleStuckFlowerman(flowermanAI, player);
				}
				lastPosition = currentPosition;
			}
		}

		private void HandleStuckFlowerman(FlowermanAI flowermanAI, PlayerControllerB player)
		{
			StopCheckStuckCoroutine();
			int playerId = SharedData.Instance.PlayerIDs[player];
			SharedData.UpdateTimestampNow(flowermanAI, player);
			GeneralUtils.UnbindPlayerAndBracken(player, flowermanAI);
			((Component)player).GetComponent<FlowermanBinding>().GiveChillPillServerRpc(playerId);
			GeneralUtils.FinishKillAnimationNormally(flowermanAI, player, playerId);
		}
	}
}
namespace SnatchingBracken.Patches.ship
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("ShipLeave")]
		private static void PrefixShipLeave(StartOfRoundPatch __instance)
		{
			SharedData.Instance.BrackenRoomPosition = null;
			SharedData.FlushDictionaries();
			SharedData.GiveChillPillToAll();
		}

		[HarmonyPrefix]
		[HarmonyPatch("openingDoorsSequence")]
		private static void ClearPlayerSanityOnLand(StartOfRound __instance)
		{
			SharedData.GiveChillPillToAll();
		}
	}
}
namespace SnatchingBracken.Patches.network
{
	public class FlowermanBinding : NetworkBehaviour
	{
		[ServerRpc(RequireOwnership = false)]
		public void BindPlayerServerRpc(int playerId, ulong flowermanId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2841149136u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					BytePacker.WriteValueBitPacked(val2, flowermanId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2841149136u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					AddBindingsClientRpc(playerId, flowermanId);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void UnbindPlayerServerRpc(int playerId, ulong flowermanId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1240084643u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					BytePacker.WriteValueBitPacked(val2, flowermanId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1240084643u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					RemoveBindingsClientRpc(playerId, flowermanId);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void ResetEntityStatesServerRpc(int playerId, ulong flowermanId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3697084031u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					BytePacker.WriteValueBitPacked(val2, flowermanId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3697084031u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ResetEntityStatesClientRpc(playerId, flowermanId);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void PrepForBindingServerRpc(int playerId, ulong flowermanId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3576432139u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					BytePacker.WriteValueBitPacked(val2, flowermanId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3576432139u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					PrepForBindingClientRpc(playerId, flowermanId);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void DamagePlayerServerRpc(int playerId, int damage)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1928701905u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					BytePacker.WriteValueBitPacked(val2, damage);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1928701905u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					DamagePlayerClientRpc(playerId, damage);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void UpdateFavoriteSpotServerRpc(int playerId, ulong flowermanId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3595148175u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					BytePacker.WriteValueBitPacked(val2, flowermanId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3595148175u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					UpdateFavoriteSpotClientRpc(playerId, flowermanId);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void MufflePlayerVoiceServerRpc(int playerId)
		{
			//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)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2582248323u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2582248323u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					MufflePlayerVoiceClientRpc(playerId);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void UnmufflePlayerVoiceServerRpc(int playerId)
		{
			//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)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3509983500u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3509983500u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					UnmufflePlayerVoiceClientRpc(playerId);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void MakeInsaneServerRpc(int playerId, float targetInsanity)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_008a: 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)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2823097549u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref targetInsanity, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2823097549u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					MakeInsaneClientRpc(playerId, targetInsanity);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void GiveChillPillServerRpc(int playerId)
		{
			//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)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3204958366u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3204958366u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					GiveChillPillClientRpc(playerId);
				}
			}
		}

		[ClientRpc]
		public void UpdateFavoriteSpotClientRpc(int playerId, ulong flowermanId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1506678615u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					BytePacker.WriteValueBitPacked(val2, flowermanId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1506678615u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerId];
					FlowermanAI val4 = SharedData.Instance.FlowermanIDs[flowermanId];
					Transform favoriteSpot = ((!SharedData.Instance.BrackenRoom || !((Object)(object)SharedData.Instance.BrackenRoomPosition != (Object)null)) ? ((EnemyAI)val4).ChooseFarthestNodeFromPosition(((Component)val3).transform.position, false, 0, false, 50, false) : SharedData.Instance.BrackenRoomPosition);
					((EnemyAI)val4).favoriteSpot = favoriteSpot;
				}
			}
		}

		[ClientRpc]
		public void GiveChillPillClientRpc(int playerId)
		{
			//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)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3079751162u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3079751162u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerId];
				if ((Object)(object)val3 == (Object)(object)StartOfRound.Instance.localPlayerController)
				{
					val3.insanityLevel = 0f;
					StartOfRound.Instance.fearLevelIncreasing = false;
					StartOfRound.Instance.fearLevel = 0f;
				}
			}
		}

		[ClientRpc]
		public void MakeInsaneClientRpc(int playerId, float targetInsanity)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_008a: 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)
			//IL_00a4: 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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(182933403u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref targetInsanity, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 182933403u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerId];
				if ((Object)(object)val3 == (Object)(object)StartOfRound.Instance.localPlayerController)
				{
					val3.JumpToFearLevel(targetInsanity, true);
				}
			}
		}

		[ClientRpc]
		public void MufflePlayerVoiceClientRpc(int playerId)
		{
			//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)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1450070789u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1450070789u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerId];
				if ((Object)(object)val3.currentVoiceChatAudioSource == (Object)null)
				{
					StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
				}
				if ((Object)(object)val3.currentVoiceChatAudioSource != (Object)null)
				{
					((Component)val3.currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>().lowpassResonanceQ = 5f;
					OccludeAudio component = ((Component)val3.currentVoiceChatAudioSource).GetComponent<OccludeAudio>();
					component.overridingLowPass = true;
					component.lowPassOverride = 500f;
					val3.voiceMuffledByEnemy = true;
				}
			}
		}

		[ClientRpc]
		public void UnmufflePlayerVoiceClientRpc(int playerId)
		{
			//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)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2434358873u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2434358873u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerId];
				if ((Object)(object)val3.currentVoiceChatAudioSource == (Object)null)
				{
					StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
				}
				if ((Object)(object)val3.currentVoiceChatAudioSource != (Object)null)
				{
					((Component)val3.currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>().lowpassResonanceQ = 1f;
					OccludeAudio component = ((Component)val3.currentVoiceChatAudioSource).GetComponent<OccludeAudio>();
					component.overridingLowPass = false;
					component.lowPassOverride = 20000f;
					val3.voiceMuffledByEnemy = false;
				}
			}
		}

		[ClientRpc]
		public void DamagePlayerClientRpc(int playerId, int damage)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1193047885u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					BytePacker.WriteValueBitPacked(val2, damage);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1193047885u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerId];
					val3.DamagePlayer(damage, true, true, (CauseOfDeath)5, 0, false, default(Vector3));
				}
			}
		}

		[ClientRpc]
		public void ResetEntityStatesClientRpc(int playerId, ulong flowermanId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2270563105u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					BytePacker.WriteValueBitPacked(val2, flowermanId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2270563105u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerId];
					FlowermanAI val4 = SharedData.Instance.FlowermanIDs[flowermanId];
					val3.inSpecialInteractAnimation = false;
					val3.inAnimationWithEnemy = null;
					val4.carryingPlayerBody = false;
					((EnemyAI)val4).creatureAnimator.SetBool("killing", false);
					((EnemyAI)val4).creatureAnimator.SetBool("carryingBody", false);
					((EnemyAI)val4).stunnedByPlayer = null;
					((EnemyAI)val4).stunNormalizedTimer = 0f;
					val4.angerMeter = 0f;
					val4.isInAngerMode = false;
					val4.timesThreatened = 0;
					val4.inKillAnimation = false;
					val4.evadeStealthTimer = 0.1f;
					((EnemyAI)val4).inSpecialAnimationWithPlayer = null;
					((EnemyAI)val4).inSpecialAnimation = false;
					((EnemyAI)val4).SetClientCalculatingAI(false);
					((Behaviour)((EnemyAI)val4).agent).enabled = true;
					((EnemyAI)val4).favoriteSpot = null;
					val4.FinishKillAnimation(false);
				}
			}
		}

		[ClientRpc]
		public void PrepForBindingClientRpc(int playerId, ulong flowermanId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1304423344u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					BytePacker.WriteValueBitPacked(val2, flowermanId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1304423344u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerId];
					FlowermanAI val4 = SharedData.Instance.FlowermanIDs[flowermanId];
					((EnemyAI)val4).creatureAnimator.SetBool("killing", false);
					((EnemyAI)val4).creatureAnimator.SetBool("carryingBody", true);
					val4.carryingPlayerBody = true;
					val3.inSpecialInteractAnimation = true;
					val4.inKillAnimation = false;
					((EnemyAI)val4).targetPlayer = null;
				}
			}
		}

		[ClientRpc]
		public void AddBindingsClientRpc(int playerId, ulong flowermanId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1647441961u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					BytePacker.WriteValueBitPacked(val2, flowermanId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1647441961u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerId];
					FlowermanAI key = SharedData.Instance.FlowermanIDs[flowermanId];
					SharedData.Instance.BindedDrags[key] = val3;
					SharedData.Instance.PlayerIDs[val3] = playerId;
					SharedData.Instance.IDsToPlayerController[playerId] = val3;
					SharedData.Instance.LastGrabbedTimeStamp[key] = Time.time;
				}
			}
		}

		[ClientRpc]
		public void RemoveBindingsClientRpc(int playerId, ulong flowermanID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2727274551u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					BytePacker.WriteValueBitPacked(val2, flowermanID);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2727274551u, val, (RpcDelivery)0);