Decompiled source of TaxmansOrders v0.1.0

TaxmansOrders.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TaxmansOrders")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("TaxmansOrders")]
[assembly: AssemblyTitle("TaxmansOrders")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 TaxmansOrders
{
	internal static class Chaos
	{
		internal static bool Active;

		private static float nextRefill;

		internal static void OnEnemyAmount(EnemyDirector director)
		{
			Active = false;
			QuestSelection.Roll();
			if (QuestSelection.Pending != Plugin.QuestType.Chaos)
			{
				return;
			}
			List<EnemySetup> list = new List<EnemySetup>();
			List<EnemySetup>[] array = new List<EnemySetup>[3] { director.enemiesDifficulty1, director.enemiesDifficulty2, director.enemiesDifficulty3 };
			foreach (List<EnemySetup> list2 in array)
			{
				if (list2 == null)
				{
					continue;
				}
				foreach (EnemySetup item2 in list2)
				{
					if ((Object)(object)item2 != (Object)null && item2.spawnObjects != null && item2.spawnObjects.Count > 0 && !list.Contains(item2))
					{
						list.Add(item2);
					}
				}
			}
			int totalAmount = director.totalAmount;
			int players;
			float num = EnemyMultiplier(out players);
			int num2 = Mathf.Max(0, Mathf.RoundToInt((float)totalAmount * (num - 1f)));
			for (int j = 0; j < num2; j++)
			{
				if (list.Count <= 0)
				{
					break;
				}
				EnemySetup item = list[Random.Range(0, list.Count)];
				director.enemyList.Add(item);
				director.enemyListCurrent.Add(item);
			}
			director.totalAmount += num2;
			Plugin.Log.LogInfo((object)$"TOTAL CHAOS: {totalAmount} + {num2} monster (x{num:0.#} för {players} spelare, bland {list.Count} typer).");
		}

		private static float EnemyMultiplier(out int players)
		{
			players = ((!SemiFunc.IsMultiplayer() || PhotonNetwork.CurrentRoom == null) ? 1 : PhotonNetwork.CurrentRoom.PlayerCount);
			return Mathf.Min(Plugin.ChaosEnemyBase.Value + Plugin.ChaosEnemyPerPlayer.Value * (float)players, Plugin.ChaosEnemyMax.Value);
		}

		internal static void Begin()
		{
			Apply();
			QuestNetwork.SendModifier(3);
			QuestDirector.Say("<b><color=#FF3030>TOTAL CHAOS</color></b>\nEvery monster in the catalogue is here. Several times over. Everyone gets three weapons. Ammo is on the house. <b>Survive.</b>");
			GiveWeapons();
		}

		internal static void Apply()
		{
			Active = true;
			Plugin.Log.LogInfo((object)"Nivåvillkor: TOTAL CHAOS.");
		}

		internal static void Reset()
		{
			Active = false;
		}

		private static void GiveWeapons()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Invalid comparison between Unknown and I4
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Invalid comparison between Unknown and I4
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			List<Item> list = new List<Item>();
			foreach (Item value in StatsManager.instance.itemDictionary.Values)
			{
				if (!((Object)(object)value == (Object)null) && !value.disabled && value.prefab != null && ((PrefabRef<GameObject>)(object)value.prefab).IsValid() && ((int)value.itemType == 9 || (int)value.itemType == 7 || (int)value.itemType == 15))
				{
					list.Add(value);
				}
			}
			if (list.Count == 0)
			{
				Plugin.Log.LogWarning((object)"Hittade inga vapen att dela ut.");
				return;
			}
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				if ((Object)(object)player == (Object)null || player.isDisabled)
				{
					continue;
				}
				List<string> list2 = new List<string>();
				for (int i = 0; i < Mathf.Max(1, Plugin.ChaosWeaponsPerPlayer.Value); i++)
				{
					Item val = list[Random.Range(0, list.Count)];
					Vector3 val2 = ((Component)player).transform.right * ((float)(i - 1) * 0.6f);
					Vector3 val3 = ((Component)player).transform.position + ((Component)player).transform.forward * 0.9f + val2 + Vector3.up * (1.2f + 0.3f * (float)i);
					Quaternion val4 = Quaternion.LookRotation(((Component)player).transform.forward) * val.spawnRotationOffset;
					if ((Object)(object)(SemiFunc.IsMultiplayer() ? PhotonNetwork.InstantiateRoomObject(((PrefabRef<GameObject>)(object)val.prefab).ResourcePath, val3, val4, (byte)0, (object[])null) : Object.Instantiate<GameObject>(((PrefabRef<GameObject>)(object)val.prefab).Prefab, val3, val4)) != (Object)null)
					{
						list2.Add(val.itemName);
					}
				}
				Plugin.Log.LogInfo((object)("Vapen till " + player.playerName + ": " + string.Join(", ", list2) + "."));
			}
		}

		internal static void HostTick()
		{
			if (!Active || Time.time < nextRefill)
			{
				return;
			}
			nextRefill = Time.time + 1f;
			ItemBattery[] array = Object.FindObjectsByType<ItemBattery>((FindObjectsSortMode)0);
			foreach (ItemBattery val in array)
			{
				if ((Object)(object)val != (Object)null && (Object)(object)val.itemAttributes != (Object)null && (val.batteryLife < 99f || val.batteryLifeInt < val.batteryBars))
				{
					val.SetBatteryLife(100);
				}
			}
		}
	}
	[HarmonyPatch(typeof(EnemyDirector), "AmountSetup")]
	internal static class ChaosAmountPatch
	{
		private static void Postfix(EnemyDirector __instance)
		{
			Chaos.OnEnemyAmount(__instance);
		}
	}
	[HarmonyPatch(typeof(EnemyParent), "Despawn")]
	internal static class ChaosOrbPatch
	{
		private static void Prefix(EnemyParent __instance)
		{
			if (Chaos.Active && (Object)(object)__instance.Enemy != (Object)null && (Object)(object)__instance.Enemy.Health != (Object)null)
			{
				__instance.Enemy.Health.spawnValuable = false;
			}
		}
	}
	[HarmonyPatch(typeof(ItemBattery), "Drain")]
	internal static class ChaosDrainPatch
	{
		private static bool Prefix()
		{
			return !Chaos.Active;
		}
	}
	[HarmonyPatch(typeof(ItemBattery), "RemoveFullBar")]
	internal static class ChaosBarPatch
	{
		private static bool Prefix()
		{
			return !Chaos.Active;
		}
	}
	internal sealed class GoldNugget : MonoBehaviour
	{
		private const float StuckMass = 400f;

		private const float StuckDrag = 20f;

		private const float CarryMass = 3f;

		private const float Scale = 1.6f;

		internal static GoldNugget Active;

		private static Material goldMaterial;

		private ValuableObject valuable;

		private PhysGrabObject grab;

		private int reward;

		private bool host;

		private bool delivered;

		private float nextCheck;

		private float haulGoalFixAt;

		internal static void StartQuest()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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)
			PrefabRef val = FindDiamond();
			if (val == null)
			{
				Plugin.Log.LogWarning((object)"Hittade ingen diamant att göra guldklump av.");
				return;
			}
			if (!FarthestFromTruck(out var position))
			{
				Plugin.Log.LogWarning((object)"Hittade ingen plats för guldklumpen.");
				return;
			}
			int num = Reward();
			Quaternion val2 = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f);
			GameObject val3 = (SemiFunc.IsMultiplayer() ? PhotonNetwork.InstantiateRoomObject(((PrefabRef<GameObject>)(object)val).ResourcePath, position, val2, (byte)0, (object[])null) : Object.Instantiate<GameObject>(((PrefabRef<GameObject>)(object)val).Prefab, position, val2));
			if ((Object)(object)val3 == (Object)null)
			{
				Plugin.Log.LogWarning((object)("Kunde inte spawna " + ((PrefabRef<GameObject>)(object)val).ResourcePath + "."));
				return;
			}
			ValuableObject component = val3.GetComponent<ValuableObject>();
			if ((Object)(object)component != (Object)null)
			{
				component.dollarValueOverride = num;
				if ((Object)(object)component.durabilityPreset != (Object)null)
				{
					Durability val4 = Object.Instantiate<Durability>(component.durabilityPreset);
					val4.fragility = Plugin.NuggetFragility.Value;
					val4.durability = 100f - Plugin.NuggetFragility.Value * 0.5f;
					component.durabilityPreset = val4;
				}
			}
			Setup(val3, num, host: true);
			PhotonView component2 = val3.GetComponent<PhotonView>();
			QuestNetwork.SendNugget(((Object)(object)component2 != (Object)null) ? component2.ViewID : 0, num);
			int num2 = MinGrabbers();
			Plugin.Log.LogInfo((object)$"Order: guldklump värd ${num} vid {position} ({((PrefabRef<GameObject>)(object)val).PrefabName}).");
			QuestDirector.Say($"<b>TAXMAN'S ORDERS:</b> pure <color=#FFC21A><b>GOLD</b></color> deep in here, worth <color=#FFC21A><b>${num / 1000}K</b></color>.\n" + $"Takes {num2} of you to drag. No cart. TRUCK only. Don't scratch it.");
		}

		internal static void Setup(GameObject go, int reward, bool host)
		{
			GoldNugget obj = go.GetComponent<GoldNugget>() ?? go.AddComponent<GoldNugget>();
			obj.reward = reward;
			obj.host = host;
			obj.haulGoalFixAt = Time.time + 2f;
			Active = obj;
			obj.MakeGold();
		}

		private static int Reward()
		{
			return Mathf.Clamp(Mathf.RoundToInt((float)RoundDirector.instance.haulGoal * Plugin.NuggetRewardMultiplier.Value / 1000f) * 1000, Plugin.NuggetMinReward.Value, Mathf.Max(Plugin.NuggetMinReward.Value, Plugin.NuggetMaxReward.Value));
		}

		internal static int MinGrabbers()
		{
			if (!Plugin.Testing(Plugin.QuestType.GoldNugget))
			{
				return Mathf.Max(1, Plugin.NuggetMinGrabbers.Value);
			}
			return 1;
		}

		private static PrefabRef FindDiamond()
		{
			PrefabRef val = null;
			foreach (Level level in RunManager.instance.levels)
			{
				if ((Object)(object)level == (Object)null || level.ValuablePresets == null)
				{
					continue;
				}
				foreach (LevelValuables valuablePreset in level.ValuablePresets)
				{
					if ((Object)(object)valuablePreset == (Object)null)
					{
						continue;
					}
					List<PrefabRef>[] array = new List<PrefabRef>[2] { valuablePreset.tiny, valuablePreset.small };
					foreach (List<PrefabRef> list in array)
					{
						if (list == null)
						{
							continue;
						}
						foreach (PrefabRef item in list)
						{
							if (item != null && ((PrefabRef<GameObject>)(object)item).IsValid())
							{
								if (((PrefabRef<GameObject>)(object)item).PrefabName.ToLowerInvariant().Contains("diamond"))
								{
									return item;
								}
								if (val == null && list == valuablePreset.tiny)
								{
									val = item;
								}
							}
						}
					}
				}
			}
			return val;
		}

		private static bool FarthestFromTruck(out Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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_0105: Unknown result type (might be due to invalid IL or missing references)
			position = Vector3.zero;
			List<LevelPoint> levelPathPoints = LevelGenerator.Instance.LevelPathPoints;
			if (levelPathPoints == null || levelPathPoints.Count == 0)
			{
				return false;
			}
			Vector3 val = (((Object)(object)PlayerAvatar.instance != (Object)null) ? ((Component)PlayerAvatar.instance).transform.position : Vector3.zero);
			foreach (LevelPoint item in levelPathPoints)
			{
				if ((Object)(object)item != (Object)null && item.Truck)
				{
					val = ((Component)item).transform.position;
					break;
				}
			}
			float num = -1f;
			foreach (LevelPoint item2 in levelPathPoints)
			{
				if (!((Object)(object)item2 == (Object)null) && !item2.Truck && !item2.inStartRoom)
				{
					float num2 = Vector3.Distance(((Component)item2).transform.position, val);
					if (num2 > num)
					{
						num = num2;
						position = ((Component)item2).transform.position + Vector3.up * 0.6f;
					}
				}
			}
			return num > 0f;
		}

		private void MakeGold()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			valuable = ((Component)this).GetComponent<ValuableObject>();
			grab = ((Component)this).GetComponent<PhysGrabObject>();
			Transform transform = ((Component)this).transform;
			transform.localScale *= 1.6f;
			if ((Object)(object)goldMaterial == (Object)null)
			{
				goldMaterial = new Material(Shader.Find("Standard"))
				{
					name = "TaxmansOrders Gold"
				};
				goldMaterial.color = new Color(1f, 0.74f, 0.16f);
				if (goldMaterial.HasProperty("_Metallic"))
				{
					goldMaterial.SetFloat("_Metallic", 1f);
				}
				if (goldMaterial.HasProperty("_Glossiness"))
				{
					goldMaterial.SetFloat("_Glossiness", 0.88f);
				}
				if (goldMaterial.HasProperty("_EmissionColor"))
				{
					goldMaterial.EnableKeyword("_EMISSION");
					goldMaterial.SetColor("_EmissionColor", new Color(0.75f, 0.48f, 0.05f));
				}
			}
			MeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<MeshRenderer>(true);
			foreach (MeshRenderer val in componentsInChildren)
			{
				Material[] sharedMaterials = ((Renderer)val).sharedMaterials;
				for (int j = 0; j < sharedMaterials.Length; j++)
				{
					sharedMaterials[j] = goldMaterial;
				}
				((Renderer)val).sharedMaterials = sharedMaterials;
			}
			GameObject val2 = new GameObject("Gold Glow");
			val2.transform.SetParent(((Component)this).transform, false);
			Light obj = val2.AddComponent<Light>();
			obj.type = (LightType)2;
			obj.color = new Color(1f, 0.75f, 0.25f);
			obj.range = 6f;
			obj.intensity = 3f;
			obj.shadows = (LightShadows)0;
		}

		private void Update()
		{
			if ((Object)(object)grab == (Object)null)
			{
				return;
			}
			int num = Grabbers();
			int num2 = MinGrabbers();
			if (num < num2 || ((Object)(object)grab.impactDetector != (Object)null && (Object)(object)grab.impactDetector.currentCart != (Object)null))
			{
				grab.OverrideMass(400f, 0.2f);
				grab.OverrideDrag(20f, 0.2f);
			}
			else
			{
				grab.OverrideMass(3f, 0.2f);
			}
			ShowHint(num, num2);
			if (!host)
			{
				return;
			}
			if (haulGoalFixAt > 0f && Time.time >= haulGoalFixAt && (Object)(object)valuable != (Object)null && valuable.dollarValueSet)
			{
				haulGoalFixAt = 0f;
				RoundDirector.instance.haulGoalMax = Mathf.Max(0, RoundDirector.instance.haulGoalMax - (int)valuable.dollarValueOriginal);
			}
			if (!delivered && Time.time >= nextCheck)
			{
				nextCheck = Time.time + 0.25f;
				if ((Object)(object)valuable != (Object)null && (Object)(object)valuable.roomVolumeCheck != (Object)null && valuable.roomVolumeCheck.inTruck)
				{
					Deliver();
				}
			}
		}

		private int Grabbers()
		{
			HashSet<PlayerAvatar> hashSet = new HashSet<PlayerAvatar>();
			foreach (PhysGrabber item in grab.playerGrabbing)
			{
				if ((Object)(object)item != (Object)null && (Object)(object)item.playerAvatar != (Object)null)
				{
					hashSet.Add(item.playerAvatar);
				}
			}
			return hashSet.Count;
		}

		private void ShowHint(int grabbers, int need)
		{
			PlayerAvatar instance = PlayerAvatar.instance;
			if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.physGrabber == (Object)null) && !((Object)(object)ItemInfoUI.instance == (Object)null) && grab.playerGrabbing.Contains(instance.physGrabber))
			{
				string text = (((Object)(object)valuable != (Object)null) ? $"${Mathf.RoundToInt(valuable.dollarValueCurrent / 1000f)}K" : "");
				ItemInfoUI.instance.ItemInfoText((ItemAttributes)null, (grabbers < need) ? $"<color=#FFC21A>Gold</color> {text} - too heavy! <color=#FFFFFF>{grabbers}/{need}</color> players" : ("<color=#FFC21A>Gold</color> " + text + " - to the TRUCK!"), false);
			}
		}

		private void Deliver()
		{
			delivered = true;
			int num = (((Object)(object)valuable != (Object)null) ? Mathf.RoundToInt(valuable.dollarValueCurrent) : reward);
			int num2 = Mathf.Max(1, Mathf.RoundToInt((float)num / 1000f));
			SemiFunc.StatSetRunCurrency(SemiFunc.StatGetRunCurrency() + num2);
			int num3 = Mathf.RoundToInt(100f * (float)num / (float)Mathf.Max(1, reward));
			Plugin.Log.LogInfo((object)$"Guldklumpen levererad: ${num} ({num3} % av ${reward}).");
			QuestDirector.Say($"<b>ORDER COMPLETE</b>\nThe gold made it! <color=#00FF00><b>+${num2}K</b></color> for the shop." + ((num3 < 100) ? $" ({num3}% left after you dropped it everywhere.)" : " Not a scratch. Impressive."));
			if ((Object)(object)grab != (Object)null)
			{
				grab.DestroyPhysGrabObject();
			}
		}

		private void OnDestroy()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Active == (Object)(object)this)
			{
				Active = null;
			}
			if (!((Object)(object)GameDirector.instance != (Object)null) || (int)GameDirector.instance.currentState != 2)
			{
				return;
			}
			if ((Object)(object)valuable != (Object)null && (Object)(object)valuable.roomVolumeCheck != (Object)null && valuable.roomVolumeCheck.inTruck)
			{
				GameObject val = (((Object)(object)AssetManager.instance != (Object)null) ? AssetManager.instance.prefabTeleportEffect : null);
				if ((Object)(object)val != (Object)null)
				{
					Object.Instantiate<GameObject>(val, ((Component)this).transform.position, Quaternion.identity).transform.localScale = Vector3.one * 2f;
				}
			}
			else if (host && !delivered)
			{
				Plugin.Log.LogInfo((object)"Guldklumpen förstördes.");
				QuestDirector.Say("<b>ORDER FAILED</b>\nYou broke the gold. Solid gold. How.");
			}
		}
	}
	[HarmonyPatch(typeof(ValuableObject), "AddToDollarHaulList")]
	internal static class HaulListPatch
	{
		private static float lastWarning;

		private static bool Prefix(ValuableObject __instance)
		{
			if ((Object)(object)((Component)__instance).GetComponent<GoldNugget>() == (Object)null)
			{
				return true;
			}
			if (Time.time - lastWarning > 30f)
			{
				lastWarning = Time.time;
				QuestDirector.Say("The gold doesn't go in the extraction. TRUCK. Bring it to the TRUCK.");
			}
			return false;
		}
	}
	internal static class Imposter
	{
		private static string imposterName;

		private static int missionsDone;

		private static bool exploded;

		private static bool revealed;

		internal static void StartQuest()
		{
			List<PlayerAvatar> list = new List<PlayerAvatar>();
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				if ((Object)(object)player != (Object)null && !player.isDisabled && !player.deadSet)
				{
					list.Add(player);
				}
			}
			if (list.Count != 0)
			{
				PlayerAvatar val = (Plugin.Testing(Plugin.QuestType.Imposter) ? PlayerAvatar.instance : list[Random.Range(0, list.Count)]);
				imposterName = val.playerName;
				missionsDone = 0;
				exploded = false;
				revealed = false;
				Plugin.Log.LogInfo((object)("Order: imposter är " + imposterName + "."));
				QuestDirector.Say("<b>TAXMAN'S ORDERS</b>\nThere is an <color=#FF2020><b>IMPOSTER</b></color> among you. They know who they are. You don't. Have a nice shift.");
				if ((Object)(object)val == (Object)(object)PlayerAvatar.instance)
				{
					BecomeImposter();
				}
				else
				{
					QuestNetwork.SendImposterRole(val);
				}
			}
		}

		internal static void BecomeImposter()
		{
			if ((Object)(object)QuestDirector.Instance != (Object)null && (Object)(object)((Component)QuestDirector.Instance).GetComponent<ImposterRole>() == (Object)null)
			{
				((Component)QuestDirector.Instance).gameObject.AddComponent<ImposterRole>();
			}
		}

		internal static void Report(int done, bool boom)
		{
			missionsDone = Mathf.Max(missionsDone, done);
			exploded |= boom;
		}

		internal static void HostTick()
		{
			if (imposterName != null && !revealed && !((Object)(object)RoundDirector.instance == (Object)null) && RoundDirector.instance.allExtractionPointsCompleted)
			{
				revealed = true;
				string text = (exploded ? "Failed the secret mission and went <b>BOOM</b>." : ((missionsDone > 0) ? "Completed the secret mission and nobody noticed. Well played." : "Never even got to do anything. Disappointing."));
				QuestDirector.Say("<b>IMPOSTER REVEALED</b>\nIt was <color=#FF2020><b>" + imposterName + "</b></color> all along. " + text);
			}
		}

		internal static void Reset()
		{
			imposterName = null;
		}

		internal static void Explosion(Vector3 position)
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Resources.Load<GameObject>("Effects/Part Prefab Explosion");
			ExplosionPreset val2 = null;
			ExplosionPreset[] array = Resources.FindObjectsOfTypeAll<ExplosionPreset>();
			int num = 0;
			if (num < array.Length)
			{
				val2 = array[num];
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			if ((Object)(object)val2 != (Object)null)
			{
				GameObject val3 = new GameObject("TaxmansOrders Explosion");
				ParticleScriptExplosion obj = val3.AddComponent<ParticleScriptExplosion>();
				obj.explosionPreset = val2;
				obj.explosionPrefab = val;
				obj.Spawn(position, 1f, 0, 0, 1f, true, false, 1f, 0f);
				Object.Destroy((Object)val3, 1f);
				return;
			}
			ParticlePrefabExplosion component = Object.Instantiate<GameObject>(val, position, Quaternion.identity).GetComponent<ParticlePrefabExplosion>();
			if ((Object)(object)component != (Object)null)
			{
				component.explosionSize = 1f;
				component.explosionDamage = 0;
				component.explosionDamageEnemy = 0;
				component.particleFire.Play();
				component.particleSmoke.Play();
				((Behaviour)component.light).enabled = true;
			}
			GameDirector.instance.CameraShake.ShakeDistance(5f, 6f, 12f, position, 0.5f);
		}

		internal static bool SaysTheWord(string message)
		{
			return ForbiddenWord.Matches(message);
		}
	}
	internal static class ForbiddenWord
	{
		private static readonly string[] Words = new string[23]
		{
			"imposter", "impostor", "imposteur", "impostore", "impostora", "bedragare", "bedrager", "bedrieger", "hochstapler", "betruger",
			"huijari", "oszust", "traitor", "forradare", "forraeder", "verrater", "traidor", "traitre", "traditore", "zdrajca",
			"petturi", "самозванец", "предатель"
		};

		private static string[] normalized;

		internal static bool Matches(string message)
		{
			if (string.IsNullOrEmpty(message))
			{
				return false;
			}
			if (normalized == null)
			{
				normalized = Array.ConvertAll(Words, (string w) => Collapse(Normalize(w)));
			}
			string input = Normalize(message);
			string text = Collapse(Regex.Replace(input, "[^\\p{L}]", ""));
			if (text.Contains("impost") || text.Contains("imposd"))
			{
				return true;
			}
			string[] array = Regex.Split(input, "[^\\p{L}]+");
			for (int num = 0; num < array.Length; num++)
			{
				if (array[num].Length != 0)
				{
					if (Close(Collapse(array[num])))
					{
						return true;
					}
					if (num + 1 < array.Length && Close(Collapse(array[num] + array[num + 1])))
					{
						return true;
					}
				}
			}
			return false;
		}

		private static bool Close(string token)
		{
			if (token.Length < 5)
			{
				return false;
			}
			string[] array = normalized;
			foreach (string text in array)
			{
				int num = ((text.Length < 8) ? 1 : 2);
				if (Math.Abs(token.Length - text.Length) <= num && Distance(token, text) <= num)
				{
					return true;
				}
			}
			return false;
		}

		private static string Normalize(string s)
		{
			StringBuilder stringBuilder = new StringBuilder(s.Length);
			string text = s.ToLowerInvariant();
			for (int i = 0; i < text.Length; i++)
			{
				char c = text[i];
				switch (c)
				{
				case '0':
					stringBuilder.Append('o');
					continue;
				case '!':
				case '1':
				case '|':
					stringBuilder.Append('i');
					continue;
				case '3':
					stringBuilder.Append('e');
					continue;
				case '4':
				case '@':
					stringBuilder.Append('a');
					continue;
				case '$':
				case '5':
					stringBuilder.Append('s');
					continue;
				case '7':
					stringBuilder.Append('t');
					continue;
				case 'æ':
					stringBuilder.Append("ae");
					continue;
				case 'ø':
					stringBuilder.Append('o');
					continue;
				case 'ß':
					stringBuilder.Append("ss");
					continue;
				}
				string text2 = c.ToString().Normalize(NormalizationForm.FormD);
				foreach (char c2 in text2)
				{
					if (CharUnicodeInfo.GetUnicodeCategory(c2) != UnicodeCategory.NonSpacingMark)
					{
						stringBuilder.Append(c2);
					}
				}
			}
			return stringBuilder.ToString();
		}

		private static string Collapse(string s)
		{
			StringBuilder stringBuilder = new StringBuilder(s.Length);
			foreach (char c in s)
			{
				if (stringBuilder.Length == 0 || stringBuilder[stringBuilder.Length - 1] != c)
				{
					stringBuilder.Append(c);
				}
			}
			return stringBuilder.ToString();
		}

		private static int Distance(string a, string b)
		{
			int[,] array = new int[a.Length + 1, b.Length + 1];
			for (int i = 0; i <= a.Length; i++)
			{
				array[i, 0] = i;
			}
			for (int j = 0; j <= b.Length; j++)
			{
				array[0, j] = j;
			}
			for (int k = 1; k <= a.Length; k++)
			{
				for (int l = 1; l <= b.Length; l++)
				{
					int num = ((a[k - 1] != b[l - 1]) ? 1 : 0);
					array[k, l] = Math.Min(Math.Min(array[k - 1, l] + 1, array[k, l - 1] + 1), array[k - 1, l - 1] + num);
				}
			}
			return array[a.Length, b.Length];
		}
	}
	internal sealed class ImposterRole : MonoBehaviour
	{
		private enum Mission
		{
			None,
			Kill,
			Destroy,
			Stall,
			Monsters
		}

		private Mission mission;

		private Mission previous;

		private float countdownEnd;

		private float missionEnd;

		private int missionsDone;

		private bool dead;

		private int destroyTarget;

		private float destroyed;

		private int monstersNeeded;

		private float monsterSecondsNeeded;

		private float monsterSeconds;

		private readonly HashSet<PlayerAvatar> deadAtStart = new HashSet<PlayerAvatar>();

		private ImposterHud hud;

		internal static ImposterRole Instance;

		private bool finished;

		private float Delay
		{
			get
			{
				if (!Plugin.Testing(Plugin.QuestType.Imposter))
				{
					return Plugin.ImposterFirstMissionSeconds.Value;
				}
				return 15f;
			}
		}

		private float MissionTime
		{
			get
			{
				if (Plugin.Testing(Plugin.QuestType.Imposter))
				{
					return 60f;
				}
				int num = (((Object)(object)RunManager.instance != (Object)null) ? RunManager.instance.levelsCompleted : 0);
				return Mathf.Min(Plugin.ImposterMissionSeconds.Value + Plugin.ImposterMissionSecondsPerLevel.Value * (float)num, Mathf.Max(Plugin.ImposterMissionSeconds.Value, Plugin.ImposterMissionSecondsMax.Value));
			}
		}

		private void Awake()
		{
			Instance = this;
			hud = new ImposterHud();
			countdownEnd = Time.time + Delay;
			Plugin.Log.LogInfo((object)"Du är impostern.");
		}

		private void OnDestroy()
		{
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
			hud.Destroy();
		}

		private void Update()
		{
			PlayerAvatar instance = PlayerAvatar.instance;
			if (dead || (Object)(object)instance == (Object)null)
			{
				hud.Hide();
				return;
			}
			if (instance.deadSet || instance.isDisabled)
			{
				dead = true;
				hud.Hide();
				return;
			}
			bool flag = (Object)(object)RoundDirector.instance != (Object)null && RoundDirector.instance.allExtractionPointsCompleted;
			if (finished)
			{
				hud.Show("<color=#FF2020><b>IMPOSTER</b></color>", "Mission complete. You're safe. Act natural.");
				return;
			}
			if (mission == Mission.None)
			{
				if (flag)
				{
					hud.Show("<color=#FF2020><b>IMPOSTER</b></color>", "No more missions. Act natural.");
					return;
				}
				float num = countdownEnd - Time.time;
				hud.Show("<color=#FF2020><b>IMPOSTER</b></color>", "Mission received in <b>" + Clock(num) + "</b>\nNever say the word. Not even in chat.");
				if (num <= 0f)
				{
					Assign();
				}
				return;
			}
			float num2 = missionEnd - Time.time;
			switch (mission)
			{
			case Mission.Kill:
				if (OtherDied())
				{
					Complete();
					return;
				}
				hud.Show(Title(num2), "Kill a teammate. Any way you can.");
				break;
			case Mission.Destroy:
				if (destroyed >= (float)destroyTarget)
				{
					Complete();
					return;
				}
				hud.Show(Title(num2), $"Break valuables worth <b>${destroyTarget / 1000}K</b>  ({Money(destroyed)} / {Money(destroyTarget)})\nOnly things you held count.");
				break;
			case Mission.Stall:
				if (flag)
				{
					Explode("they finished too early");
				}
				else if (num2 <= 0f)
				{
					Complete();
				}
				else
				{
					hud.Show(Title(num2), "Stall them. The last extraction must NOT be done before the timer runs out.");
				}
				return;
			case Mission.Monsters:
				if (MonstersNearTeam() >= monstersNeeded)
				{
					monsterSeconds += Time.deltaTime;
				}
				if (monsterSeconds >= monsterSecondsNeeded)
				{
					Complete();
					return;
				}
				hud.Show(Title(num2), string.Format("Keep {0} monster{1} close to the team  ({2:0}/{3:0} s)", monstersNeeded, (monstersNeeded > 1) ? "s" : "", monsterSeconds, monsterSecondsNeeded));
				break;
			}
			if (num2 <= 0f)
			{
				Explode("ran out of time");
			}
		}

		private void Assign()
		{
			bool num = (Object)(object)RoundDirector.instance != (Object)null && RoundDirector.instance.allExtractionPointsCompleted;
			List<Mission> list = new List<Mission>();
			if (OthersAlive() > 0)
			{
				list.Add(Mission.Kill);
			}
			list.Add(Mission.Destroy);
			if (!num)
			{
				list.Add(Mission.Stall);
			}
			if ((Object)(object)EnemyDirector.instance != (Object)null && EnemyDirector.instance.enemiesSpawned != null && EnemyDirector.instance.enemiesSpawned.Count > 0)
			{
				list.Add(Mission.Monsters);
			}
			if (list.Count > 1)
			{
				list.Remove(previous);
			}
			mission = list[Random.Range(0, list.Count)];
			previous = mission;
			missionEnd = Time.time + MissionTime;
			int num2 = ((!((Object)(object)RunManager.instance != (Object)null)) ? 1 : (RunManager.instance.levelsCompleted + 1));
			switch (mission)
			{
			case Mission.Kill:
				deadAtStart.Clear();
				foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
				{
					if ((Object)(object)player != (Object)null && player.deadSet)
					{
						deadAtStart.Add(player);
					}
				}
				break;
			case Mission.Destroy:
				destroyTarget = Mathf.Clamp(num2, 1, 5) * 1000;
				destroyed = 0f;
				break;
			case Mission.Monsters:
				monstersNeeded = ((num2 < 5) ? 1 : 2);
				monsterSecondsNeeded = (Plugin.Testing(Plugin.QuestType.Imposter) ? 10f : 30f);
				monsterSeconds = 0f;
				break;
			}
			Plugin.Log.LogInfo((object)$"Imposter-uppdrag: {mission}.");
			AudioScare instance = AudioScare.instance;
			if (instance != null)
			{
				instance.PlayImpact();
			}
		}

		private void Complete()
		{
			missionsDone++;
			Plugin.Log.LogInfo((object)$"Imposter-uppdrag klart: {mission} ({missionsDone} totalt).");
			mission = Mission.None;
			finished = true;
			QuestNetwork.SendImposterStatus(missionsDone, exploded: false);
		}

		internal void Explode(string reason)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			if (!dead && !finished)
			{
				dead = true;
				hud.Hide();
				PlayerAvatar instance = PlayerAvatar.instance;
				Plugin.Log.LogInfo((object)("Impostern exploderar: " + reason + "."));
				QuestNetwork.SendImposterStatus(missionsDone, exploded: true);
				Vector3 val = (((Object)(object)instance.PlayerVisionTarget != (Object)null) ? instance.PlayerVisionTarget.VisionTransform.position : (((Component)instance).transform.position + Vector3.up));
				QuestNetwork.SendExplosion(val);
				Imposter.Explosion(val);
				instance.playerHealth.Hurt(instance.playerHealth.health, false, -1, false);
			}
		}

		internal void ValueLost(PhysGrabObjectImpactDetector impact, float valueLost)
		{
			if (mission == Mission.Destroy && !((Object)(object)impact == (Object)null) && !((Object)(object)impact.physGrabObject == (Object)null) && (Object)(object)impact.physGrabObject.lastPlayerGrabbing == (Object)(object)PlayerAvatar.instance)
			{
				destroyed += valueLost;
			}
		}

		private bool OtherDied()
		{
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				if ((Object)(object)player != (Object)null && (Object)(object)player != (Object)(object)PlayerAvatar.instance && player.deadSet && !deadAtStart.Contains(player))
				{
					return true;
				}
			}
			return false;
		}

		private static int OthersAlive()
		{
			int num = 0;
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				if ((Object)(object)player != (Object)null && (Object)(object)player != (Object)(object)PlayerAvatar.instance && !player.isDisabled && !player.deadSet)
				{
					num++;
				}
			}
			return num;
		}

		private static int MonstersNearTeam()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			foreach (EnemyParent item in EnemyDirector.instance.enemiesSpawned)
			{
				if ((Object)(object)item == (Object)null || !item.Spawned || (Object)(object)item.Enemy == (Object)null)
				{
					continue;
				}
				Vector3 position = ((Component)item.Enemy).transform.position;
				foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
				{
					if ((Object)(object)player != (Object)null && !player.isDisabled && !player.deadSet && Vector3.Distance(((Component)player).transform.position, position) <= 10f)
					{
						num++;
						break;
					}
				}
			}
			return num;
		}

		private static string Title(float remaining)
		{
			return "<color=#FF2020><b>IMPOSTER MISSION</b></color>  <b>" + Clock(remaining) + "</b>";
		}

		private static string Clock(float seconds)
		{
			int num = Mathf.Max(0, Mathf.CeilToInt(seconds));
			return $"{num / 60:00}:{num % 60:00}";
		}

		private static string Money(float dollars)
		{
			return $"${dollars / 1000f:0.0}K";
		}
	}
	[HarmonyPatch(typeof(PlayerAvatar), "ChatMessageSend")]
	internal static class ImposterChatPatch
	{
		private static void Prefix(PlayerAvatar __instance, string _message)
		{
			if ((Object)(object)__instance == (Object)(object)PlayerAvatar.instance && (Object)(object)ImposterRole.Instance != (Object)null && Imposter.SaysTheWord(_message))
			{
				ImposterRole.Instance.Explode("said the word");
			}
		}
	}
	[HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "BreakRPC")]
	internal static class ImposterBreakPatch
	{
		private static void Prefix(PhysGrabObjectImpactDetector __instance, float valueLost)
		{
			if ((Object)(object)ImposterRole.Instance != (Object)null && __instance.isValuable)
			{
				ImposterRole.Instance.ValueLost(__instance, valueLost);
			}
		}
	}
	internal sealed class ImposterHud
	{
		private GameObject canvas;

		private TextMeshProUGUI text;

		internal void Show(string title, string body)
		{
			if (!((Object)(object)canvas == (Object)null) || Create())
			{
				canvas.SetActive(true);
				((TMP_Text)text).text = title + "\n<size=80%>" + body + "</size>";
			}
		}

		internal void Hide()
		{
			if ((Object)(object)canvas != (Object)null)
			{
				canvas.SetActive(false);
			}
		}

		internal void Destroy()
		{
			if ((Object)(object)canvas != (Object)null)
			{
				Object.Destroy((Object)(object)canvas);
			}
		}

		private bool Create()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0046: 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_0078: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			canvas = new GameObject("TaxmansOrders Imposter HUD");
			Canvas obj = canvas.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 60;
			CanvasScaler obj2 = canvas.AddComponent<CanvasScaler>();
			obj2.uiScaleMode = (ScaleMode)1;
			obj2.referenceResolution = new Vector2(1920f, 1080f);
			obj2.matchWidthOrHeight = 0.5f;
			GameObject val = new GameObject("Text", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(canvas.transform, false);
			text = val.AddComponent<TextMeshProUGUI>();
			TextMeshProUGUI val2 = Object.FindAnyObjectByType<TextMeshProUGUI>();
			if ((Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)text && (Object)(object)((TMP_Text)val2).font != (Object)null)
			{
				((TMP_Text)text).font = ((TMP_Text)val2).font;
			}
			((TMP_Text)text).fontSize = 30f;
			((TMP_Text)text).alignment = (TextAlignmentOptions)258;
			((Graphic)text).color = Color.white;
			((TMP_Text)text).outlineWidth = 0.2f;
			((TMP_Text)text).outlineColor = Color32.op_Implicit(Color.black);
			((Graphic)text).raycastTarget = false;
			RectTransform rectTransform = ((TMP_Text)text).rectTransform;
			rectTransform.anchorMin = new Vector2(0.5f, 1f);
			rectTransform.anchorMax = new Vector2(0.5f, 1f);
			rectTransform.pivot = new Vector2(0.5f, 1f);
			rectTransform.anchoredPosition = new Vector2(0f, -110f);
			rectTransform.sizeDelta = new Vector2(1000f, 200f);
			return true;
		}
	}
	internal sealed class LevelModifier : MonoBehaviour
	{
		internal enum Kind
		{
			None,
			Glass,
			Rubber
		}

		internal static LevelModifier Instance;

		private static PhysicsMaterial rubber;

		private readonly HashSet<PhysGrabObject> done = new HashSet<PhysGrabObject>();

		private float nextScan;

		private float fallVelocity;

		private bool wasGrounded = true;

		internal static Kind Active { get; private set; }

		internal static void StartGlass()
		{
			Begin(Kind.Glass);
			QuestDirector.Say("<b>TAXMAN'S ORDERS</b>\nEverything here is made of <color=#9FE8FF><b>GLASS</b></color> today. Breathe on it and it breaks. Good luck.");
		}

		internal static void StartRubber()
		{
			Begin(Kind.Rubber);
			QuestDirector.Say("<b>TAXMAN'S ORDERS</b>\nEverything is <color=#FF5FD2><b>RUBBER</b></color> today. Nothing breaks. Everything bounces. <b>Including you.</b>");
		}

		private static void Begin(Kind kind)
		{
			Apply(kind);
			QuestNetwork.SendModifier((int)kind);
		}

		internal static void Apply(Kind kind)
		{
			Active = kind;
			Plugin.Log.LogInfo((object)$"Nivåvillkor: {kind}.");
			if ((Object)(object)QuestDirector.Instance != (Object)null && (Object)(object)((Component)QuestDirector.Instance).GetComponent<LevelModifier>() == (Object)null)
			{
				((Component)QuestDirector.Instance).gameObject.AddComponent<LevelModifier>();
			}
		}

		internal static void Reset()
		{
			Active = Kind.None;
		}

		private void Awake()
		{
			Instance = this;
		}

		private void OnDestroy()
		{
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
			Active = Kind.None;
		}

		private void Update()
		{
			if (Active == Kind.None)
			{
				return;
			}
			if (Time.time >= nextScan)
			{
				nextScan = Time.time + 2f;
				PhysGrabObject[] array = Object.FindObjectsByType<PhysGrabObject>((FindObjectsSortMode)0);
				foreach (PhysGrabObject val in array)
				{
					if ((Object)(object)val != (Object)null && done.Add(val))
					{
						Prepare(val);
					}
				}
			}
			if (Active != Kind.Rubber)
			{
				return;
			}
			foreach (PhysGrabObject item in done)
			{
				if ((Object)(object)item != (Object)null)
				{
					item.OverrideIndestructible(0.5f);
				}
			}
			PlayerAvatar instance = PlayerAvatar.instance;
			if ((Object)(object)instance != (Object)null)
			{
				instance.FallDamageResetSet(0.5f);
			}
		}

		private static void Prepare(PhysGrabObject obj)
		{
			PhysGrabObjectImpactDetector val = (((Object)(object)obj.impactDetector != (Object)null) ? obj.impactDetector : ((Component)obj).GetComponent<PhysGrabObjectImpactDetector>());
			if (Active == Kind.Glass)
			{
				if ((Object)(object)val != (Object)null && val.isValuable)
				{
					val.fragility = Plugin.GlassFragility.Value;
					val.durability = Plugin.GlassDurability.Value;
				}
			}
			else if (Active == Kind.Rubber)
			{
				MakeBouncy(((Component)obj).gameObject);
			}
		}

		private static void MakeBouncy(GameObject go)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			if ((Object)(object)rubber == (Object)null)
			{
				rubber = new PhysicsMaterial("TaxmansOrders Rubber")
				{
					bounciness = Mathf.Clamp01(Plugin.RubberBounciness.Value),
					bounceCombine = (PhysicsMaterialCombine)3,
					dynamicFriction = 0.25f,
					staticFriction = 0.3f,
					frictionCombine = (PhysicsMaterialCombine)2
				};
			}
			Collider[] componentsInChildren = go.GetComponentsInChildren<Collider>(true);
			foreach (Collider val in componentsInChildren)
			{
				if ((Object)(object)val != (Object)null && !val.isTrigger)
				{
					val.sharedMaterial = rubber;
				}
			}
		}

		private void FixedUpdate()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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)
			if (Active != Kind.Rubber)
			{
				return;
			}
			PlayerController instance = PlayerController.instance;
			PlayerAvatar instance2 = PlayerAvatar.instance;
			if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.rb == (Object)null) && !((Object)(object)instance2 == (Object)null) && !instance2.isDisabled && !instance2.deadSet && !((Object)(object)instance.CollisionController == (Object)null))
			{
				bool flag = instance.CollisionController.Grounded;
				float y = instance.rb.linearVelocity.y;
				if (!flag)
				{
					fallVelocity = Mathf.Min(fallVelocity, y);
				}
				else if (!wasGrounded && fallVelocity < 0f - Plugin.RubberMinBounceSpeed.Value)
				{
					float num = Mathf.Min((0f - fallVelocity) * Plugin.RubberPlayerBounce.Value, 30f);
					instance.rb.AddForce(Vector3.up * num - new Vector3(0f, y, 0f), (ForceMode)1);
					instance.CollisionGrounded.Grounded = false;
					instance.CollisionController.GroundedDisableTimer = 0.1f;
					instance.CollisionController.fallDistance = 0f;
					flag = false;
					fallVelocity = 0f;
				}
				if (flag)
				{
					fallVelocity = 0f;
				}
				wasGrounded = flag;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerTumble), "BreakImpact")]
	internal static class RubberTumblePatch
	{
		private static bool Prefix()
		{
			return LevelModifier.Active != LevelModifier.Kind.Rubber;
		}
	}
	[BepInPlugin("kinglir.taxmansorders", "TaxmansOrders", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal enum QuestType
		{
			None,
			GoldNugget,
			Imposter,
			Glass,
			Rubber,
			Chaos
		}

		public const string Guid = "kinglir.taxmansorders";

		public const string Name = "TaxmansOrders";

		public const string Version = "0.1.0";

		internal static ManualLogSource Log;

		internal static ConfigEntry<float> QuestChance;

		internal static ConfigEntry<bool> HideTaxmanChatter;

		internal static ConfigEntry<int> NuggetMinPlayers;

		internal static ConfigEntry<int> NuggetMinGrabbers;

		internal static ConfigEntry<float> NuggetRewardMultiplier;

		internal static ConfigEntry<int> NuggetMinReward;

		internal static ConfigEntry<int> NuggetMaxReward;

		internal static ConfigEntry<float> NuggetFragility;

		internal static ConfigEntry<QuestType> TestForceQuest;

		internal static ConfigEntry<bool> ChaosEnabled;

		internal static ConfigEntry<float> ChaosEnemyBase;

		internal static ConfigEntry<float> ChaosEnemyPerPlayer;

		internal static ConfigEntry<float> ChaosEnemyMax;

		internal static ConfigEntry<int> ChaosWeaponsPerPlayer;

		internal static ConfigEntry<bool> GlassEnabled;

		internal static ConfigEntry<bool> RubberEnabled;

		internal static ConfigEntry<float> GlassFragility;

		internal static ConfigEntry<float> GlassDurability;

		internal static ConfigEntry<float> RubberBounciness;

		internal static ConfigEntry<float> RubberPlayerBounce;

		internal static ConfigEntry<float> RubberMinBounceSpeed;

		internal static ConfigEntry<int> ImposterMinPlayers;

		internal static ConfigEntry<float> ImposterFirstMissionSeconds;

		internal static ConfigEntry<float> ImposterMissionSeconds;

		internal static ConfigEntry<float> ImposterMissionSecondsPerLevel;

		internal static ConfigEntry<float> ImposterMissionSecondsMax;

		internal static bool Testing(QuestType quest)
		{
			return TestForceQuest.Value == quest;
		}

		private void Awake()
		{
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			QuestChance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ChancePerScenario", 0.1f, "Chans (0-1) per scenario och nivå (högst ett per nivå). Ett scenario kommer inte tillbaka förrän två andra har förekommit.");
			HideTaxmanChatter = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "HideTaxmanChatter", true, "Döljer Taxmans vanliga repliker på lastbilsskärmen (överallt). Orders, HowTheyDied och spelarnas meddelanden syns som vanligt.");
			NuggetMinPlayers = ((BaseUnityPlugin)this).Config.Bind<int>("Gold Nugget", "MinPlayers", 3, "Guldklumpen väljs bara när minst så här många spelare är med.");
			NuggetMinGrabbers = ((BaseUnityPlugin)this).Config.Bind<int>("Gold Nugget", "MinGrabbers", 3, "Antal spelare som måste hålla i klumpen samtidigt för att den ska gå att flytta.");
			NuggetRewardMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Gold Nugget", "RewardMultiplier", 5f, "Belöning = nivåns kvot x detta (avrundat till hela tusental).");
			NuggetMinReward = ((BaseUnityPlugin)this).Config.Bind<int>("Gold Nugget", "MinReward", 25000, "Lägsta belöning i dollar.");
			NuggetMaxReward = ((BaseUnityPlugin)this).Config.Bind<int>("Gold Nugget", "MaxReward", 200000, "Högsta belöning i dollar.");
			NuggetFragility = ((BaseUnityPlugin)this).Config.Bind<float>("Gold Nugget", "Fragility", 60f, "Hur lätt klumpen tar skada (0-100, spelets skala). Skadan dras av från belöningen.");
			ImposterMinPlayers = ((BaseUnityPlugin)this).Config.Bind<int>("Imposter", "MinPlayers", 4, "Impostern väljs bara när minst så här många spelare är med.");
			ImposterFirstMissionSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Imposter", "FirstMissionSeconds", 300f, "Nedräkning (s) till imposterns första uppdrag.");
			ImposterMissionSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Imposter", "MissionSeconds", 360f, "Tid (s) för uppdraget på nivå 1. Misslyckas det exploderar impostern. Ett uppdrag per nivå.");
			ImposterMissionSecondsPerLevel = ((BaseUnityPlugin)this).Config.Bind<float>("Imposter", "MissionSecondsPerLevel", 60f, "Extra tid (s) per avklarad nivå (nivåerna blir större och svårare).");
			ImposterMissionSecondsMax = ((BaseUnityPlugin)this).Config.Bind<float>("Imposter", "MissionSecondsMax", 900f, "Längsta tid (s) för uppdraget.");
			ChaosEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Total Chaos", "Enabled", true, "TOTAL CHAOS kan väljas.");
			ChaosEnemyBase = ((BaseUnityPlugin)this).Config.Bind<float>("Total Chaos", "EnemyMultiplierBase", 2f, "Monstermultiplikator = bas + per spelare x antal spelare (alla monstertyper kan komma, oavsett nivå).");
			ChaosEnemyPerPlayer = ((BaseUnityPlugin)this).Config.Bind<float>("Total Chaos", "EnemyMultiplierPerPlayer", 1f, "Tillägg per spelare (standard: 1 spelare = x3, 2 = x4, 3 = x5).");
			ChaosEnemyMax = ((BaseUnityPlugin)this).Config.Bind<float>("Total Chaos", "EnemyMultiplierMax", 5f, "Tak för multiplikatorn.");
			ChaosWeaponsPerPlayer = ((BaseUnityPlugin)this).Config.Bind<int>("Total Chaos", "WeaponsPerPlayer", 3, "Antal slumpade vapen per spelare.");
			GlassEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Glass", "Enabled", true, "Glasnivån kan väljas.");
			RubberEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Rubber", "Enabled", true, "Gumminivån kan väljas.");
			GlassFragility = ((BaseUnityPlugin)this).Config.Bind<float>("Glass", "Fragility", 100f, "Glasnivå: hur lätt värdesaker går sönder (0-100, spelets skala).");
			GlassDurability = ((BaseUnityPlugin)this).Config.Bind<float>("Glass", "Durability", 15f, "Glasnivå: hur mycket värdesakerna tål (lägre = mer värde förloras per stöt).");
			RubberBounciness = ((BaseUnityPlugin)this).Config.Bind<float>("Rubber", "Bounciness", 0.95f, "Gumminivå: hur mycket föremål studsar (0-1).");
			RubberPlayerBounce = ((BaseUnityPlugin)this).Config.Bind<float>("Rubber", "PlayerBounce", 0.85f, "Gumminivå: hur högt spelare studsar tillbaka (andel av fallhastigheten).");
			RubberMinBounceSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Rubber", "MinBounceSpeed", 4f, "Gumminivå: lägsta fallhastighet (m/s) som ger en studs (vanliga steg studsar inte).");
			TestForceQuest = ((BaseUnityPlugin)this).Config.Bind<QuestType>("Debug", "TestForceQuest", QuestType.None, "Endast för test: tvinga fram detta scenario varje nivå, även ensam (guldklumpen: en spelare räcker; impostern: du, korta tider).");
			QuestNetwork.Register();
			new Harmony("kinglir.taxmansorders").PatchAll();
			Log.LogInfo((object)"TaxmansOrders 0.1.0 laddad.");
		}
	}
	internal sealed class QuestDirector : MonoBehaviour
	{
		internal static QuestDirector Instance;

		private readonly Queue<string> taxman = new Queue<string>();

		private float nextMessage;

		private bool chosen;

		private void Awake()
		{
			Instance = this;
			QuestNetwork.Register();
			Imposter.Reset();
			LevelModifier.Reset();
			Chaos.Reset();
		}

		private void OnDestroy()
		{
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}

		private void Update()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				if (!chosen && Ready())
				{
					chosen = true;
					Choose();
				}
				Imposter.HostTick();
				Chaos.HostTick();
				SendTaxman();
			}
		}

		private static bool Ready()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			if (SemiFunc.RunIsLevel() && (Object)(object)LevelGenerator.Instance != (Object)null && LevelGenerator.Instance.Generated && (int)GameDirector.instance.currentState == 2 && (Object)(object)RoundDirector.instance != (Object)null)
			{
				return RoundDirector.instance.haulGoal > 0;
			}
			return false;
		}

		private void Choose()
		{
			Plugin.QuestType pending = QuestSelection.Pending;
			QuestSelection.Pending = Plugin.QuestType.None;
			switch (pending)
			{
			default:
				return;
			case Plugin.QuestType.GoldNugget:
				GoldNugget.StartQuest();
				break;
			case Plugin.QuestType.Imposter:
				Imposter.StartQuest();
				break;
			case Plugin.QuestType.Glass:
				LevelModifier.StartGlass();
				break;
			case Plugin.QuestType.Rubber:
				LevelModifier.StartRubber();
				break;
			case Plugin.QuestType.Chaos:
				Chaos.Begin();
				break;
			}
			QuestSelection.Started(pending);
		}

		internal static void Say(string message)
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Instance.taxman.Enqueue(message);
			}
		}

		private void SendTaxman()
		{
			TruckScreenText instance = TruckScreenText.instance;
			if (taxman.Count != 0 && !((Object)(object)instance == (Object)null) && instance.started && !instance.isTyping && !(Time.time < nextMessage))
			{
				instance.MessageSendCustom("", taxman.Dequeue(), 0);
				nextMessage = Time.time + 3f;
			}
		}
	}
	[HarmonyPatch(typeof(TruckScreenText), "TypingUpdate")]
	internal static class TaxmanChatterPatch
	{
		private static bool Prefix(TruckScreenText __instance)
		{
			if (!Plugin.HideTaxmanChatter.Value)
			{
				return true;
			}
			if (__instance.currentPageIndex >= 0 && __instance.currentPageIndex < __instance.pages.Count)
			{
				TextPages val = __instance.pages[__instance.currentPageIndex];
				if (__instance.currentLineIndex >= 0 && __instance.currentLineIndex < val.textLines.Count)
				{
					TextLine val2 = val.textLines[__instance.currentLineIndex];
					__instance.currentCharIndex = ((val2.text != null) ? val2.text.Length : 0);
				}
			}
			__instance.isTyping = false;
			__instance.delayTimer = 0f;
			return false;
		}
	}
	[HarmonyPatch(typeof(RoundDirector), "Start")]
	internal static class RoundDirectorStartPatch
	{
		private static void Postfix(RoundDirector __instance)
		{
			if ((Object)(object)((Component)__instance).GetComponent<QuestDirector>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<QuestDirector>();
			}
		}
	}
	internal static class QuestNetwork
	{
		private const byte EventNugget = 180;

		private const byte EventImposterRole = 182;

		private const byte EventImposterStatus = 183;

		private const byte EventExplosion = 184;

		private const byte EventModifier = 185;

		internal const int ChaosModifier = 3;

		private static bool registered;

		internal static void Register()
		{
			if (!registered && PhotonNetwork.NetworkingClient != null)
			{
				PhotonNetwork.NetworkingClient.EventReceived += OnEvent;
				registered = true;
			}
		}

		internal static void SendNugget(int viewID, int reward)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0031: Expected O, but got Unknown
			if (SemiFunc.IsMultiplayer())
			{
				PhotonNetwork.RaiseEvent((byte)180, (object)new int[2] { viewID, reward }, new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)0
				}, SendOptions.SendReliable);
			}
		}

		internal static void SendImposterRole(PlayerAvatar imposter)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			Player val = (((Object)(object)imposter.photonView != (Object)null) ? imposter.photonView.Owner : null);
			if (SemiFunc.IsMultiplayer() && val != null)
			{
				object obj = 1;
				RaiseEventOptions val2 = new RaiseEventOptions();
				val2.TargetActors = new int[1] { val.ActorNumber };
				PhotonNetwork.RaiseEvent((byte)182, obj, val2, SendOptions.SendReliable);
			}
		}

		internal static void SendImposterStatus(int missionsDone, bool exploded)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_0042: Expected O, but got Unknown
			if (!SemiFunc.IsMultiplayer() || PhotonNetwork.IsMasterClient)
			{
				Imposter.Report(missionsDone, exploded);
				return;
			}
			PhotonNetwork.RaiseEvent((byte)183, (object)new int[2]
			{
				missionsDone,
				exploded ? 1 : 0
			}, new RaiseEventOptions
			{
				Receivers = (ReceiverGroup)2
			}, SendOptions.SendReliable);
		}

		internal static void SendExplosion(Vector3 at)
		{
			//IL_0015: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			if (SemiFunc.IsMultiplayer())
			{
				PhotonNetwork.RaiseEvent((byte)184, (object)new float[3] { at.x, at.y, at.z }, new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)0
				}, SendOptions.SendReliable);
			}
		}

		internal static void SendModifier(int kind)
		{
			//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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			if (SemiFunc.IsMultiplayer())
			{
				PhotonNetwork.RaiseEvent((byte)185, (object)kind, new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)0
				}, SendOptions.SendReliable);
			}
		}

		private static void OnEvent(EventData e)
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			if (e.Code == 185 && e.CustomData is int num)
			{
				if (num == 3)
				{
					Chaos.Apply();
				}
				else
				{
					LevelModifier.Apply((LevelModifier.Kind)num);
				}
			}
			else if (e.Code == 182)
			{
				Imposter.BecomeImposter();
			}
			else if (e.Code == 183 && e.CustomData is int[] array && array.Length == 2)
			{
				Imposter.Report(array[0], array[1] == 1);
			}
			else if (e.Code == 184 && e.CustomData is float[] array2 && array2.Length == 3)
			{
				Imposter.Explosion(new Vector3(array2[0], array2[1], array2[2]));
			}
			else if (e.Code == 180 && e.CustomData is int[] array3 && array3.Length == 2 && (Object)(object)QuestDirector.Instance != (Object)null)
			{
				((MonoBehaviour)QuestDirector.Instance).StartCoroutine(SetupNugget(array3[0], array3[1]));
			}
		}

		private static IEnumerator SetupNugget(int viewID, int reward)
		{
			for (float waited = 0f; waited < 10f; waited += 0.25f)
			{
				PhotonView val = PhotonView.Find(viewID);
				if ((Object)(object)val != (Object)null)
				{
					GoldNugget.Setup(((Component)val).gameObject, reward, host: false);
					yield break;
				}
				yield return (object)new WaitForSeconds(0.25f);
			}
			Plugin.Log.LogWarning((object)$"Hittade inte guldklumpen ({viewID}).");
		}
	}
	internal static class QuestSelection
	{
		private const int Spacing = 2;

		internal static Plugin.QuestType Pending = Plugin.QuestType.None;

		private static readonly List<Plugin.QuestType> history = new List<Plugin.QuestType>();

		internal static void Roll()
		{
			Pending = Plugin.QuestType.None;
			if (!SemiFunc.IsMasterClientOrSingleplayer() || !SemiFunc.RunIsLevel())
			{
				return;
			}
			bool flag = FogLevel();
			if (Plugin.TestForceQuest.Value != Plugin.QuestType.None)
			{
				Pending = Plugin.TestForceQuest.Value;
				if (Pending == Plugin.QuestType.Chaos && flag)
				{
					Plugin.Log.LogInfo((object)"TOTAL CHAOS hoppas över: FogMod har dimnivå.");
					Pending = Plugin.QuestType.None;
				}
				return;
			}
			int num = ((!SemiFunc.IsMultiplayer() || PhotonNetwork.CurrentRoom == null) ? 1 : PhotonNetwork.CurrentRoom.PlayerCount);
			List<Plugin.QuestType> list = new List<Plugin.QuestType>();
			if (num >= Plugin.NuggetMinPlayers.Value)
			{
				list.Add(Plugin.QuestType.GoldNugget);
			}
			if (num >= Plugin.ImposterMinPlayers.Value)
			{
				list.Add(Plugin.QuestType.Imposter);
			}
			if (Plugin.GlassEnabled.Value)
			{
				list.Add(Plugin.QuestType.Glass);
			}
			if (Plugin.RubberEnabled.Value)
			{
				list.Add(Plugin.QuestType.Rubber);
			}
			if (Plugin.ChaosEnabled.Value && !flag)
			{
				list.Add(Plugin.QuestType.Chaos);
			}
			list.RemoveAll((Plugin.QuestType q) => history.Contains(q));
			ShuffleList(list);
			float value = Random.value;
			float num2 = 0f;
			foreach (Plugin.QuestType item in list)
			{
				num2 += Mathf.Clamp01(Plugin.QuestChance.Value);
				if (value < num2)
				{
					Pending = item;
					break;
				}
			}
			Plugin.Log.LogInfo((object)("Order-val: " + ((Pending == Plugin.QuestType.None) ? "ingen" : Pending.ToString()) + " " + string.Format("(valbara: {0}; spärrade: {1}; {2} spelare).", string.Join(", ", list), string.Join(", ", history), num)));
		}

		internal static void Started(Plugin.QuestType quest)
		{
			history.Add(quest);
			while (history.Count > 2)
			{
				history.RemoveAt(0);
			}
		}

		internal static void Clear()
		{
			history.Clear();
			Pending = Plugin.QuestType.None;
		}

		private static bool FogLevel()
		{
			try
			{
				Type type = AccessTools.TypeByName("FogMod.FogState");
				MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, "IsFogLevel", (Type[])null, (Type[])null) : null);
				bool flag = default(bool);
				int num;
				if (methodInfo != null)
				{
					object obj = methodInfo.Invoke(null, null);
					if (obj is bool)
					{
						flag = (bool)obj;
						num = 1;
					}
					else
					{
						num = 0;
					}
				}
				else
				{
					num = 0;
				}
				return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Kunde inte fråga FogMod: " + ex.Message));
				return false;
			}
		}

		private static void ShuffleList<T>(List<T> list)
		{
			for (int num = list.Count - 1; num > 0; num--)
			{
				int num2 = Random.Range(0, num + 1);
				int index = num;
				int index2 = num2;
				T value = list[num2];
				T value2 = list[num];
				list[index] = value;
				list[index2] = value2;
			}
		}
	}
	[HarmonyPatch(typeof(RunManager), "ResetProgress")]
	internal static class QuestHistoryResetPatch
	{
		private static void Postfix()
		{
			QuestSelection.Clear();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}