Decompiled source of LycansNewRoles v0.90.0

plugins/LycansNewRoles/LycansNewRoles.dll

Decompiled a day 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+8cbf627162fd73e31e7500bda288e61adb30a442")]
[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.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 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 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 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 = 15f;

		public const float BomberBombStartMaximumDelay = 30f;

		public const float BomberBombTickingSoundRange = 20f;

		public const float BomberBombExplosionSoundRange = 40f;

		public const int BomberRequiredMaterials = 125;

		public const float BomberStartingMaterialPercentage = 0.251f;

		public const float AlcoholicPotionHealWolf = 0.45f;

		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 = 10f;

		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 ForensicsAnalyzeDuration = 3f;

		public const float AvengerKillRange = 2.5f;

		public const float SurvivalistSaveCastTime = 4f;

		public const float SurvivalistHungerPercentageWhenDowned = 0.245f;

		public const float SurvivalistAlertRange = 40f;

		public const float PriestProtectRange = 2.5f;

		public const int PriestRequiredMaterials = 125;

		public const float PriestStartingMaterialPercentage = 0.502f;

		public const float PriestMaterialsMultiplierAtFullHealth = 2f;

		public const float PriestProtectionDownedDuration = 7f;

		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 = 10;

		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.15f;

		public const float LoverVillagerHungerRatePerLivingPlayer = 0.0125f;

		public const float LoverVillagerHealPercentageOnWolfKill = 0.4f;

		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 GetVillagerJobChancePonderation(PlayerCustom.PlayerPrimaryRolePower power)
		{
			return power switch
			{
				PlayerCustom.PlayerPrimaryRolePower.Peasant => 2, 
				PlayerCustom.PlayerPrimaryRolePower.Repairer => 1, 
				PlayerCustom.PlayerPrimaryRolePower.Guard => 1, 
				PlayerCustom.PlayerPrimaryRolePower.Exorcist => 2, 
				PlayerCustom.PlayerPrimaryRolePower.Forensics => 1, 
				PlayerCustom.PlayerPrimaryRolePower.Avenger => 1, 
				PlayerCustom.PlayerPrimaryRolePower.Barkeep => 2, 
				PlayerCustom.PlayerPrimaryRolePower.Survivalist => 2, 
				PlayerCustom.PlayerPrimaryRolePower.Priest => 2, 
				_ => 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 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.BothPolitician => 10 * 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 4;
			case 7:
			case 8:
			case 9:
				return 5;
			case 10:
			case 11:
				return 6;
			case 12:
			case 13:
				return 7;
			case 14:
			case 15:
				return 8;
			default:
				return 8;
			}
		}

		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, 
			};
		}
	}
	[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(PlayerController), "OnPlayerDataChanged")]
	internal class OnPlayerDataChangedColorPatch
	{
		private static void Postfix(Changed<PlayerController> changed)
		{
			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);
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("OnPlayerDataChangedColorPatch error: " + ex));
			}
		}
	}
	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_0047: 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)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Invalid comparison between Unknown and I4
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Invalid comparison between Unknown and I4
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Invalid comparison between Unknown and I4
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Invalid comparison between Unknown and I4
			//IL_0558: Unknown result type (might be due to invalid IL or missing references)
			//IL_055e: Invalid comparison between Unknown and I4
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0565: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a6: Invalid comparison between Unknown and I4
			try
			{
				if (NetworkBool.op_Implicit(__instance.IsStarted) && !NetworkBool.op_Implicit(__instance.IsFinished))
				{
					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<PlayerController> list2 = PlayerRegistry.Where((Predicate<PlayerController>)((PlayerController p) => !NetworkBool.op_Implicit(p.IsDead))).ToList();
					if (!NetworkBool.op_Implicit(__instance.BattleRoyale))
					{
						int num2 = list2.Count((PlayerController p) => (int)p.Role == 1);
						int num3 = list2.Count - num2;
						if ((int)GameManager.LocalGameState == 4 && num2 > 0)
						{
							foreach (PlayerController item2 in list2)
							{
								PlayerCustom player = PlayerCustomRegistry.GetPlayer(item2.Ref);
								if (player.NewPrimaryRole == PlayerCustom.PlayerNewPrimaryRole.Traitor)
								{
									num2++;
									num3--;
								}
								if (player.NewPrimaryRole == PlayerCustom.PlayerNewPrimaryRole.Lover && (int)item2.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 (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_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: 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(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 = 10f * 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];
			}
			set
			{
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing PlayerCustom.NightFog. Networked properties can only be accessed when Spawned() has been called.");
				}
				base.Ptr[5] = value;
			}
		}

		private void Start()
		{
			FillTrapsModifiedToggle();
			FillAnonymousVotesToggle();
			FillAmogusModeToggle();
			FillSabotagesAvailableToggle();
			FillDropItemsAvailableToggle();
		}

		public override void Spawned()
		{
			if (((SimulationBehaviour)this).Runner.IsClient)
			{
				Plugin.NetworkObject = ((Component)this).GetComponent<NetworkObject>();
			}
			try
			{
				SoloRolesCount = int.Parse(SoloRolesCountConfig.options[SoloRolesCountConfig.value].text);
				TraitorsCount = int.Parse(TraitorsCountConfig.options[TraitorsCountConfig.value].text);
				WolfPowersCount = int.Parse(WolfPowersCountConfig.options[WolfPowersCountConfig.value].text);
				VillagerPowersChance = int.Parse(VillagerPowersChanceConfig.options[VillagerPowersChanceConfig.value].text.Replace("%", ""));
				SecondaryRolesCount = int.Parse(SecondaryRolesCountConfig.options[SecondaryRolesCountConfig.value].text);
				foreach (KeyValuePair<PlayerCustom.PlayerNewPrimaryRole, Toggle> item in SoloRolesConfig)
				{
					SoloRoleActive[item.Key] = item.Value.isOn;
				}
				foreach (KeyValuePair<PlayerCustom.PlayerPrimaryRolePower, Toggle> item2 in PrimaryRolePowerConfig)
				{
					PrimaryRolePowerActive[item2.Key] = item2.Value.isOn;
				}
				foreach (KeyValuePair<PlayerCustom.PlayerSecondaryRole, Toggle> item3 in SecondaryRolesConfig)
				{
					SecondaryRoleActive[item3.Key] = item3.Value.isOn;
				}
				NightFog = int.Parse(NightFogDropdown.options[NightFogDropdown.value].text.Replace("%", ""));
				foreach (KeyValuePair<string, Toggle> item4 in PotionsConfig)
				{
					PotionsAvailability[item4.Key] = item4.Value.isOn;
				}
				foreach (KeyValuePair<string, Toggle> item5 in GadgetsConfig)
				{
					GadgetsAvailability[item5.Key] = item5.Value.isOn;
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("GameConfigSetGameSettingsPatch error: " + ex));
			}
		}

		public override void Despawned(NetworkRunner runner, bool hasState)
		{
		}

		public static void CreateAndAttachSoloRoleConfigToggle(GameSettingsUI gameSettingsUI, PlayerCustom.PlayerNewPrimaryRole role, string key)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			string key2 = ((role == PlayerCustom.PlayerNewPrimaryRole.Lover) ? "NALES_CONFIG_ROLE_TYPE_MAIN_DUO" : "NALES_CONFIG_ROLE_TYPE_MAIN_SOLO");
			Toggle toggle = GetToggle(gameSettingsUI, key2, new List<object> { key }, ConfigTypeEnum.Roles, PlayerCustom.GetNewPrimaryRoleColor(role));
			SoloRolesConfig[role] = toggle;
			FillSoloRoleToggle(toggle, role);
		}

		public static void CreateAndAttachPrimaryRolePowerConfigToggle(GameSettingsUI gameSettingsUI, PlayerCustom.PlayerPrimaryRolePower role, string key)
		{
			//IL_0032: 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)
			bool flag = PlayerCustom.IsPrimaryRolePowerForVillagers(role);
			string key2 = (flag ? "NALES_CONFIG_ROLE_TYPE_MAIN_VILLAGER" : "NALES_CONFIG_ROLE_TYPE_MAIN_WOLF");
			Toggle toggle = GetToggle(gameSettingsUI, key2, new List<object> { key }, ConfigTypeEnum.Roles, flag ? ColorVillagerJob : ColorWolfPower);
			PrimaryRolePowerConfig[role] = toggle;
			FillPrimaryRolePowerToggle(toggle, role);
		}

		public static void CreateAndAttachSecondaryRoleConfigToggle(GameSettingsUI gameSettingsUI, PlayerCustom.PlayerSecondaryRole role, string key)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			Toggle toggle = GetToggle(gameSettingsUI, "NALES_CONFIG_ROLE_TYPE_SECONDARY", new List<object> { key }, ConfigTypeEnum.RolesSecondary, ColorSecondaryRole);
			SecondaryRolesConfig[role] = toggle;
			FillSecondaryRoleToggle(toggle, role);
		}

		public static Toggle CreateAndAttachConfigToggle(GameSettingsUI gameSettingsUI, string key, List<object> arguments, ConfigTypeEnum type, Color textColor)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return GetToggle(gameSettingsUI, key, arguments, type, textColor);
		}

		public static TMP_Dropdown CreateAndAttachConfigDropdownWithMax(GameSettingsUI gameSettingsUI, string key, int max, ConfigTypeEnum type, Color textColor)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string>();
			for (int i = 0; i <= max; i++)
			{
				list.Add(i.ToString());
			}
			return GetDropdown(gameSettingsUI, key, list, type, textColor);
		}

		public static TMP_Dropdown CreateAndAttachConfigDropdownWithPercentages(GameSettingsUI gameSettingsUI, string key, ConfigTypeEnum type, Color textColor)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string>();
			for (int i = 0; i <= 100; i += 10)
			{
				list.Add(i + "%");
			}
			return GetDropdown(gameSettingsUI, key, list, type, textColor);
		}

		public static void FillSoloRolesCountDropdown()
		{
			TMP_Dropdown dropdown = SoloRolesCountConfig;
			if (!PlayerPrefs.HasKey("GAME_SETTINGS_SOLO_ROLES_COUNT"))
			{
				PlayerPrefs.SetInt("GAME_SETTINGS_SOLO_ROLES_COUNT", 1);
			}
			((UnityEventBase)dropdown.onValueChanged).RemoveAllListeners();
			((UnityEvent<int>)(object)dropdown.onValueChanged).AddListener((UnityAction<int>)delegate(int index)
			{
				Plugin.CustomConfig.SoloRolesCount = int.Parse(dropdown.options[index].text);
				PlayerPrefs.SetInt("GAME_SETTINGS_SOLO_ROLES_COUNT", index);
			});
			if (PlayerPrefs.HasKey("GAME_SETTINGS_SOLO_ROLES_COUNT"))
			{
				int @int = PlayerPrefs.GetInt("GAME_SETTINGS_SOLO_ROLES_COUNT");
				if (@int < dropdown.options.Count)
				{
					dropdown.SetValueWithoutNotify(@int);
				}
			}
		}

		public static void FillTraitorsCountDropdown()
		{
			TMP_Dropdown dropdown = TraitorsCountConfig;
			if (!PlayerPrefs.HasKey("GAME_SETTINGS_TRAITORS_COUNT"))
			{
				PlayerPrefs.SetInt("GAME_SETTINGS_TRAITORS_COUNT", 0);
			}
			((UnityEventBase)dropdown.onValueChanged).RemoveAllListeners();
			((UnityEvent<int>)(object)dropdown.onValueChanged).AddListener((UnityAction<int>)delegate(int index)
			{
				Plugin.CustomConfig.TraitorsCount = int.Parse(dropdown.options[index].text);
				PlayerPrefs.SetInt("GAME_SETTINGS_TRAITORS_COUNT", index);
			});
			if (PlayerPrefs.HasKey("GAME_SETTINGS_TRAITORS_COUNT"))
			{
				int @int = PlayerPrefs.GetInt("GAME_SETTINGS_TRAITORS_COUNT");
				if (@int < dropdown.options.Count)
				{
					dropdown.SetValueWithoutNotify(@int);
				}
			}
		}

		public static void FillPrimaryRolePowersCountDropdown()
		{
			TMP_Dropdown dropdown = WolfPowersCountConfig;
			if (!PlayerPrefs.HasKey("GAME_SETTINGS_PRIMARY_ROLE_POWERS_COUNT"))
			{
				PlayerPrefs.SetInt("GAME_SETTINGS_PRIMARY_ROLE_POWERS_COUNT", 2);
			}
			((UnityEventBase)dropdown.onValueChanged).RemoveAllListeners();
			((UnityEvent<int>)(object)dropdown.onValueChanged).AddListener((UnityAction<int>)delegate(int index)
			{
				Plugin.CustomConfig.WolfPowersCount = int.Parse(dropdown.options[index].text);
				PlayerPrefs.SetInt("GAME_SETTINGS_PRIMARY_ROLE_POWERS_COUNT", index);
			});
			if (PlayerPrefs.HasKey("GAME_SETTINGS_PRIMARY_ROLE_POWERS_COUNT"))
			{
				int @int = PlayerPrefs.GetInt("GAME_SETTINGS_PRIMARY_ROLE_POWERS_COUNT");
				if (@int < dropdown.options.Count)
				{
					dropdown.SetValueWithoutNotify(@int);
				}
			}
		}

		public static void FillPrimaryRoleVillagerPowersChanceDropdown()
		{
			TMP_Dropdown dropdown = VillagerPowersChanceConfig;
			if (!PlayerPrefs.HasKey("GAME_SETTINGS_PRIMARY_ROLE_VILLAGER_POWERS_CHANCE"))
			{
				PlayerPrefs.SetInt("GAME_SETTINGS_PRIMARY_ROLE_VILLAGER_POWERS_CHANCE", 10);
			}
			((UnityEventBase)dropdown.onValueChanged).RemoveAllListeners();
			((UnityEvent<int>)(object)dropdown.onValueChanged).AddListener((UnityAction<int>)delegate(int index)
			{
				Plugin.CustomConfig.VillagerPowersChance = int.Parse(dropdown.options[index].text.Replace("%", ""));
				PlayerPrefs.SetInt("GAME_SETTINGS_PRIMARY_ROLE_VILLAGER_POWERS_CHANCE", index);
			});
			if (PlayerPrefs.HasKey("GAME_SETTINGS_PRIMARY_ROLE_VILLAGER_POWERS_CHANCE"))
			{
				int @int = PlayerPrefs.GetInt("GAME_SETTINGS_PRIMARY_ROLE_VILLAGER_POWERS_CHANCE");
				if (@int < dropdown.options.Count)
				{
					dropdown.SetValueWithoutNotify(@int);
				}
			}
		}

		public static void FillSecondaryRolesCountDropdown()
		{
			TMP_Dropdown dropdown = SecondaryRolesCountConfig;
			if (!PlayerPrefs.HasKey("GAME_SETTINGS_SECONDARY_ROLES_COUNT"))
			{
				PlayerPrefs.SetInt("GAME_SETTINGS_SECONDARY_ROLES_COUNT", 1);
			}
			((UnityEventBase)dropdown.onValueChanged).RemoveAllListeners();
			((UnityEvent<int>)(object)dropdown.onValueChanged).AddListener((UnityAction<int>)delegate(int index)
			{
				Plugin.CustomConfig.SecondaryRolesCount = int.Parse(dropdown.options[index].text);
				PlayerPrefs.SetInt("GAME_SETTINGS_SECONDARY_ROLES_COUNT", index);
			});
			if (PlayerPrefs.HasKey("GAME_SETTINGS_SECONDARY_ROLES_COUNT"))
			{
				int @int = PlayerPrefs.GetInt("GAME_SETTINGS_SECONDARY_ROLES_COUNT");
				if (@int < dropdown.options.Count)
				{
					dropdown.SetValueWithoutNotify(@int);
				}
			}
		}

		public static void FillSoloRoleToggle(Toggle toggle, PlayerCustom.PlayerNewPrimaryRole role)
		{
			string playerPref = "GAME_SETTINGS_NALES_ROLE_" + role;
			if (!PlayerPrefs.HasKey(playerPref))
			{
				PlayerPrefs.SetInt(playerPref, 1);
			}
			((UnityEventBase)toggle.onValueChanged).RemoveAllListeners();
			((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value)
			{
				Plugin.CustomConfig.SoloRoleActive[role] = value;
				PlayerPrefs.SetInt(playerPref, value ? 1 : 0);
			});
			if (PlayerPrefs.HasKey(playerPref) && PlayerPrefs.GetInt(playerPref) == 1)
			{
				SoloRolesConfig[role].SetIsOnWithoutNotify(true);
			}
		}

		public static void FillPrimaryRolePowerToggle(Toggle toggle, PlayerCustom.PlayerPrimaryRolePower role)
		{
			string playerPref = "GAME_SETTINGS_NALES_ROLE_" + role;
			if (!PlayerPrefs.HasKey(playerPref))
			{
				PlayerPrefs.SetInt(playerPref, 1);
			}
			((UnityEventBase)toggle.onValueChanged).RemoveAllListeners();
			((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value)
			{
				Plugin.CustomConfig.PrimaryRolePowerActive[role] = value;
				PlayerPrefs.SetInt(playerPref, value ? 1 : 0);
			});
			if (PlayerPrefs.HasKey(playerPref) && PlayerPrefs.GetInt(playerPref) == 1)
			{
				PrimaryRolePowerConfig[role].SetIsOnWithoutNotify(true);
			}
		}

		public static void FillSecondaryRoleToggle(Toggle toggle, PlayerCustom.PlayerSecondaryRole role)
		{
			string playerPref = "GAME_SETTINGS_NALES_ROLE_" + role;
			if (!PlayerPrefs.HasKey(playerPref))
			{
				PlayerPrefs.SetInt(playerPref, 1);
			}
			((UnityEventBase)toggle.onValueChanged).RemoveAllListeners();
			((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value)
			{
				Plugin.CustomConfig.SecondaryRoleActive[role] = value;
				PlayerPrefs.SetInt(playerPref, value ? 1 : 0);
			});
			if (PlayerPrefs.HasKey(playerPref) && PlayerPrefs.GetInt(playerPref) == 1)
			{
				SecondaryRolesConfig[role].SetIsOnWithoutNotify(true);
			}
		}

		public void FillTrapsModifiedToggle()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if (!PlayerPrefs.HasKey("GAME_SETTINGS_TRAPS_MODIFIED"))
			{
				PlayerPrefs.SetInt("GAME_SETTINGS_TRAPS_MODIFIED", 1);
			}
			if (PlayerPrefs.HasKey("GAME_SETTINGS_TRAPS_MODIFIED") && PlayerPrefs.GetInt("GAME_SETTINGS_TRAPS_MODIFIED") == 1)
			{
				TrapsModified = NetworkBool.op_Implicit(true);
				TrapsModifiedToggle.SetIsOnWithoutNotify(true);
			}
		}

		public static void UpdateTrapsModified(bool value)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Plugin.CustomConfig.TrapsModified = NetworkBool.op_Implicit(value);
			PlayerPrefs.SetInt("GAME_SETTINGS_TRAPS_MODIFIED", value ? 1 : 0);
		}

		public void UpdateTrapsModifiedSetting(bool value)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (((SimulationBehaviour)this).Runner.IsServer && (int)GameManager.State.Current == 1)
			{
				TrapsModified = NetworkBool.op_Implicit(value);
			}
		}

		public void FillAnonymousVotesToggle()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if (!PlayerPrefs.HasKey("GAME_SETTINGS_ANONYMOUS_VOTES"))
			{
				PlayerPrefs.SetInt("GAME_SETTINGS_ANONYMOUS_VOTES", 0);
			}
			if (PlayerPrefs.HasKey("GAME_SETTINGS_ANONYMOUS_VOTES") && PlayerPrefs.GetInt("GAME_SETTINGS_ANONYMOUS_VOTES") == 1)
			{
				AnonymousVotes = NetworkBool.op_Implicit(true);
				AnonymousVotesToggle.SetIsOnWithoutNotify(true);
			}
		}

		public static void UpdateAnonymousVotes(bool value)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Plugin.CustomConfig.AnonymousVotes = NetworkBool.op_Implicit(value);
			PlayerPrefs.SetInt("GAME_SETTINGS_ANONYMOUS_VOTES", value ? 1 : 0);
		}

		public void UpdateAnonymousVotesSetting(bool value)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (((SimulationBehaviour)this).Runner.IsServer && (int)GameManager.State.Current == 1)
			{
				AnonymousVotes = NetworkBool.op_Implicit(value);
			}
		}

		public void FillAmogusModeToggle()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if (!PlayerPrefs.HasKey("GAME_SETTINGS_AMOGUS_MODE"))
			{
				PlayerPrefs.SetInt("GAME_SETTINGS_AMOGUS_MODE", 0);
			}
			if (PlayerPrefs.HasKey("GAME_SETTINGS_AMOGUS_MODE") && PlayerPrefs.GetInt("GAME_SETTINGS_AMOGUS_MODE") == 1)
			{
				AmogusMode = NetworkBool.op_Implicit(true);
				AmogusModeToggle.SetIsOnWithoutNotify(true);
			}
		}

		public static void UpdateAmogusMode(bool value)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Plugin.CustomConfig.AmogusMode = NetworkBool.op_Implicit(value);
			PlayerPrefs.SetInt("GAME_SETTINGS_AMOGUS_MODE", value ? 1 : 0);
		}

		public void UpdateAmogusModeSetting(bool value)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (((SimulationBehaviour)this).Runner.IsServer && (int)GameManager.State.Current == 1)
			{
				AmogusMode = NetworkBool.op_Implicit(value);
			}
		}

		public void FillSabotagesAvailableToggle()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if (!PlayerPrefs.HasKey("GAME_SETTINGS_SABOTAGES_AVAILABLE"))
			{
				PlayerPrefs.SetInt("GAME_SETTINGS_SABOTAGES_AVAILABLE", 1);
			}
			if (PlayerPrefs.HasKey("GAME_SETTINGS_SABOTAGES_AVAILABLE") && PlayerPrefs.GetInt("GAME_SETTINGS_SABOTAGES_AVAILABLE") == 1)
			{
				SabotagesAvailable = NetworkBool.op_Implicit(true);
				SabotagesAvailableToggle.SetIsOnWithoutNotify(true);
			}
		}

		public static void UpdateSabotagesAvailable(bool value)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Plugin.CustomConfig.SabotagesAvailable = NetworkBool.op_Implicit(value);
			PlayerPrefs.SetInt("GAME_SETTINGS_SABOTAGES_AVAILABLE", value ? 1 : 0);
		}

		public void UpdateSabotagesAvailableSetting(bool value)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (((SimulationBehaviour)this).Runner.IsServer && (int)GameManager.State.Current == 1)
			{
				SabotagesAvailable = NetworkBool.op_Implicit(value);
			}
		}

		public void FillDropItemsAvailableToggle()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if (!PlayerPrefs.HasKey("GAME_SETTINGS_DROP_ITEMS_AVAILABLE"))
			{
				PlayerPrefs.SetInt("GAME_SETTINGS_DROP_ITEMS_AVAILABLE", 1);
			}
			if (PlayerPrefs.HasKey("GAME_SETTINGS_DROP_ITEMS_AVAILABLE") && PlayerPrefs.GetInt("GAME_SETTINGS_DROP_ITEMS_AVAILABLE") == 1)
			{
				DropItemsAvailable = NetworkBool.op_Implicit(true);
				DropItemsAvailableToggle.SetIsOnWithoutNotify(true);
			}
		}

		public static void UpdateDropItemsAvailable(bool value)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Plugin.CustomConfig.DropItemsAvailable = NetworkBool.op_Implicit(value);
			PlayerPrefs.SetInt("GAME_SETTINGS_DROP_ITEMS_AVAILABLE", value ? 1 : 0);
		}

		public void UpdateDropItemsAvailableSetting(bool value)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (((SimulationBehaviour)this).Runner.IsServer && (int)GameManager.State.Current == 1)
			{
				DropItemsAvailable = NetworkBool.op_Implicit(value);
			}
		}

		public static void FillNightFogDropdown(TMP_Dropdown dropdown)
		{
			if (!PlayerPrefs.HasKey("GAME_SETTINGS_NIGHT_FOG"))
			{
				PlayerPrefs.SetInt("GAME_SETTINGS_NIGHT_FOG", 5);
			}
			((UnityEventBase)dropdown.onValueChanged).RemoveAllListeners();
			((UnityEvent<int>)(object)dropdown.onValueChanged).AddListener((UnityAction<int>)delegate(int index)
			{
				Plugin.CustomConfig.NightFog = int.Parse(dropdown.options[index].text.Replace("%", ""));
				PlayerPrefs.SetInt("GAME_SETTINGS_NIGHT_FOG", index);
			});
			if (PlayerPrefs.HasKey("GAME_SETTINGS_NIGHT_FOG"))
			{
				int @int = PlayerPrefs.GetInt("GAME_SETTINGS_NIGHT_FOG");
				if (@int < dropdown.options.Count)
				{
					dropdown.SetValueWithoutNotify(@int);
				}
			}
		}

		public static void FillPotionToggle(Toggle potionToggle, Effect effect)
		{
			string playerPref = "GAME_SETTINGS_NALES_POTION_" + effect.GetTranslateKey();
			if (!PlayerPrefs.HasKey(playerPref))
			{
				PlayerPrefs.SetInt(playerPref, 1);
			}
			((UnityEventBase)potionToggle.onValueChanged).RemoveAllListeners();
			((UnityEvent<bool>)(object)potionToggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value)
			{
				Plugin.CustomConfig.PotionsAvailability[effect.GetTranslateKey()] = value;
				PlayerPrefs.SetInt(playerPref, value ? 1 : 0);
			});
			if (PlayerPrefs.HasKey(playerPref) && PlayerPrefs.GetInt(playerPref) == 1)
			{
				PotionsConfig[effect.GetTranslateKey()].SetIsOnWithoutNotify(true);
			}
		}

		public static void FillGadgetToggle(Toggle gadgetToggle, string itemKey)
		{
			string playerPref = "GAME_SETTINGS_" + itemKey;
			if (!PlayerPrefs.HasKey(playerPref))
			{
				PlayerPrefs.SetInt(playerPref, 1);
			}
			((UnityEventBase)gadgetToggle.onValueChanged).RemoveAllListeners();
			((UnityEvent<bool>)(object)gadgetToggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value)
			{
				Plugin.CustomConfig.GadgetsAvailability[itemKey] = value;
				PlayerPrefs.SetInt(playerPref, value ? 1 : 0);
			});
			if (PlayerPrefs.HasKey(playerPref) && PlayerPrefs.GetInt(playerPref) == 1)
			{
				GadgetsConfig[itemKey].SetIsOnWithoutNotify(true);
			}
		}

		public void ResetToDefault()
		{
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			SoloRolesCountConfig.value = 1;
			TraitorsCountConfig.value = 0;
			WolfPowersCountConfig.value = 3;
			VillagerPowersChanceConfig.value = 10;
			SecondaryRolesCountConfig.value = 15;
			PlayerPrefs.SetInt("GAME_SETTINGS_SOLO_ROLES_COUNT", 1);
			PlayerPrefs.SetInt("GAME_SETTINGS_TRAITORS_COUNT", 0);
			PlayerPrefs.SetInt("GAME_SETTINGS_PRIMARY_ROLE_POWERS_COUNT", 3);
			PlayerPrefs.SetInt("GAME_SETTINGS_VILLAGER_PRIMARY_ROLE_POWERS_CHANCE", 10);
			PlayerPrefs.SetInt("GAME_SETTINGS_SECONDARY_ROLES_COUNT", 15);
			foreach (KeyValuePair<PlayerCustom.PlayerNewPrimaryRole, Toggle> item in SoloRolesConfig)
			{
				item.Value.isOn = true;
				PlayerPrefs.SetInt("GAME_SETTINGS_NALES_ROLE_" + item.Key, 1);
			}
			foreach (KeyValuePair<PlayerCustom.PlayerPrimaryRolePower, Toggle> item2 in PrimaryRolePowerConfig)
			{
				item2.Value.isOn = true;
				PlayerPrefs.SetInt("GAME_SETTINGS_NALES_ROLE_" + item2.Key, 1);
			}
			foreach (KeyValuePair<PlayerCustom.PlayerSecondaryRole, Toggle> item3 in SecondaryRolesConfig)
			{
				item3.Value.isOn = true;
				PlayerPrefs.SetInt("GAME_SETTINGS_NALES_ROLE_" + item3.Key, 1);
			}
			TrapsModifiedToggle.SetIsOnWithoutNotify(true);
			PlayerPrefs.SetInt("GAME_SETTINGS_TRAPS_MODIFIED", 1);
			TrapsModified = NetworkBool.op_Implicit(true);
			AnonymousVotesToggle.SetIsOnWithoutNotify(false);
			PlayerPrefs.SetInt("GAME_SETTINGS_ANONYMOUS_VOTES", 0);
			AnonymousVotes = NetworkBool.op_Implicit(false);
			AmogusModeToggle.SetIsOnWithoutNotify(false);
			PlayerPrefs.SetInt("GAME_SETTINGS_AMOGUS_MODE", 0);
			AmogusMode = NetworkBool.op_Implicit(false);
			SabotagesAvailableToggle.SetIsOnWithoutNotify(true);
			PlayerPrefs.SetInt("GAME_SETTINGS_SABOTAGES_AVAILABLE", 1);
			SabotagesAvailable = NetworkBool.op_Implicit(true);
			DropItemsAvailableToggle.SetIsOnWithoutNotify(true);
			PlayerPrefs.SetInt("GAME_SETTINGS_DROP_ITEMS_AVAILABLE", 1);
			DropItemsAvailable = NetworkBool.op_Implicit(true);
			NightFogDropdown.value = 5;
			PlayerPrefs.SetInt("GAME_SETTINGS_NIGHT_FOG", 5);
			foreach (KeyValuePair<string, Toggle> item4 in PotionsConfig)
			{
				item4.Value.isOn = true;
				PlayerPrefs.SetInt("GAME_SETTINGS_NALES_POTION_" + item4.Key, 1);
			}
			foreach (KeyValuePair<string, Toggle> item5 in GadgetsConfig)
			{
				item5.Value.isOn = true;
				PlayerPrefs.SetInt("GAME_SETTINGS_" + item5.Key, 1);
			}
		}

		private static Toggle GetToggle(GameSettingsUI gameSettingsUI, string key, List<object> arguments, ConfigTypeEnum type, Color textColor)
		{
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			Toggle value = Traverse.Create((object)gameSettingsUI).Field<Toggle>("showAllyToggle").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);
			switch (type)
			{
			case ConfigTypeEnum.Roles: