Decompiled source of LycansNewRoles v0.98.0

plugins/LycansNewRoles/LycansNewRoles.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using DynamicSmokeSystem;
using Fusion;
using Fusion.Sockets;
using HarmonyLib;
using HarmonyLib.Tools;
using Helpers.Collections;
using LycansNewRoles.NewEffects;
using LycansNewRoles.NewItems;
using LycansNewRoles.NewPrimaryRoles;
using LycansNewRoles.Sabotages;
using Managers;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.Localization;
using UnityEngine.Localization.Components;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using UnityEngine.Scripting;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LycansNewRoles")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c3522b56c07da0ecb375c2eddf9c2807d3d165f6")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("LycansNewRoles")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LycansNewRoles
{
	[HarmonyPatch(typeof(LightingManager), "FixedUpdateNetwork")]
	internal class AmogusModeNoCyclePatch
	{
		private static bool Prefix(LightingManager __instance)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (NetworkBool.op_Implicit(Plugin.CustomConfig.AmogusMode))
				{
					return false;
				}
				return true;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("AmogusModeNoCyclePatch error: " + ex));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerController), "Interact")]
	internal class AmogusModeInteractPatch
	{
		private static void Postfix(bool isPrimary, PlayerController __instance)
		{
			//IL_0007: 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)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Invalid comparison between Unknown and I4
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Invalid comparison between Unknown and I4
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!NetworkBool.op_Implicit(Plugin.CustomConfig.AmogusMode))
				{
					return;
				}
				if (LycansUtility.GameActuallyInPlay && (Object)(object)__instance.targetObject != (Object)null && !NetworkBool.op_Implicit(GameManager.LightingManager.IsNight))
				{
					PlayerController componentInParent = __instance.targetObject.GetComponentInParent<PlayerController>();
					PlayerCustom player = PlayerCustomRegistry.GetPlayer(PlayerController.Local.Ref);
					if ((Object)(object)componentInParent != (Object)null && NetworkBool.op_Implicit(componentInParent.IsDead))
					{
						AmogusManager.Rpc_Report(((SimulationBehaviour)__instance).Runner, __instance.Index, componentInParent.Index);
					}
				}
				if (!LycansUtility.GameActuallyInPlay || NetworkBool.op_Implicit(GameManager.LightingManager.IsNight) || !((Object)(object)__instance.targetObject != (Object)null) || (int)__instance.Role != 1)
				{
					return;
				}
				PlayerController componentInParent2 = __instance.targetObject.GetComponentInParent<PlayerController>();
				PlayerCustom player2 = PlayerCustomRegistry.GetPlayer(PlayerController.Local.Ref);
				if ((Object)(object)componentInParent2 != (Object)null && (int)componentInParent2.Role != 1 && !NetworkBool.op_Implicit(componentInParent2.IsDead))
				{
					TickTimer amogusModeKillCooldown = player2.AmogusModeKillCooldown;
					if (!((TickTimer)(ref amogusModeKillCooldown)).IsRunning)
					{
						componentInParent2.Rpc_Kill(__instance.Ref);
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("AmogusModeInteractPatch error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(PlayerController), "Rpc_Kill")]
	internal class AmogusModeKillSilentPatch
	{
		private unsafe static bool Prefix(PlayerRef killer, PlayerController __instance)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!NetworkBool.op_Implicit(Plugin.CustomConfig.AmogusMode))
				{
					return true;
				}
				if (NetworkBehaviourUtils.InvokeRpc)
				{
					NetworkBehaviourUtils.InvokeRpc = false;
				}
				else
				{
					NetworkRunner runner = ((SimulationBehaviour)__instance).Runner;
					if ((Object)(object)runner == (Object)null)
					{
						throw new ArgumentNullException("runner");
					}
					if ((int)runner.Stage == 4)
					{
						return false;
					}
					if (runner.HasAnyActiveConnections())
					{
						int num = 8;
						num += 4;
						SimulationMessage* ptr = SimulationMessage.Allocate(((SimulationBehaviour)__instance).Runner.Simulation, num);
						byte* data = SimulationMessage.GetData(ptr);
						int num2 = RpcHeader.Write(RpcHeader.Create(((SimulationBehaviour)__instance).Object.Id, ((NetworkBehaviour)__instance).ObjectIndex, 12), data);
						Unsafe.Write(data + num2, killer);
						num2 += 4;
						((SimulationMessage)ptr).Offset = num2 * 8;
						((SimulationBehaviour)__instance).Runner.SendRpc(ptr);
					}
				}
				if (((SimulationBehaviour)__instance).HasStateAuthority)
				{
					if (!((PlayerRef)(ref killer)).IsNone)
					{
						PlayerController player = PlayerRegistry.GetPlayer(killer);
						PlayerCustom player2 = PlayerCustomRegistry.GetPlayer(killer);
						TickTimer amogusModeKillCooldown = player2.AmogusModeKillCooldown;
						if (((TickTimer)(ref amogusModeKillCooldown)).IsRunning)
						{
							return false;
						}
						player2.AmogusModeKillCooldown = TickTimer.CreateFromSeconds(((SimulationBehaviour)__instance).Runner, 30f);
						__instance.Killer = killer;
					}
					__instance.IsDead = NetworkBool.op_Implicit(true);
					GameManager.Instance.CheckForEndGame();
				}
				return false;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("AmogusModeKillSilentPatch error: " + ex));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(GameState), "Spawned")]
	internal class AmogusModeStateMachinePatch
	{
		private static void Postfix(GameState __instance)
		{
			try
			{
				StateMachine<EGameState> value = Traverse.Create((object)__instance).Field<StateMachine<EGameState>>("StateMachine").Value;
				GameState gameState = __instance;
				StateHooks<EGameState> obj = value[(EGameState)2];
				obj.onEnter = (Action<EGameState>)Delegate.Combine(obj.onEnter, (Action<EGameState>)delegate(EGameState state)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_0024: Unknown result type (might be due to invalid IL or missing references)
					//IL_0026: Invalid comparison between Unknown and I4
					if (NetworkBool.op_Implicit(Plugin.CustomConfig.AmogusMode) && ((SimulationBehaviour)gameState).Runner.IsServer && (int)state != 5)
					{
						PlayerRegistry.ForEach((Action<PlayerController>)delegate(PlayerController player)
						{
							//IL_000b: 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_002a: Unknown result type (might be due to invalid IL or missing references)
							//IL_0055: Unknown result type (might be due to invalid IL or missing references)
							//IL_003e: Unknown result type (might be due to invalid IL or missing references)
							//IL_0062: Unknown result type (might be due to invalid IL or missing references)
							//IL_0068: Invalid comparison between Unknown and I4
							//IL_0073: Unknown result type (might be due to invalid IL or missing references)
							//IL_0091: Unknown result type (might be due to invalid IL or missing references)
							if ((Object)(object)player != (Object)null && NetworkBool.op_Implicit(player.IsDead))
							{
								PlayerCustom player2 = PlayerCustomRegistry.GetPlayer(player.Ref);
								if (!NetworkBool.op_Implicit(player2.Disappeared))
								{
									player2.Disappeared = NetworkBool.op_Implicit(true);
								}
							}
							if ((Object)(object)player != (Object)null && !NetworkBool.op_Implicit(player.IsDead) && (int)player.Role == 1)
							{
								PlayerCustom player3 = PlayerCustomRegistry.GetPlayer(player.Ref);
								player3.AmogusModeKillCooldown = TickTimer.CreateFromSeconds(((SimulationBehaviour)gameState).Runner, 15f);
							}
						});
					}
				});
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("AmogusModeStateMachinePatch error: " + ex));
			}
		}
	}
	[NetworkBehaviourWeaved(20)]
	public class AmogusManager : NetworkBehaviour
	{
		public static AmogusManager Instance { get; private set; }

		[Networked]
		[NetworkedWeaved(0, 1)]
		public unsafe TickTimer NextLootTimer
		{
			get
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing AmogusManager.NextLootTimer. Networked properties can only be accessed when Spawned() has been called.");
				}
				return (TickTimer)(*base.Ptr);
			}
			set
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing AmogusManager.NextLootTimer. Networked properties can only be accessed when Spawned() has been called.");
				}
				Unsafe.Write(base.Ptr, value);
			}
		}

		public override void Spawned()
		{
			((NetworkBehaviour)this).Spawned();
			Instance = this;
		}

		public override void Despawned(NetworkRunner runner, bool hasState)
		{
			((NetworkBehaviour)this).Despawned(runner, hasState);
			Instance = null;
		}

		public override void FixedUpdateNetwork()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!NetworkBool.op_Implicit(Plugin.CustomConfig.AmogusMode) || !((SimulationBehaviour)this).Runner.IsServer || (int)GameManager.LocalGameState != 2)
				{
					return;
				}
				TickTimer nextLootTimer = NextLootTimer;
				if (((TickTimer)(ref nextLootTimer)).Expired(((SimulationBehaviour)this).Runner))
				{
					List<Loot> source = (from o in Object.FindObjectsOfType<Loot>()
						where o.GetMapID() == GameManager.Instance.MapID
						select o).ToList();
					for (int i = 0; i < 5; i++)
					{
						List<Loot> list = source.Where((Loot o) => !NetworkBool.op_Implicit(o.Available)).ToList();
						if (list.Any())
						{
							Loot val = CollectionsUtil.Grab<Loot>(list, 1).First();
							val.Available = NetworkBool.op_Implicit(true);
						}
					}
					NextLootTimer = TickTimer.None;
				}
				nextLootTimer = NextLootTimer;
				if (!((TickTimer)(ref nextLootTimer)).IsRunning)
				{
					int num = PlayerRegistry.CountWhere((Predicate<PlayerController>)((PlayerController o) => !NetworkBool.op_Implicit(o.IsDead)));
					float num2 = 60f / (float)num;
					NextLootTimer = TickTimer.CreateFromSeconds(((SimulationBehaviour)this).Runner, num2);
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("AmogusManager FixedUpdateNetwork error: " + ex));
			}
		}

		[Rpc]
		public unsafe static void Rpc_Report(NetworkRunner runner, int playerIndex, int targetPlayerIndex)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Invalid comparison between Unknown and I4
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (NetworkBehaviourUtils.InvokeRpc)
				{
					NetworkBehaviourUtils.InvokeRpc = false;
				}
				else
				{
					if ((Object)(object)runner == (Object)null)
					{
						throw new ArgumentNullException("runner");
					}
					if ((int)runner.Stage == 4)
					{
						return;
					}
					if (runner.HasAnyActiveConnections())
					{
						int num = 24;
						SimulationMessage* ptr = SimulationMessage.Allocate(runner.Simulation, num);
						byte* data = SimulationMessage.GetData(ptr);
						int num2 = RpcHeader.Write(RpcHeader.Create(NetworkBehaviourUtils.GetRpcStaticIndexOrThrow("System.Void LycansNewRoles.AmogusManager::Rpc_Report(Fusion.NetworkRunner,System.Int32,System.Int32)")), data);
						*(int*)(data + num2) = playerIndex;
						num2 += 4;
						*(int*)(data + num2) = targetPlayerIndex;
						num2 += 4;
						((SimulationMessage)ptr).Offset = num2 * 8;
						((SimulationMessage)ptr).SetStatic();
						runner.SendRpc(ptr);
					}
				}
				if (runner.IsServer)
				{
					GameManager.LightingManager.IsNight = NetworkBool.op_Implicit(true);
					PlayerRegistry.ForEach((Action<PlayerController>)delegate(PlayerController pObj)
					{
						//IL_0003: Unknown result type (might be due to invalid IL or missing references)
						pObj.CanMove = NetworkBool.op_Implicit(false);
					});
					GameManager.State.Server_DelaySetState((EGameState)3, 3f);
				}
				if (runner.IsPlayer)
				{
					AudioManager.Play("BELL", (MixerTarget)2, 1f, 1f);
					PlayerCustom player = PlayerCustomRegistry.GetPlayer(playerIndex);
					PlayerCustom player2 = PlayerCustomRegistry.GetPlayer(targetPlayerIndex);
					TextMeshProUGUI value = Traverse.Create((object)GameManager.Instance.gameUI).Field<TextMeshProUGUI>("transitionText").Value;
					LocalizeStringEvent value2 = Traverse.Create((object)GameManager.Instance.gameUI).Field<LocalizeStringEvent>("transition").Value;
					((Graphic)value).color = Color.white;
					value2.StringReference.Arguments = new List<object>
					{
						player.PlayerController.PlayerData.Username,
						player2.PlayerController.PlayerData.Username
					};
					((LocalizedReference)value2.StringReference).SetReference(TableReference.op_Implicit("UI Text"), TableEntryReference.op_Implicit("NALES_AMOGUS_MODE_REPORT_TEXT"));
					value2.RefreshString();
					GameManager.Instance.gameUI.StartFade(true);
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("Rpc_Report error: " + ex));
			}
		}

		[NetworkRpcStaticWeavedInvoker("System.Void LycansNewRoles.AmogusManager::Rpc_Report(Fusion.NetworkRunner,System.Int32,System.Int32)")]
		[Preserve]
		protected unsafe static void Rpc_Report_0040Invoker(NetworkRunner runner, SimulationMessage* message)
		{
			byte* data = SimulationMessage.GetData(message);
			int num = (RpcHeader.ReadSize(data) + 3) & -4;
			int playerIndex = *(int*)(data + num);
			num += 4;
			int targetPlayerIndex = *(int*)(data + num);
			num += 4;
			NetworkBehaviourUtils.InvokeRpc = true;
			Rpc_Report(runner, playerIndex, targetPlayerIndex);
		}
	}
	public static class BalancingValues
	{
		public const float EffectDurationStunned = 5f;

		public const float EffectDurationChasing = 2.5f;

		public const float EffectDurationSprinting = 5f;

		public const float EffectDurationReverting = 20f;

		public const float EffectDurationDisoriented = 3f;

		public const float EffectDurationInfected = 8f;

		public const float EffectDurationStealthing = 7f;

		public const float EffectDurationUndetected = 15f;

		public const float EffectDurationInnocent = 6f;

		public const float EffectDurationMurderer = 6f;

		public const float EffectDurationStarvationActive = 150f;

		public const float EffectDurationShouting = 7f;

		public const float EffectDurationBlind = 3.5f;

		public const float EffectDurationIllusion = 25f;

		public const float EffectDurationAntiMagic = 15f;

		public const float EffectDurationDisguised = 300f;

		public const float EffectDurationDiseased = 300f;

		public const float EffectDurationBomb = 20f;

		public const float EffectDurationPanic = 3f;

		public const float EffectDurationFleeing = 4f;

		public const float EffectDurationVillageIdiotWarning = 5f;

		public const float EffectDurationVillageIdiotHunger = 10f;

		public const float EffectDurationCannibalFull = 80f;

		public const float EffectDurationDowned = 10f;

		public const float EffectDurationWounded = 45f;

		public const float EffectDurationPoisoned = 45f;

		public const float EffectDurationPhasing = 3f;

		public const float EffectDurationDying = 45f;

		public const float EffectDurationAngel = 25f;

		public const float EffectDurationPoaching = 6f;

		public const float EffectDurationPotionDeaf = 75f;

		public const float EffectDurationPotionMidas = 50f;

		public const float EffectDurationPotionVampire = 45f;

		public const float EffectDurationPotionTiny = 35f;

		public const float EffectDurationPotionHaunted = 70f;

		public const float EffectDurationPotionNearsighted = 60f;

		public const float EffectDurationPotionAssassin = 10f;

		public const float EffectDurationPotionStinking = 60f;

		public const float EffectDurationPotionMute = 60f;

		public const float AgentEliminationRange = 2.5f;

		public const float CannibalEatDuration = 4f;

		public const float NecromancerResurrectDuration = 3f;

		public const int ShapeshifterIllusionCastTime = 1;

		public const float DeceiverScaryEffectDistance = 40f;

		public const float DeceiverIllusionDelayInitialMinSeconds = 2f;

		public const float DeceiverIllusionDelayInitialMaxSeconds = 10f;

		public const float DeceiverIllusionDelayBetweenMinSeconds = 15f;

		public const float DeceiverIllusionDelayBetweenMaxSeconds = 30f;

		public const float DeceiverIllusionDurationMinSeconds = 6f;

		public const float DeceiverIllusionDurationMaxSeconds = 15f;

		public const float VillageIdiotCheckInterval = 5f;

		public const float VillageIdiotMaximumPlayerDistance = 13f;

		public const float VillageIdiotMaximumWolfDistance = 40f;

		public const float VillageIdiotMinimumLastCheckDistance = 14f;

		public const float VillageIdiotNewTimerAfterLoot = 10f;

		public const int VillageIdiotFailedChecksForWarning = 4;

		public const int VillageIdiotFailedChecksForHunger = 6;

		public const float VillageIdiotAdditionalHungerWithEffect = 2.5f;

		public const float SpyMinimumDistanceForBestTarget = 50f;

		public const float SpySpyingRange = 10f;

		public const float SpyCooldownAfterSpyingSeconds = 30f;

		public const float ScientistAnalysisPowerAtMinDistance = 80f;

		public const float ScientistAnalysisPowerAtMaxDistance = 20f;

		public const float ScientistAnalysisMultiplierIfCursed = 0.2f;

		public const float ScientistAnalysisMultiplierForTransform = 10f;

		public const float ScientistAnalysisMultiplierForKill = 10f;

		public const float ScientistAnalysisMultiplierIfWolfVisible = 5f;

		public const float ScientistAnalysisMultiplierIfWolfVisibleButWounded = 0.4f;

		public const float ScientistAnalysisMultiplierIfScientistCrouched = 0.8f;

		public const float ScientistAnalysisRangePeriodic = 40f;

		public const float ScientistAnalysisRangeTransform = 40f;

		public const float ScientistAnalysisRangeKill = 30f;

		public const float BeastMarkRange = 2.5f;

		public const float BeastTransformationTime = 8f;

		public const float BeastKillRange = 3f;

		public const float BeastHealthLossPercentagePerSecond = 0.01f;

		public const float BeastTrapHealthLossPercentagePerSecond = 0.02f;

		public const float BeastHealthGainPercentagePerKill = 0.15f;

		public const float BeastMovementSpeed = 0.15f;

		public const float BeastNegativeEffectsDurationPercentage = 0.5f;

		public const float BeastHealthLossPercentageOnShot = 0.1f;

		public const float BeastHealthLossPercentageOnBomb = 0.25f;

		public const float BeastTrapDurationSeconds = 5f;

		public const int BeastDamageBonusOnDoors = 50;

		public const int BeastActiveFogEndDistance = 65;

		public static Color BeastActiveFogColor = new Color(1f, 0f, 0f, 1f);

		public const float BeastVoiceRange = 80f;

		public const float TrackerWolfSpeedMultiplier = 0.9f;

		public const float EnragedWolfSpeedMultiplier = 1.2f;

		public const float EnragedWolfTransformDelayMultiplier = 0.7f;

		public const float EnragedWolfHungerMultiplier = 1.5f;

		public const float WarlockWolfCurseRange = 10f;

		public const float WarlockWolfCurseDormantMinimumDelay = 1f;

		public const float WarlockWolfCurseDormantMaximumDelay = 20f;

		public const float WarlockWolfCurseDormantMinimumDuration = 25f;

		public const float WarlockWolfCurseDormantMaximumDuration = 50f;

		public const float SaboteurTrapHeldItemRange = 2.5f;

		public const float SaboteurPoisonHealthDecrease = 1f;

		public const int SaboteurPoisonFogEndDistance = 25;

		public static Color SaboteurPoisonFogColor = new Color(0f, 0.5f, 0f, 1f);

		public const float SaboteurTrappedGadgetHealthLossPercentage = 0.2f;

		public const float SaboteurWoundedMoveSpeedMultiplier = 0.65f;

		public const float SaboteurItemLightIntensityNotHeld = 3f;

		public const float SaboteurItemLightIntensityHeld = 0.5f;

		public const float SaboteurItemLightRangeNotHeld = 2f;

		public const float SaboteurItemLightRangeHeld = 0.15f;

		public const float TraitorSabotageDelayMultiplier = 1.35f;

		public const float BomberCreateBombRange = 2.5f;

		public const float BomberGiveBombRange = 2.5f;

		public const float BomberBombStartMinimumDelay = 10f;

		public const float BomberBombStartMaximumDelay = 20f;

		public const float BomberBombTickingSoundRange = 20f;

		public const float BomberBombExplosionSoundRange = 40f;

		public const float PoacherMarkSoundRange = 30f;

		public const float PoachingMovementSpeed = 1.8f;

		public const float AlcoholicPotionHealWolf = 0.45f;

		public const float AlcoholicPotionHealBeast = 0.15f;

		public const float SprinterSprintingMoveSpeedMultiplier = 1.75f;

		public const float SprinterChasingMoveSpeedMultiplier = 1.5f;

		public const float DetectiveInspectRange = 2.5f;

		public const float EngineerTrappedDuration = 4f;

		public const float EngineerTrapDisarmTime = 1f;

		public const int EngineerDoorBashBonusDamageWolf = 40;

		public const int EngineerDoorBashBonusDamageNonWolf = 20;

		public const int EngineerSmokeRadius = 250;

		public const int InfectedWolfRadius = 30;

		public const float GamblerSwitchRange = 5f;

		public const float HowlerShoutingVoiceRange = 80f;

		public const float HowlerShoutingDisorientedRange = 25f;

		public const float MetabolicWolfStarvationRange = 10f;

		public const float MetabolicVillagerFeedMultiplier = 1.75f;

		public const float MetabolicStarvationAdditionalHunger = 1f;

		public const float PoliticianDenyVoteRange = 10f;

		public const float AstralDefaultRange = 10f;

		public const float AstralKillRange = 4f;

		public const float AstralSabotageRange = 7f;

		public const float AstralPowerHeight = 10f;

		public const float AstralPowerAdditionalHunger = 0.8f;

		public const float SherifKillRange = 2.5f;

		public const float SherifWolfHealthAfterBeingShot = 0.4f;

		public const float SprinterSprintingAdditionalHunger = 4f;

		public const float RangerWolfFootstepsDuration = 90f;

		public const float RangerVillagerFootstepsDuration = 25f;

		public const float RangerSearchRadius = 30f;

		public const float ScavengerHumanFormHealPercentage = 0.15f;

		public const float ScavengerWolfFormHealPercentage = 0.5f;

		public const float PeasantRadiusForItem = 30f;

		public const float PeasantChanceForItem = 1f;

		public const float GuardTakeRifleDuration = 3f;

		public const float ExorcistMarkRange = 7f;

		public const float ExorcistMarkHungerMultiplier = 1.35f;

		public const int ExorcistFogEndDistance = 25;

		public static Color ExorcistFogColor = new Color(0.5f, 0.5f, 0f, 1f);

		public const float ExorcistBlindDuration = 3f;

		public const float ForensicsAnalyzeDuration = 3f;

		public const float AvengerAttackRange = 2.5f;

		public const float AvengerAttackDownedDuration = 8f;

		public const float SurvivalistSaveCastTime = 4f;

		public const float SurvivalistHungerPercentageWhenDowned = 0.295f;

		public const float SurvivalistAlertRange = 40f;

		public const float PriestProtectRange = 2.5f;

		public const float PriestProtectionDownedDuration = 7f;

		public const float AngelHealPercentage = 0.5f;

		public const float VillageIdiotHungerMultiplier = 0.7f;

		public const float MidasEffectValueMultiplier = 4f;

		public const float VampireEffectCurrentPercentage = 0.03f;

		public const float TinyMovementSpeed = 0.6f;

		public const float HauntedMinimumDelayServer = 3f;

		public const float HauntedMaximumDelayServer = 6f;

		public const float HauntedHealthGainPercentage = 0.3f;

		public const float HauntedHealthLossPercentage = 0.2f;

		public const float HauntedDoorRadius = 40f;

		public const float HauntedLanternFlickerRadius = 30f;

		public const float HauntedLanternFlickerDuration = 10f;

		public static Dictionary<HauntedEffect.HauntedPossibleEffect, int> HauntedChanceByEffect = new Dictionary<HauntedEffect.HauntedPossibleEffect, int>
		{
			{
				HauntedEffect.HauntedPossibleEffect.HealthGain,
				2
			},
			{
				HauntedEffect.HauntedPossibleEffect.HealthLoss,
				2
			},
			{
				HauntedEffect.HauntedPossibleEffect.OpenDoors,
				3
			},
			{
				HauntedEffect.HauntedPossibleEffect.CloseDoors,
				3
			},
			{
				HauntedEffect.HauntedPossibleEffect.Teleport,
				2
			},
			{
				HauntedEffect.HauntedPossibleEffect.GainItem,
				2
			},
			{
				HauntedEffect.HauntedPossibleEffect.RandomNegativeEffect,
				3
			},
			{
				HauntedEffect.HauntedPossibleEffect.Sound,
				2
			},
			{
				HauntedEffect.HauntedPossibleEffect.FlickerLanterns,
				2
			}
		};

		public const int NearsightedFogEndDistance = 12;

		public static Color NearsightedFogColor = new Color(0f, 0f, 0.1f, 1f);

		public const float AssassinRange = 2.5f;

		public const float DisorientedMovementSpeed = 0.5f;

		public const float StunnedMovementSpeed = 0.5f;

		public const float StinkingEffectRadiusOnNonWolf = 4f;

		public const float StinkingEffectRadiusOnWolf = 10f;

		public const float NauseatedMovementSpeed = 0.8f;

		public const int NauseatedFogEndDistance = 30;

		public static Color NauseatedFogColor = new Color(0f, 0.5f, 0f, 1f);

		public const float SacrificeWolfHungerMultiplier = 0.75f;

		public const float SacrificeMovementSpeed = 1.15f;

		public const float SacrificeTransformDelayMultiplier = 0.6f;

		public const float PhasingMovementSpeedHumanForm = 1.5f;

		public const float PhasingMovementSpeedWolfForm = 1.25f;

		public const float BombMovementSpeed = 1.15f;

		public const float FleeingMovementSpeed = 1.5f;

		public const float PanicMovementSpeed = 0.65f;

		public const float LoverVillagerHungerRateBase = 0.125f;

		public const float LoverVillagerHungerRatePerLivingPlayer = 0.0125f;

		public const float LoverVillagerHealPercentageOnWolfKill = 0.45f;

		public const float SabotageObjectRaycastRange = 7f;

		public const float DiseaseEffectHealthDecrease = 0.3f;

		public const float DiseaseMoveSpeedMultiplier = 0.85f;

		public const float EmpoweredWolfHungerMultiplier = 0.75f;

		public const float EmpoweredMovementSpeed = 1.1f;

		public const float PortalSabotageStayActiveTime = 120f;

		public const float PortalSabotageReactivateTime = 5f;

		public const float CursedNightFogEndDistanceMultiplier = 0.65f;

		public const float CursedNightDefaultCurseCooldown = 100f;

		public const float PlayerRaycastRange = 10f;

		public const float PlayerRaycastRangeWhenInvisible = 2.5f;

		public const float TrapSetupTime = 1f;

		public const float TrapDisarmTime = 2.5f;

		public const float TrapDisarmTimeInWolfForm = 5f;

		public const float MaxSpeedBase = 1.5f;

		public const float AmogusModeKillRange = 5f;

		public const float AmogusModeKillCooldown = 30f;

		public const float AmogusModeReportRange = 10f;

		public const int AmogusBaseLootsSpawn = 5;

		public const int AmogusBaseIntervalBetweenLoots = 60;

		public static Dictionary<int, float> FogEndDistanceDaytimeByFogConfigPercentage = new Dictionary<int, float>
		{
			{ 0, 300f },
			{ 10, 300f },
			{ 20, 300f },
			{ 30, 300f },
			{ 40, 300f },
			{ 50, 300f },
			{ 60, 300f },
			{ 70, 300f },
			{ 80, 300f },
			{ 90, 300f },
			{ 100, 300f }
		};

		public static Dictionary<int, float> FogEndDistanceNightByFogConfigPercentage = new Dictionary<int, float>
		{
			{ 0, 300f },
			{ 10, 150f },
			{ 20, 125f },
			{ 30, 100f },
			{ 40, 80f },
			{ 50, 65f },
			{ 60, 55f },
			{ 70, 45f },
			{ 80, 35f },
			{ 90, 26f },
			{ 100, 18f }
		};

		public const int FogBonusEndDistanceForWolfForm = 25;

		public static int BeastMarkCooldown => Mathf.RoundToInt(50f - (float)PlayerRegistry.Count * 2f);

		public static int GetVillagerJobChancePonderation(PlayerCustom.PlayerPrimaryRolePower power)
		{
			return power switch
			{
				PlayerCustom.PlayerPrimaryRolePower.Peasant => 3, 
				PlayerCustom.PlayerPrimaryRolePower.Repairer => 2, 
				PlayerCustom.PlayerPrimaryRolePower.Guard => 2, 
				PlayerCustom.PlayerPrimaryRolePower.Exorcist => 3, 
				PlayerCustom.PlayerPrimaryRolePower.Forensics => 2, 
				PlayerCustom.PlayerPrimaryRolePower.Avenger => 2, 
				PlayerCustom.PlayerPrimaryRolePower.Barkeep => 3, 
				PlayerCustom.PlayerPrimaryRolePower.Survivalist => 3, 
				PlayerCustom.PlayerPrimaryRolePower.Priest => 3, 
				PlayerCustom.PlayerPrimaryRolePower.Angel => 3, 
				_ => 0, 
			};
		}

		public static int AvengerMaxSurvivorsToKill(int totalPlayers)
		{
			switch (totalPlayers)
			{
			case 1:
			case 2:
			case 3:
			case 4:
			case 5:
			case 6:
			case 7:
			case 8:
				return 3;
			case 9:
			case 10:
			case 11:
				return 4;
			case 12:
			case 13:
			case 14:
				return 5;
			case 15:
				return 6;
			default:
				return 4;
			}
		}

		public static int? GetCastTimeForSecondaryRole(PlayerCustom.PlayerSecondaryRole role)
		{
			return role switch
			{
				PlayerCustom.PlayerSecondaryRole.BothTeleporter => 3, 
				PlayerCustom.PlayerSecondaryRole.BothRanger => 3, 
				PlayerCustom.PlayerSecondaryRole.BothScavenger => 3, 
				_ => null, 
			};
		}

		public static int? GetCooldownForPrimaryRolePower(PlayerCustom.PlayerPrimaryRolePower role, int totalCycleTime)
		{
			if (role == PlayerCustom.PlayerPrimaryRolePower.Saboteur)
			{
				return 30;
			}
			return null;
		}

		public static PowerMaterialsInfo? GetRequiredMaterialsForPrimaryRolePower(PlayerCustom.PlayerPrimaryRolePower power)
		{
			return power switch
			{
				PlayerCustom.PlayerPrimaryRolePower.Bomber => new PowerMaterialsInfo(125, 0.256f, 0f), 
				PlayerCustom.PlayerPrimaryRolePower.Exorcist => new PowerMaterialsInfo(75, 0.756f, 0f), 
				PlayerCustom.PlayerPrimaryRolePower.Priest => new PowerMaterialsInfo(125, 0.756f, 1f), 
				_ => null, 
			};
		}

		public static int? GetCooldownForSecondaryRole(PlayerCustom.PlayerSecondaryRole role, int totalCycleTime)
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			return role switch
			{
				PlayerCustom.PlayerSecondaryRole.BothAlcoholic => 60, 
				PlayerCustom.PlayerSecondaryRole.BothDetective => 8 * totalCycleTime, 
				PlayerCustom.PlayerSecondaryRole.BothEngineer => NetworkBool.op_Implicit(Plugin.CustomConfig.DropItemsAvailable) ? 90 : 60, 
				PlayerCustom.PlayerSecondaryRole.BothGambler => 120, 
				PlayerCustom.PlayerSecondaryRole.BothHowler => 120, 
				PlayerCustom.PlayerSecondaryRole.BothIllusionist => 120, 
				PlayerCustom.PlayerSecondaryRole.BothInfected => 120, 
				PlayerCustom.PlayerSecondaryRole.BothMetabolic => 8 * totalCycleTime, 
				PlayerCustom.PlayerSecondaryRole.BothAstral => 15, 
				PlayerCustom.PlayerSecondaryRole.BothSprinter => 90, 
				PlayerCustom.PlayerSecondaryRole.BothStealther => 120, 
				PlayerCustom.PlayerSecondaryRole.BothTeleporter => 90, 
				PlayerCustom.PlayerSecondaryRole.BothScavenger => 30, 
				_ => null, 
			};
		}

		public static int CannibalTargetAmount(int totalPlayers)
		{
			if (totalPlayers <= 3)
			{
				return 1;
			}
			if (totalPlayers <= 6)
			{
				return 2;
			}
			if (totalPlayers <= 10)
			{
				return 3;
			}
			if (totalPlayers <= 15)
			{
				return 4;
			}
			return 5;
		}

		public static int AgentMaxSurvivorsToWin(int totalPlayers)
		{
			switch (totalPlayers)
			{
			case 1:
			case 2:
			case 3:
			case 4:
			case 5:
			case 6:
			case 7:
				return 2;
			case 8:
			case 9:
			case 10:
			case 11:
			case 12:
				return 3;
			case 13:
			case 14:
			case 15:
				return 4;
			default:
				return 4;
			}
		}

		public static int SpyTargetAmount(int totalPlayers)
		{
			switch (totalPlayers)
			{
			case 1:
			case 2:
			case 3:
			case 4:
			case 5:
			case 6:
				return 5;
			case 7:
			case 8:
			case 9:
				return 6;
			case 10:
			case 11:
				return 7;
			case 12:
			case 13:
				return 8;
			case 14:
			case 15:
				return 9;
			default:
				return 9;
			}
		}

		public static int BeastTargetAmount(int survivingPlayers)
		{
			return Mathf.CeilToInt((float)survivingPlayers * 0.6f);
		}

		public static int ScientistGoal(int totalPlayers)
		{
			return PlayerRegistry.Count * 650;
		}

		public static float WolfScareEffectRadiusMultiplierByMap(int mapId)
		{
			return mapId switch
			{
				1 => 1f, 
				2 => 0.65f, 
				_ => 1f, 
			};
		}

		public static float NightFogEndDistanceMultiplierByMap(int mapId)
		{
			return mapId switch
			{
				1 => 1f, 
				2 => 0.7f, 
				_ => 1f, 
			};
		}

		public static float VampireEffectRadiusByMap(int mapId)
		{
			return mapId switch
			{
				1 => 30f, 
				2 => 15f, 
				_ => 30f, 
			};
		}

		public static float BeastHeartbeatMaximumRange(int mapId)
		{
			return mapId switch
			{
				1 => 30f, 
				2 => 20f, 
				_ => 30f, 
			};
		}
	}
	public class PowerMaterialsInfo
	{
		public int RequiredMaterials;

		public float StartingMaterialsPercentage;

		public float BonusMultiplierAtFullHealth;

		public PowerMaterialsInfo(int requiredMaterials, float startingMaterialsPercentage, float bonusMultiplierAtFullHealth)
		{
			RequiredMaterials = requiredMaterials;
			StartingMaterialsPercentage = startingMaterialsPercentage;
			BonusMultiplierAtFullHealth = bonusMultiplierAtFullHealth;
		}
	}
	[NetworkBehaviourWeaved(20)]
	public class BeastManager : NetworkBehaviour
	{
		private float DelayToNextHeartbeat;

		private const float DelaySoundSlow = 2.1f;

		private const float DelaySoundMid = 1.42f;

		private const float DelaySoundFast = 0.9f;

		[Networked(OnChanged = "BeastActiveChanged")]
		[NetworkedWeaved(0, 1)]
		public unsafe NetworkBool BeastActive
		{
			get
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing PlayerCustom.BeastActive. Networked properties can only be accessed when Spawned() has been called.");
				}
				return (NetworkBool)(*base.Ptr);
			}
			set
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing PlayerCustom.BeastActive. Networked properties can only be accessed when Spawned() has been called.");
				}
				Unsafe.Write(base.Ptr, value);
			}
		}

		[Networked(OnChanged = "BeastKillsChanged")]
		[NetworkedWeaved(1, 1)]
		public unsafe int BeastKills
		{
			get
			{
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing PlayerCustom.BeastKills. Networked properties can only be accessed when Spawned() has been called.");
				}
				return base.Ptr[1];
			}
			set
			{
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing PlayerCustom.BeastKills. Networked properties can only be accessed when Spawned() has been called.");
				}
				base.Ptr[1] = value;
			}
		}

		[Networked]
		[NetworkedWeaved(2, 1)]
		public unsafe int BeastKillsObjective
		{
			get
			{
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing PlayerCustom.BeastKillsObjective. Networked properties can only be accessed when Spawned() has been called.");
				}
				return base.Ptr[2];
			}
			set
			{
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing PlayerCustom.BeastKillsObjective. Networked properties can only be accessed when Spawned() has been called.");
				}
				base.Ptr[2] = value;
			}
		}

		public static BeastManager Instance { get; private set; }

		public void Reset()
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			BeastActive = NetworkBool.op_Implicit(false);
			BeastKills = 0;
			BeastKillsObjective = 0;
		}

		public override void Spawned()
		{
			((NetworkBehaviour)this).Spawned();
			Instance = this;
		}

		public override void Despawned(NetworkRunner runner, bool hasState)
		{
			((NetworkBehaviour)this).Despawned(runner, hasState);
			Instance = null;
		}

		private void Update()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkBool.op_Implicit(BeastActive))
			{
				return;
			}
			if (DelayToNextHeartbeat <= 0f)
			{
				float num = BalancingValues.BeastHeartbeatMaximumRange(GameManager.Instance.MapID);
				float num2 = num * 0.7f;
				float num3 = num * 0.4f;
				PlayerCustom povPlayerCustom = PlayerCustomRegistry.GetPlayer(PlayerController.Local.LocalCameraHandler.PovPlayer.Ref);
				if (povPlayerCustom.NewPrimaryRole == PlayerCustom.PlayerNewPrimaryRole.Beast)
				{
					List<PlayerController> list = PlayerRegistry.Where((Predicate<PlayerController>)((PlayerController o) => o.Ref != povPlayerCustom.Ref && !NetworkBool.op_Implicit(o.IsDead))).ToList();
					PlayerController val = null;
					float? num4 = null;
					foreach (PlayerController item in list)
					{
						float num5 = Vector3.Distance(((Component)povPlayerCustom.PlayerController).transform.position, ((Component)item).transform.position);
						if (!num4.HasValue || num5 < num4.Value)
						{
							val = item;
							num4 = num5;
						}
					}
					if ((Object)(object)val != (Object)null && num4.Value <= num)
					{
						string text;
						float delayToNextHeartbeat;
						if (num4.Value > num2)
						{
							text = "BeastHeartBeatSlow";
							delayToNextHeartbeat = 2f;
						}
						else if (num4.Value > num3)
						{
							text = "BeastHeartBeatMid";
							delayToNextHeartbeat = 1.337f;
						}
						else
						{
							text = "BeastHeartBeatFast";
							delayToNextHeartbeat = 0.841f;
						}
						AudioManager.PlayAndFollow(text, ((Component)val).transform, (MixerTarget)2, num, 0.8f);
						DelayToNextHeartbeat = delayToNextHeartbeat;
					}
					else
					{
						DelayToNextHeartbeat = 0.5f;
					}
					return;
				}
				PlayerCustom specificNewPrimaryRole = PlayerCustomRegistry.GetSpecificNewPrimaryRole(PlayerCustom.PlayerNewPrimaryRole.Beast);
				float num6 = Vector3.Distance(((Component)povPlayerCustom.PlayerController).transform.position, ((Component)specificNewPrimaryRole.PlayerController).transform.position);
				if (num6 <= num)
				{
					string text2;
					float delayToNextHeartbeat2;
					if (num6 > num2)
					{
						text2 = "BeastHeartBeatSlow";
						delayToNextHeartbeat2 = 2f;
					}
					else if (num6 > num3)
					{
						text2 = "BeastHeartBeatMid";
						delayToNextHeartbeat2 = 1.337f;
					}
					else
					{
						text2 = "BeastHeartBeatFast";
						delayToNextHeartbeat2 = 0.841f;
					}
					AudioManager.Play(text2, (MixerTarget)2, 0.5f, 1f);
					DelayToNextHeartbeat = delayToNextHeartbeat2;
				}
				else
				{
					DelayToNextHeartbeat = 0.5f;
				}
			}
			else
			{
				DelayToNextHeartbeat -= Time.deltaTime;
			}
		}

		public void ActivateBeast()
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			BeastActive = NetworkBool.op_Implicit(true);
		}

		[Preserve]
		public static void BeastActiveChanged(Changed<BeastManager> changed)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				BeastManager behaviour = changed.Behaviour;
				if (NetworkBool.op_Implicit(behaviour.BeastActive))
				{
					int num = BalancingValues.BeastTargetAmount(PlayerRegistry.CountWhere((Predicate<PlayerController>)((PlayerController o) => !NetworkBool.op_Implicit(o.IsDead))) - 1);
					PlayerCustom specificNewPrimaryRole = PlayerCustomRegistry.GetSpecificNewPrimaryRole(PlayerCustom.PlayerNewPrimaryRole.Beast);
					if (((SimulationBehaviour)behaviour).Runner.IsServer)
					{
						behaviour.BeastKillsObjective = num;
						specificNewPrimaryRole.PlayerController.Hunger = GameManager.Instance.MaxHunger;
						Traverse.Create((object)specificNewPrimaryRole.PlayerController).Property("WolfDelay", (object[])null).SetValue((object)TickTimer.CreateFromSeconds(((SimulationBehaviour)behaviour).Runner, 8f));
						specificNewPrimaryRole.PlayerController.TransformedNight = NetworkBool.op_Implicit(true);
						specificNewPrimaryRole.PlayerController.IsWolf = NetworkBool.op_Implicit(true);
						specificNewPrimaryRole.PlayerController.MovementAction = 0;
						specificNewPrimaryRole.PlayerController.CanMoveAnimation = NetworkBool.op_Implicit(false);
						specificNewPrimaryRole.PlayerController.IsZooming = NetworkBool.op_Implicit(false);
						GameManager.Rpc_BroadcastFollowSound(((SimulationBehaviour)behaviour).Runner, NetworkString<_16>.op_Implicit("BeastAwakening"), ((Component)specificNewPrimaryRole.PlayerController).transform.position, 50f, 0.8f);
					}
					Traverse.Create((object)specificNewPrimaryRole.PlayerController).Field<ParticleSystem>("smokeParticleSystem").Value.Play();
					PlayerCustom player = PlayerCustomRegistry.GetPlayer(PlayerController.Local.LocalCameraHandler.PovPlayer.Ref);
					if (player.NewPrimaryRole == PlayerCustom.PlayerNewPrimaryRole.Beast)
					{
						UIManager.ShowRedCenterMessage("NALES_UI_BEAST_UNLEASHED_BEAST", 0.5f, 5f, new List<object> { num });
					}
					else
					{
						UIManager.ShowRedCenterMessage("NALES_UI_BEAST_UNLEASHED_OTHERS", 0.5f, 4f);
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("ColorIndexChanged error: " + ex));
			}
		}

		[Preserve]
		public static void BeastKillsChanged(Changed<BeastManager> changed)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				BeastManager behaviour = changed.Behaviour;
				if (NetworkBool.op_Implicit(behaviour.BeastActive) && ((SimulationBehaviour)behaviour).Runner.IsServer && behaviour.BeastKills >= behaviour.BeastKillsObjective)
				{
					PlayerCustom.Rpc_End_Game(((SimulationBehaviour)behaviour).Runner, PlayerCustomRegistry.GetSpecificNewPrimaryRole(PlayerCustom.PlayerNewPrimaryRole.Beast).Index);
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("ColorIndexChanged error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(GameState), "Spawned")]
	internal class GameStateActivateBeastPatch
	{
		private static void Postfix(GameState __instance)
		{
			try
			{
				StateMachine<EGameState> value = Traverse.Create((object)__instance).Field<StateMachine<EGameState>>("StateMachine").Value;
				GameState gameState = __instance;
				StateHooks<EGameState> obj = value[(EGameState)3];
				obj.onExit = (Action<EGameState>)Delegate.Combine(obj.onExit, (Action<EGameState>)delegate
				{
					//IL_0018: Unknown result type (might be due to invalid IL or missing references)
					//IL_0057: Unknown result type (might be due to invalid IL or missing references)
					if (((SimulationBehaviour)gameState).Runner.IsServer && NetworkBool.op_Implicit(GameManager.LightingManager.IsNight))
					{
						PlayerCustom beastCustom = PlayerCustomRegistry.GetSpecificNewPrimaryRole(PlayerCustom.PlayerNewPrimaryRole.Beast);
						if (Object.op_Implicit((Object)(object)beastCustom) && !NetworkBool.op_Implicit(beastCustom.PlayerController.IsDead) && PlayerCustomRegistry.AllPlayers.All((PlayerCustom o) => o.Ref == beastCustom.Ref || NetworkBool.op_Implicit(o.PlayerController.IsDead) || NetworkBool.op_Implicit(o.BeastMark)))
						{
							BeastManager.Instance.ActivateBeast();
						}
					}
				});
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("GameStateActivateBeastPatch: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(LightingManager), "FixedUpdateNetwork")]
	internal class BeastNoCyclePatch
	{
		private static bool Prefix(LightingManager __instance)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (NetworkBool.op_Implicit(BeastManager.Instance.BeastActive))
				{
					return false;
				}
				return true;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("BeastNoCyclePatch error: " + ex));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(Effect), "Init")]
	internal class BeastReducedNegativeEffectsDurationPatch
	{
		private static bool Prefix(PlayerRef targetPlayer, Effect __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PlayerCustom player = PlayerCustomRegistry.GetPlayer(targetPlayer);
				if ((int)__instance.GetEffectType() == 2 && NetworkBool.op_Implicit(BeastManager.Instance.BeastActive) && NetworkBool.op_Implicit(player.PlayerController.IsWolf))
				{
					player.PlayerController.PlayerEffectManager.ApplyEffect(__instance);
					Traverse.Create((object)__instance).Field<PlayerRef>("_EffectPlayer").Value = targetPlayer;
					if (((SimulationBehaviour)__instance).HasStateAuthority)
					{
						float num = Traverse.Create((object)__instance).Field<float>("duration").Value * 0.5f;
						Traverse.Create((object)__instance).Field<CustomTickTimer>("_EffectTimer").Value = CustomTickTimer.CreateFromTicks(((SimulationBehaviour)__instance).Runner, (int)(num * (float)((SimulationBehaviour)__instance).Runner.Config.Simulation.TickRate));
					}
					((NetworkBehaviour)__instance).CopyBackingFieldsToState(true);
					Traverse.Create((object)__instance).Method("ApplyEffectToPlayerSpecific", new List<Type> { typeof(PlayerRef) }.ToArray(), (object[])null).GetValue(new object[1] { targetPlayer });
					return false;
				}
				return true;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("BeastReducedNegativeEffectsDurationPatch error: " + ex));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerController), "Rpc_Damage")]
	internal class BeastReducedDamagePatch
	{
		private static bool Prefix(PlayerRef attacker, PlayerController __instance)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Invalid comparison between Unknown and I4
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Expected O, but got Unknown
			try
			{
				if (!((NetworkBehaviour)__instance).InvokeRpc && (int)((SimulationBehaviour)__instance).Runner.Stage == 4)
				{
					return false;
				}
				if (((SimulationBehaviour)__instance).Object.HasStateAuthority && !NetworkBool.op_Implicit(__instance.IsDead))
				{
					PlayerCustom playerCustom = PlayerCustomRegistry.GetPlayer(__instance.Ref);
					if (playerCustom.NewPrimaryRole == PlayerCustom.PlayerNewPrimaryRole.Beast && NetworkBool.op_Implicit(BeastManager.Instance.BeastActive))
					{
						PlayerController playerController = playerCustom.PlayerController;
						playerController.Hunger -= 0.1f * (float)GameManager.Instance.MaxHunger;
						NetworkPrefabId networkObject = NetworkObjectService.Instance.GetNetworkObject(GlobalManager.WoundedEffectName);
						((SimulationBehaviour)playerCustom).Runner.Spawn(networkObject, (Vector3?)Vector3.zero, (Quaternion?)Quaternion.identity, (PlayerRef?)null, (OnBeforeSpawned)delegate(NetworkRunner _, NetworkObject no)
						{
							//IL_000d: Unknown result type (might be due to invalid IL or missing references)
							((Component)no).GetComponent<Effect>().Init(playerCustom.Ref);
						}, (NetworkObjectPredictionKey?)null, true, (NetworkObject)null);
						return false;
					}
				}
				return true;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("BeastReducedDamagePatch error: " + ex));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(NetworkRunnerHandler), "StartSession")]
	internal class StartSessionPatch
	{
		private static void Prefix(ref int playerCount)
		{
			try
			{
				playerCount = 15;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("CreateGamePatch error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(PlayerRegistry), "GetAvailable")]
	internal class PlayerRegistryPatch
	{
		private static bool Prefix(PlayerRegistry __instance, ref bool __result, out byte index)
		{
			//IL_0013: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				NetworkDictionary<PlayerRef, PlayerController> value = Traverse.Create((object)__instance).Property<NetworkDictionary<PlayerRef, PlayerController>>("ObjectByRef", (object[])null).Value;
				if (value.Count == 0)
				{
					index = 0;
					__result = true;
					return false;
				}
				if (value.Count == 15)
				{
					index = 0;
					__result = false;
					return false;
				}
				byte[] array = ((IEnumerable<KeyValuePair<PlayerRef, PlayerController>>)(object)value).OrderBy(delegate(KeyValuePair<PlayerRef, PlayerController> kvp)
				{
					KeyValuePair<PlayerRef, PlayerController> keyValuePair2 = kvp;
					return keyValuePair2.Value.Index;
				}).Select(delegate(KeyValuePair<PlayerRef, PlayerController> kvp)
				{
					KeyValuePair<PlayerRef, PlayerController> keyValuePair = kvp;
					return keyValuePair.Value.Index;
				}).ToArray();
				for (int i = 0; i < array.Length - 1; i++)
				{
					if (array[i + 1] > array[i] + 1)
					{
						index = (byte)(array[i] + 1);
						__result = true;
						return false;
					}
				}
				index = (byte)(array[^1] + 1);
				__result = true;
				return false;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("PlayerRegistryPatch error: " + ex));
				index = 0;
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(GameUI), "UpdatePlayerCount")]
	internal class UpdatePlayerCountPatch
	{
		private static bool Prefix(int count, GameUI __instance)
		{
			try
			{
				((TMP_Text)Traverse.Create((object)__instance).Field<TextMeshProUGUI>("playerCount").Value).text = count + "/15";
				return false;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("UpdatePlayerCountPatch error: " + ex));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(ColorManager), "Awake")]
	internal class ColorManagerPatch
	{
		private static void Postfix(ColorManager __instance)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				List<Texture> list = Traverse.Create((object)__instance).Field<Texture[]>("villagerTextures").Value.ToList();
				List<Color> list2 = Traverse.Create((object)__instance).Field<Color[]>("colors").Value.ToList();
				list.Add(list[0]);
				list.Add(list[1]);
				list.Add(list[2]);
				list2.Add(list2[0]);
				list2.Add(list2[1]);
				list2.Add(list2[2]);
				Traverse.Create((object)__instance).Field("villagerTextures").SetValue((object)list.ToArray());
				Traverse.Create((object)__instance).Field("colors").SetValue((object)list2.ToArray());
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("ColorManagerPatch error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(GameManager), "GetSpawnPosition")]
	internal class SpawnPositionPatch
	{
		private static bool Prefix(PlayerController playerController, GameManager __instance, ref Vector3 __result)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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)
			try
			{
				float num = 24f;
				float num2 = (float)(int)playerController.Index * num;
				Vector3 val = Quaternion.Euler(0f, num2, 0f) * Vector3.forward * Traverse.Create((object)__instance).Field<float>("radius").Value;
				__result = Traverse.Create((object)__instance).Field<Transform[]>("mapSpawns").Value[__instance.MapID - 1].position + val;
				return false;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("SpawnPositionPatch error: " + ex));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(LocalCameraHandler), "UpdateAnchorOffset")]
	internal class TinyEffectLocalCameraHandlerPatch
	{
		private static void Postfix(LocalCameraHandler __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((int)GameManager.LocalGameState == 0 || !((Object)(object)__instance.PovPlayer != (Object)null) || NetworkBool.op_Implicit(__instance.PovPlayer.IsDead))
				{
					return;
				}
				PlayerCustom player = PlayerCustomRegistry.GetPlayer(__instance.PovPlayer.Ref);
				Traverse<bool> val = Traverse.Create((object)__instance).Field<bool>("_giant");
				if (val.Value != NetworkBool.op_Implicit(player.Tiny) || (player.SecondaryRole == PlayerCustom.PlayerSecondaryRole.BothAstral && val.Value != NetworkBool.op_Implicit(player.SecondaryRolePowerActive)))
				{
					Transform value = Traverse.Create((object)__instance).Field<Transform>("localCameraAnchorPoint").Value;
					int value2 = Traverse.Create((object)__instance).Field<int>("_movementStatus").Value;
					Traverse<bool> val2 = Traverse.Create((object)__instance).Field<bool>("_isWolf");
					float value3 = Traverse.Create((object)__instance).Field<float>("_baseCameraOffset").Value;
					int movementAction = __instance.PovPlayer.MovementAction;
					bool flag = NetworkBool.op_Implicit(__instance.PovPlayer.IsWolf);
					bool flag2 = NetworkBool.op_Implicit(__instance.PovPlayer.PlayerEffectManager.Giant);
					bool flag3 = NetworkBool.op_Implicit(player.Tiny);
					bool flag4 = player.SecondaryRole == PlayerCustom.PlayerSecondaryRole.BothAstral && NetworkBool.op_Implicit(player.SecondaryRolePowerActive);
					float num = ((movementAction == 1) ? (value3 - 0.5f) : value3);
					if (flag)
					{
						num += 0.25f;
					}
					else if (flag2)
					{
						num = ((movementAction == 1) ? 7.2f : 10.2f);
					}
					else if (flag3)
					{
						num = ((movementAction == 1) ? 0.09f : 0.12f);
					}
					else if (flag4)
					{
						num = 10f;
					}
					Vector3 localPosition = value.localPosition;
					((Vector3)(ref localPosition))..ctor(localPosition.x, num, localPosition.z);
					value.localPosition = localPosition;
					value2 = movementAction;
					val2.Value = flag;
					val.Value = flag2 || flag3 || flag4;
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("TinyEffectLocalCameraHandlerPatch error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(PlayerController), "UpdateCameraAnchorOffset")]
	internal class CameraAnchorPatch
	{
		private static void Postfix(PlayerController __instance)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PlayerCustom player = PlayerCustomRegistry.GetPlayer(__instance.Ref);
				if (player.SecondaryRole == PlayerCustom.PlayerSecondaryRole.BothAstral && NetworkBool.op_Implicit(player.SecondaryRolePowerActive))
				{
					float num = 10f;
					Transform value = Traverse.Create((object)__instance).Field<Transform>("cameraAnchorPoint").Value;
					Vector3 localPosition = value.localPosition;
					((Vector3)(ref localPosition))..ctor(localPosition.x, num, localPosition.z);
					value.localPosition = localPosition;
				}
				else if (NetworkBool.op_Implicit(player.Tiny))
				{
					float num2 = ((__instance.MovementAction == 1) ? 0.09f : 0.12f);
					Transform value2 = Traverse.Create((object)__instance).Field<Transform>("cameraAnchorPoint").Value;
					Vector3 localPosition2 = value2.localPosition;
					((Vector3)(ref localPosition2))..ctor(localPosition2.x, num2, localPosition2.z);
					value2.localPosition = localPosition2;
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("CameraAnchorPatch error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(LocalCameraHandler), "LateUpdate")]
	internal class LocalCameraHandlerLateUpdatePatch
	{
		private static bool Prefix(LocalCameraHandler __instance)
		{
			//IL_001e: 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)
			try
			{
				if (!((Behaviour)__instance.LocalCamera).enabled)
				{
					return false;
				}
				if (NetworkBool.op_Implicit(PlayerCustom.Local.Dying) || NetworkBool.op_Implicit(PlayerCustom.Local.Downed))
				{
					return false;
				}
				if (UIManager.SeerPanel.Active)
				{
					return false;
				}
				return true;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("LocalCameraHandlerLateUpdatePatch error: " + ex));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(LocalCameraHandler), "SwitchPov")]
	internal class LocalCameraHandlerSwitchPoVPatch
	{
		private static void Postfix(LocalCameraHandler __instance)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PlayerCustom player = PlayerCustomRegistry.GetPlayer(__instance.PovPlayer.Ref);
				if (!((Object)(object)player != (Object)null))
				{
					return;
				}
				player.UpdateAngelLightOnWolves();
				foreach (PlayerCustom allPlayer in PlayerCustomRegistry.AllPlayers)
				{
					allPlayer.UpdateVisibility();
					allPlayer.UpdatePoacherMarkVisibility();
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("LocalCameraHandlerSwitchPoVPatch error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(PlayerController), "OnPlayerDataChanged")]
	internal class OnPlayerDataChangedColorPatch
	{
		private static void Postfix(Changed<PlayerController> changed)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PlayerController behaviour = changed.Behaviour;
				if (((SimulationBehaviour)behaviour).HasInputAuthority)
				{
					if (PlayerPrefs.HasKey("FavoriteColor"))
					{
						PlayerCustom.Rpc_Change_Color(((SimulationBehaviour)behaviour).Runner, behaviour.Index, PlayerPrefs.GetInt("FavoriteColor"));
					}
					else
					{
						PlayerCustom.Rpc_Change_Color(((SimulationBehaviour)behaviour).Runner, behaviour.Index, behaviour.Index);
					}
				}
				PlayerCustom player = PlayerCustomRegistry.GetPlayer(behaviour.Ref);
				if ((Object)(object)player != (Object)null)
				{
					player.UpdateColor();
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("OnPlayerDataChangedColorPatch error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(PlayerEffectsManager), "GlowingChanged")]
	internal class GlowingChangedColorPatch
	{
		private static bool Prefix(Changed<PlayerEffectsManager> changed)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PlayerEffectsManager behaviour = changed.Behaviour;
				PlayerController value = Traverse.Create((object)behaviour).Field<PlayerController>("_playerController").Value;
				PlayerCustom player = PlayerCustomRegistry.GetPlayer(value.Ref);
				SkinnedMeshRenderer value2 = Traverse.Create((object)value.PlayerEffectManager).Field<SkinnedMeshRenderer>("skinnedMeshRenderer").Value;
				Light value3 = Traverse.Create((object)value.PlayerEffectManager).Field<Light>("glowingLight").Value;
				if (NetworkBool.op_Implicit(behaviour.Glowing))
				{
					Color color = ColorManager.GetColor(player.ColorIndex);
					((Renderer)value2).material.SetColor(Shader.PropertyToID("_EmissionColor"), color * 3f);
					((Renderer)value2).material.EnableKeyword("_EMISSION");
					value3.color = color;
					((Behaviour)value3).enabled = true;
					return false;
				}
				((Renderer)value2).material.DisableKeyword("_EMISSION");
				((Behaviour)value3).enabled = false;
				return false;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("GlowingChangedColorPatch error: " + ex));
				return true;
			}
		}
	}
	public static class ColorPicker
	{
		public const int ColorsLength = 12;

		public const string FavoriteColorPlayerPref = "FavoriteColor";

		public static void NextColor()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			PlayerCustom player = PlayerCustomRegistry.GetPlayer(PlayerController.Local.Ref);
			if (player.ColorIndex >= 11)
			{
				PlayerCustom.Rpc_Change_Color(((SimulationBehaviour)player).Runner, player.Index, 0);
			}
			else
			{
				PlayerCustom.Rpc_Change_Color(((SimulationBehaviour)player).Runner, player.Index, player.ColorIndex + 1);
			}
		}

		public static void PreviousColor()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			PlayerCustom player = PlayerCustomRegistry.GetPlayer(PlayerController.Local.Ref);
			if (player.ColorIndex == 0)
			{
				PlayerCustom.Rpc_Change_Color(((SimulationBehaviour)player).Runner, player.Index, 11);
			}
			else
			{
				PlayerCustom.Rpc_Change_Color(((SimulationBehaviour)player).Runner, player.Index, player.ColorIndex - 1);
			}
		}
	}
	[HarmonyPatch(typeof(GameManager), "CheckForEndGame")]
	internal class CheckForEndgamePatch
	{
		private static bool Prefix(GameManager __instance)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Invalid comparison between Unknown and I4
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Invalid comparison between Unknown and I4
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Invalid comparison between Unknown and I4
			//IL_0456: Unknown result type (might be due to invalid IL or missing references)
			//IL_045c: Invalid comparison between Unknown and I4
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_056a: Invalid comparison between Unknown and I4
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f1: Invalid comparison between Unknown and I4
			//IL_05f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Invalid comparison between Unknown and I4
			//IL_058b: Unknown result type (might be due to invalid IL or missing references)
			//IL_059e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a4: Invalid comparison between Unknown and I4
			try
			{
				if (NetworkBool.op_Implicit(__instance.IsStarted) && !NetworkBool.op_Implicit(__instance.IsFinished))
				{
					if (NetworkBool.op_Implicit(BeastManager.Instance.BeastActive))
					{
						return false;
					}
					PlayerCustom specificNewPrimaryRole = PlayerCustomRegistry.GetSpecificNewPrimaryRole(PlayerCustom.PlayerNewPrimaryRole.VillageIdiot);
					if ((Object)(object)specificNewPrimaryRole != (Object)null)
					{
						PlayerController playerController = specificNewPrimaryRole.PlayerController;
						if (NetworkBool.op_Implicit(playerController.IsDead) && NetworkBool.op_Implicit(specificNewPrimaryRole.RoleDeathUniqueBool))
						{
							PlayerCustom.Rpc_End_Game(((SimulationBehaviour)__instance).Runner, specificNewPrimaryRole.Index);
							return false;
						}
					}
					PlayerCustom specificNewPrimaryRole2 = PlayerCustomRegistry.GetSpecificNewPrimaryRole(PlayerCustom.PlayerNewPrimaryRole.Cannibal);
					if ((Object)(object)specificNewPrimaryRole2 != (Object)null && specificNewPrimaryRole2.SoloRoleObjectiveCount >= BalancingValues.CannibalTargetAmount(PlayerRegistry.Count))
					{
						PlayerCustom.Rpc_End_Game(((SimulationBehaviour)__instance).Runner, specificNewPrimaryRole2.Index);
						return false;
					}
					if ((int)GameManager.LocalGameState == 4 && PlayerRegistry.CountWhere((Predicate<PlayerController>)((PlayerController o) => !NetworkBool.op_Implicit(o.IsDead))) <= BalancingValues.AgentMaxSurvivorsToWin(PlayerRegistry.Count))
					{
						IEnumerable<PlayerCustom> enumerable = PlayerCustomRegistry.Where((PlayerCustom o) => o.NewPrimaryRole == PlayerCustom.PlayerNewPrimaryRole.Agent);
						if (enumerable.Any())
						{
							int num = 0;
							foreach (PlayerCustom item in enumerable)
							{
								PlayerController playerController2 = item.PlayerController;
								if (!NetworkBool.op_Implicit(playerController2.IsDead))
								{
									num++;
								}
							}
							if (num == 1)
							{
								PlayerCustom.Rpc_End_Game(((SimulationBehaviour)__instance).Runner, enumerable.First((PlayerCustom o) => !NetworkBool.op_Implicit(o.PlayerController.IsDead)).Index);
								return false;
							}
						}
					}
					PlayerCustom specificNewPrimaryRole3 = PlayerCustomRegistry.GetSpecificNewPrimaryRole(PlayerCustom.PlayerNewPrimaryRole.Spy);
					if ((Object)(object)specificNewPrimaryRole3 != (Object)null && specificNewPrimaryRole3.SoloRoleObjectiveCount >= BalancingValues.SpyTargetAmount(PlayerRegistry.Count))
					{
						PlayerCustom.Rpc_End_Game(((SimulationBehaviour)__instance).Runner, specificNewPrimaryRole3.Index);
						return false;
					}
					if ((int)GameManager.LocalGameState == 4)
					{
						PlayerCustom specificNewPrimaryRole4 = PlayerCustomRegistry.GetSpecificNewPrimaryRole(PlayerCustom.PlayerNewPrimaryRole.Scientist);
						if ((Object)(object)specificNewPrimaryRole4 != (Object)null && specificNewPrimaryRole4.SoloRoleObjectiveCount >= BalancingValues.ScientistGoal(PlayerRegistry.Count))
						{
							PlayerController playerController3 = specificNewPrimaryRole4.PlayerController;
							if (!NetworkBool.op_Implicit(playerController3.IsDead))
							{
								PlayerCustom.Rpc_End_Game(((SimulationBehaviour)__instance).Runner, specificNewPrimaryRole4.Index);
								return false;
							}
						}
					}
					List<PlayerCustom> list = PlayerCustomRegistry.Where((PlayerCustom o) => o.NewPrimaryRole == PlayerCustom.PlayerNewPrimaryRole.Lover).ToList();
					if (list.Count == 2 && !NetworkBool.op_Implicit(PlayerRegistry.GetPlayer(list.First().Ref).IsDead))
					{
						if (PlayerRegistry.CountWhere((Predicate<PlayerController>)((PlayerController o) => !NetworkBool.op_Implicit(o.IsDead))) == 2)
						{
							PlayerCustom.Rpc_End_Game(((SimulationBehaviour)__instance).Runner, list.First().Index);
							return false;
						}
						if ((int)GameManager.LocalGameState == 4 && PlayerRegistry.CountWhere((Predicate<PlayerController>)((PlayerController o) => !NetworkBool.op_Implicit(o.IsDead))) <= 4)
						{
							PlayerCustom.Rpc_End_Game(((SimulationBehaviour)__instance).Runner, list.First().Index);
							return false;
						}
					}
					List<PlayerCustom> list2 = PlayerCustomRegistry.Where((PlayerCustom o) => !NetworkBool.op_Implicit(o.PlayerController.IsDead)).ToList();
					if (!NetworkBool.op_Implicit(__instance.BattleRoyale))
					{
						int num2 = list2.Count((PlayerCustom o) => (int)o.PlayerController.Role == 1);
						int num3 = list2.Count - num2;
						if ((int)GameManager.LocalGameState == 4 && num2 > 0)
						{
							foreach (PlayerCustom item2 in list2)
							{
								if (item2.NewPrimaryRole == PlayerCustom.PlayerNewPrimaryRole.Traitor)
								{
									num2++;
									num3--;
								}
								if (item2.NewPrimaryRole == PlayerCustom.PlayerNewPrimaryRole.Lover && (int)item2.PlayerController.Role == 1)
								{
									num3 += 2;
								}
							}
						}
						if (num2 == 0)
						{
							PlayerCustom.Rpc_End_Game(((SimulationBehaviour)__instance).Runner, PlayerCustomRegistry.GetAnyVillager().Index);
							return false;
						}
						if (num3 == 0)
						{
							PlayerCustom.Rpc_End_Game(((SimulationBehaviour)__instance).Runner, PlayerCustomRegistry.Where((PlayerCustom o) => (int)o.PlayerController.Role == 1 && o.NewPrimaryRole == PlayerCustom.PlayerNewPrimaryRole.None).First().Index);
							return false;
						}
						if ((int)GameManager.State.Current == 4)
						{
							foreach (PlayerCustom item3 in list2)
							{
								if (NetworkBool.op_Implicit(item3.Downed) && ((int)item3.PlayerController.Role == 1 || item3.NewPrimaryRole == PlayerCustom.PlayerNewPrimaryRole.Traitor))
								{
									num2--;
								}
							}
						}
						if (num2 >= num3 && ((int)GameManager.State.Current == 4 || NetworkBool.op_Implicit(Plugin.CustomConfig.AmogusMode)))
						{
							PlayerCustom.Rpc_End_Game(((SimulationBehaviour)__instance).Runner, PlayerCustomRegistry.Where((PlayerCustom o) => (int)o.PlayerController.Role == 1 && o.NewPrimaryRole == PlayerCustom.PlayerNewPrimaryRole.None).First().Index);
							return false;
						}
					}
					else if (list2.Count <= 1)
					{
						GameManager.Rpc_EndGameBattleRoyale(((SimulationBehaviour)__instance).Runner);
					}
				}
				return false;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("CheckForEndgamePatch: " + ex));
				StackTrace stackTrace = new StackTrace();
				Plugin.Logger.LogError((object)("StackTrace: " + stackTrace));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(GameManager), "OnScoreChanged")]
	internal class OnScoreChangedPatch
	{
		private static bool Prefix(Changed<GameManager> changed)
		{
			try
			{
				GameManager.Instance.gameUI.UpdateScore();
				if (((SimulationBehaviour)changed.Behaviour).HasStateAuthority && GameManager.Instance.Score >= GameManager.Instance.MaxScore)
				{
					PlayerCustom.Rpc_End_Game(((SimulationBehaviour)changed.Behaviour).Runner, PlayerCustomRegistry.GetAnyVillager().Index);
				}
				return false;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("OnScoreChangedPatch error: " + ex));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(GameManager), "Rpc_EndGame")]
	internal class EndgameChangesPatch
	{
		private unsafe static bool Prefix(NetworkRunner runner, bool wolfWin)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (NetworkBehaviourUtils.InvokeRpc)
				{
					NetworkBehaviourUtils.InvokeRpc = false;
				}
				else
				{
					if ((Object)(object)runner == (Object)null)
					{
						throw new ArgumentNullException("runner");
					}
					if ((int)runner.Stage == 4)
					{
						return false;
					}
					if (runner.HasAnyActiveConnections())
					{
						int num = 8;
						num += 4;
						SimulationMessage* ptr = SimulationMessage.Allocate(runner.Simulation, num);
						byte* data = SimulationMessage.GetData(ptr);
						int num2 = RpcHeader.Write(RpcHeader.Create(NetworkBehaviourUtils.GetRpcStaticIndexOrThrow("System.Void GameManager::Rpc_EndGame(Fusion.NetworkRunner,System.Boolean)")), data);
						ReadWriteUtilsForWeaver.WriteBoolean((int*)(data + num2), wolfWin);
						num2 += 4;
						((SimulationMessage)ptr).Offset = num2 * 8;
						((SimulationMessage)ptr).SetStatic();
						runner.SendRpc(ptr);
					}
				}
				Plugin.Logger.LogError((object)"ERROR: should never go into Rpc_EndGame method!");
				return true;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("EndgameChangesPatch error: " + ex));
				return true;
			}
		}
	}
	public class ExtraSettings : MonoBehaviour
	{
		private static ExtraSettings _instance;

		public static string PlayerPrefReduceWolfRef = "EXTRA_SETTINGS_REDUCE_WOLF_RED";

		public static string PlayerPrefCheckModInstall = "EXTRA_SETTINGS_CHECK_MOD_INSTALL";

		public bool ReduceWolfRed;

		public bool CheckModInstall;

		public static ExtraSettings Instance
		{
			get
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				if ((Object)(object)_instance == (Object)null)
				{
					GameObject val = new GameObject("ExtraSettings");
					val.AddComponent<ExtraSettings>();
					GameObject val2 = Object.Instantiate<GameObject>(val);
					_instance = val2.GetComponent<ExtraSettings>();
				}
				return _instance;
			}
		}

		private void Start()
		{
			ReduceWolfRed = PlayerPrefs.GetInt(PlayerPrefReduceWolfRef) == 1;
			CheckModInstall = PlayerPrefs.GetInt(PlayerPrefCheckModInstall) == 1;
		}

		public static void OnReduceWolfRedChanged(bool value)
		{
			PlayerPrefs.SetInt(PlayerPrefReduceWolfRef, value ? 1 : 0);
			Instance.ReduceWolfRed = value;
		}

		public static void OnCheckModInstallChanged(bool value)
		{
			PlayerPrefs.SetInt(PlayerPrefCheckModInstall, value ? 1 : 0);
			Instance.CheckModInstall = value;
		}
	}
	[HarmonyPatch(typeof(SettingsUI), "Start")]
	internal class ExtraSettingsPatch
	{
		private static void Postfix(SettingsUI __instance)
		{
			try
			{
				if (!PlayerPrefs.HasKey(ExtraSettings.PlayerPrefReduceWolfRef))
				{
					PlayerPrefs.SetInt(ExtraSettings.PlayerPrefReduceWolfRef, 0);
					ExtraSettings.Instance.ReduceWolfRed = false;
				}
				else
				{
					ExtraSettings.Instance.ReduceWolfRed = PlayerPrefs.GetInt(ExtraSettings.PlayerPrefReduceWolfRef) == 1;
				}
				if (!PlayerPrefs.HasKey(ExtraSettings.PlayerPrefCheckModInstall))
				{
					PlayerPrefs.SetInt(ExtraSettings.PlayerPrefCheckModInstall, 1);
					ExtraSettings.Instance.CheckModInstall = true;
				}
				else
				{
					ExtraSettings.Instance.ReduceWolfRed = PlayerPrefs.GetInt(ExtraSettings.PlayerPrefCheckModInstall) == 1;
				}
				Toggle checkbox = GetCheckbox(__instance, "NALES_SETTING_REDUCE_WOLF_RED", ExtraSettings.PlayerPrefReduceWolfRef);
				((UnityEvent<bool>)(object)checkbox.onValueChanged).AddListener((UnityAction<bool>)ExtraSettings.OnReduceWolfRedChanged);
				Toggle checkbox2 = GetCheckbox(__instance, "NALES_SETTING_CHECK_MOD_INSTALL", ExtraSettings.PlayerPrefCheckModInstall);
				((UnityEvent<bool>)(object)checkbox2.onValueChanged).AddListener((UnityAction<bool>)ExtraSettings.OnCheckModInstallChanged);
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("ExtraSettingsPatch error: " + ex));
			}
		}

		private static Toggle GetCheckbox(SettingsUI settingsUI, string textKey, string playerPref)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			Toggle value = Traverse.Create((object)settingsUI).Field<Toggle>("reverseYAxisToggle").Value;
			Transform parent = ((Component)value).transform.parent.parent.parent;
			Transform parent2 = ((Component)value).transform.parent.parent.parent.parent;
			Transform val = Object.Instantiate<Transform>(parent, parent2);
			LocalizeStringEvent val2 = ((Component)val).GetComponentsInChildren<LocalizeStringEvent>().First((LocalizeStringEvent o) => ((Object)o).name == "SettingNameText");
			((LocalizedReference)val2.StringReference).SetReference(TableReference.op_Implicit("UI Text"), TableEntryReference.op_Implicit(textKey));
			Toggle componentInChildren = ((Component)val).GetComponentInChildren<Toggle>();
			GameObject gameObject = ((Component)componentInChildren).gameObject;
			Object.DestroyImmediate((Object)(object)componentInChildren);
			componentInChildren = gameObject.AddComponent<Toggle>();
			componentInChildren.graphic = ((Component)((Component)componentInChildren).transform.Find("Background").Find("Checkmark")).GetComponent<Graphic>();
			componentInChildren.isOn = PlayerPrefs.GetInt(playerPref) == 1;
			return componentInChildren;
		}
	}
	[HarmonyPatch(typeof(LightingManager), "DisplayWolfLight")]
	internal class ExtraSettingsReduceWolfRedPatch
	{
		private static bool Prefix(bool active, LightingManager __instance)
		{
			try
			{
				ColorAdjustmentManager.UpdateColorAdjustment();
				return false;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("ExtraSettingsReduceWolfRedPatch error: " + ex));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(LightingManager), "UpdateLighting")]
	public class FogChangesPatch
	{
		public static float FogDensityDaytime = 0.015f;

		public static float FogEndDistanceDaytime { get; set; }

		public static float FogEndDistanceNight { get; set; }

		public static float FogDensityNight { get; set; }

		private static void Postfix(LightingManager __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				EGameState localGameState = GameManager.LocalGameState;
				EGameState val = localGameState;
				if (val - 2 <= 2)
				{
					PlayerCustom player = PlayerCustomRegistry.GetPlayer(PlayerController.Local.LocalCameraHandler.PovPlayer.Ref);
					if (NetworkBool.op_Implicit(PlayerController.Local.LocalCameraHandler.PovPlayer.IsZooming))
					{
						RenderSettings.fogDensity = 0f;
						RenderSettings.fogEndDistance = 300f;
						return;
					}
					float num = 0f;
					float num2 = 300f;
					float value = Traverse.Create((object)__instance).Field<float>("_localTimeOfDay").Value;
					if (value >= 6f && value <= 17f)
					{
						num = FogDensityDaytime;
						num2 = FogEndDistanceDaytime;
					}
					else if (value <= 5f || value >= 18f)
					{
						num = FogDensityNight;
						num2 = FogEndDistanceNight;
					}
					else if (value > 5f && value < 6f)
					{
						num = Mathf.Lerp(FogDensityDaytime, FogDensityNight, 6f - value);
						num2 = Mathf.Lerp(FogEndDistanceDaytime, FogEndDistanceNight, 6f - value);
					}
					else if (value > 17f && value < 18f)
					{
						num = Mathf.Lerp(FogDensityNight, FogDensityDaytime, 18f - value);
						num2 = Mathf.Lerp(FogEndDistanceNight, FogEndDistanceDaytime, 18f - value);
					}
					if (SabotageManager.Instance.IsSabotageActive(SabotageManager.SabotageIds.CursedNight))
					{
						num2 *= 0.65f;
					}
					if (NetworkBool.op_Implicit(BeastManager.Instance.BeastActive))
					{
						num2 = 65f * BalancingValues.NightFogEndDistanceMultiplierByMap(GameManager.Instance.MapID);
						num = 0.25f;
						RenderSettings.fogColor = BalancingValues.BeastActiveFogColor;
					}
					if (NetworkBool.op_Implicit(PlayerController.Local.LocalCameraHandler.PovPlayer.IsWolf))
					{
						num2 += 25f * BalancingValues.NightFogEndDistanceMultiplierByMap(GameManager.Instance.MapID);
					}
					else if (NetworkBool.op_Implicit(PlayerController.Local.LocalCameraHandler.PovPlayer.PlayerEffectManager.NightVision))
					{
						num2 += 60f;
						num /= 2f;
					}
					if (NetworkBool.op_Implicit(player.Nearsighted))
					{
						num2 = 12f * BalancingValues.NightFogEndDistanceMultiplierByMap(GameManager.Instance.MapID);
						num = 1f;
						RenderSettings.fogColor = BalancingValues.NearsightedFogColor;
					}
					else if (NetworkBool.op_Implicit(player.Poison))
					{
						num2 = 25f * BalancingValues.NightFogEndDistanceMultiplierByMap(GameManager.Instance.MapID);
						num = 0.75f;
						RenderSettings.fogColor = BalancingValues.SaboteurPoisonFogColor;
					}
					else if (NetworkBool.op_Implicit(player.ExorcismActive))
					{
						num2 = 25f * BalancingValues.NightFogEndDistanceMultiplierByMap(GameManager.Instance.MapID);
						num = 1f;
						RenderSettings.fogColor = BalancingValues.ExorcistFogColor;
					}
					else if (NetworkBool.op_Implicit(player.Nauseated))
					{
						num2 = 30f * BalancingValues.NightFogEndDistanceMultiplierByMap(GameManager.Instance.MapID);
						num = 0.75f;
						RenderSettings.fogColor = BalancingValues.NauseatedFogColor;
					}
					RenderSettings.fogDensity = num;
					RenderSettings.fogEndDistance = num2;
				}
				else
				{
					RenderSettings.fogDensity = 0f;
					RenderSettings.fogEndDistance = 300f;
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("FogChangesPatch error: " + ex));
			}
		}
	}
	[NetworkBehaviourWeaved(7)]
	public class GameConfig : NetworkBehaviour
	{
		public enum ConfigTypeEnum
		{
			Base,
			Roles,
			RolesSecondary,
			Others,
			Potions,
			Gadgets
		}

		public static Color ColorSoloRole = new Color(1f, 0f, 1f, 1f);

		public static Color ColorWolfPower = new Color(1f, 0f, 0f, 1f);

		public static Color ColorVillagerJob = new Color(0f, 0.5f, 1f, 1f);

		public static Color ColorTraitor = new Color(1f, 0.5f, 0f, 1f);

		public static Color ColorSecondaryRole = new Color(1f, 1f, 1f, 1f);

		public static TMP_Dropdown SoloRolesCountConfig;

		public static TMP_Dropdown TraitorsCountConfig;

		public static TMP_Dropdown WolfPowersCountConfig;

		public static TMP_Dropdown VillagerPowersChanceConfig;

		public static TMP_Dropdown SecondaryRolesCountConfig;

		public static Dictionary<PlayerCustom.PlayerNewPrimaryRole, Toggle> SoloRolesConfig = new Dictionary<PlayerCustom.PlayerNewPrimaryRole, Toggle>();

		public static Dictionary<PlayerCustom.PlayerPrimaryRolePower, Toggle> PrimaryRolePowerConfig = new Dictionary<PlayerCustom.PlayerPrimaryRolePower, Toggle>();

		public static Dictionary<PlayerCustom.PlayerSecondaryRole, Toggle> SecondaryRolesConfig = new Dictionary<PlayerCustom.PlayerSecondaryRole, Toggle>();

		public static Dictionary<string, Toggle> PotionsConfig = new Dictionary<string, Toggle>();

		public static Dictionary<string, Toggle> GadgetsConfig = new Dictionary<string, Toggle>();

		public int SoloRolesCount;

		public int TraitorsCount;

		public int WolfPowersCount;

		public int VillagerPowersChance;

		public int SecondaryRolesCount;

		public Dictionary<PlayerCustom.PlayerNewPrimaryRole, bool> SoloRoleActive = new Dictionary<PlayerCustom.PlayerNewPrimaryRole, bool>();

		public Dictionary<PlayerCustom.PlayerPrimaryRolePower, bool> PrimaryRolePowerActive = new Dictionary<PlayerCustom.PlayerPrimaryRolePower, bool>();

		public Dictionary<PlayerCustom.PlayerSecondaryRole, bool> SecondaryRoleActive = new Dictionary<PlayerCustom.PlayerSecondaryRole, bool>();

		public Dictionary<string, bool> PotionsAvailability = new Dictionary<string, bool>();

		public Dictionary<string, bool> GadgetsAvailability = new Dictionary<string, bool>();

		public static Toggle TrapsModifiedToggle;

		public static Toggle AnonymousVotesToggle;

		public static Toggle AmogusModeToggle;

		public static Toggle SabotagesAvailableToggle;

		public static Toggle DropItemsAvailableToggle;

		public static TMP_Dropdown NightFogDropdown;

		public static Button ButtonConfigBaseGame;

		public static Button ButtonConfigMod;

		public static GameObject GameSettingsObject;

		public static GameObject RoleInfoObject;

		[Networked]
		[NetworkedWeaved(0, 1)]
		public unsafe NetworkBool TrapsModified
		{
			get
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing GameConfig.TrapsModified. Networked properties can only be accessed when Spawned() has been called.");
				}
				return (NetworkBool)(*base.Ptr);
			}
			private set
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing GameConfig.TrapsModified. Networked properties can only be accessed when Spawned() has been called.");
				}
				Unsafe.Write(base.Ptr, value);
			}
		}

		[Networked]
		[NetworkedWeaved(1, 1)]
		public unsafe NetworkBool AnonymousVotes
		{
			get
			{
				//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_002b: Unknown result type (might be due to invalid IL or missing references)
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing GameConfig.AnonymousVotes. Networked properties can only be accessed when Spawned() has been called.");
				}
				return (NetworkBool)base.Ptr[1];
			}
			private set
			{
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing GameConfig.AnonymousVotes. Networked properties can only be accessed when Spawned() has been called.");
				}
				Unsafe.Write(base.Ptr + 1, value);
			}
		}

		[Networked]
		[NetworkedWeaved(2, 1)]
		public unsafe NetworkBool AmogusMode
		{
			get
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing GameConfig.AmogusMode. Networked properties can only be accessed when Spawned() has been called.");
				}
				return (NetworkBool)base.Ptr[2];
			}
			private set
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing GameConfig.AmogusMode. Networked properties can only be accessed when Spawned() has been called.");
				}
				Unsafe.Write(base.Ptr + 2, value);
			}
		}

		[Networked]
		[NetworkedWeaved(3, 1)]
		public unsafe NetworkBool SabotagesAvailable
		{
			get
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing GameConfig.SabotagesAvailable. Networked properties can only be accessed when Spawned() has been called.");
				}
				return (NetworkBool)base.Ptr[3];
			}
			private set
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing GameConfig.SabotagesAvailable. Networked properties can only be accessed when Spawned() has been called.");
				}
				Unsafe.Write(base.Ptr + 3, value);
			}
		}

		[Networked]
		[NetworkedWeaved(4, 1)]
		public unsafe NetworkBool DropItemsAvailable
		{
			get
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing GameConfig.DropItemsAvailable. Networked properties can only be accessed when Spawned() has been called.");
				}
				return (NetworkBool)base.Ptr[4];
			}
			private set
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing GameConfig.DropItemsAvailable. Networked properties can only be accessed when Spawned() has been called.");
				}
				Unsafe.Write(base.Ptr + 4, value);
			}
		}

		[Networked]
		[NetworkedWeaved(5, 1)]
		public unsafe int NightFog
		{
			get
			{
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing PlayerCustom.NightFog. Networked properties can only be accessed when Spawned() has been called.");
				}
				return base.Ptr[5];
			}