Decompiled source of Ransom v1.0.2

BepInEx/plugins/Ransom.dll

Decompiled 17 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CSync.Extensions;
using CSync.Lib;
using GameNetcodeStuff;
using LethalConfig;
using LethalConfig.ConfigItems;
using Microsoft.CodeAnalysis;
using RuntimeNetcodeRPCValidator;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Ransom")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Ransom")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("68efc109-9703-41dc-b77e-634f554b904b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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;
		}
	}
}
namespace MyMonsterMod
{
	public static class AssetLoader
	{
		public static string GetPluginFolder()
		{
			return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		}

		public static Sprite LoadSprite(string fileName)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			string text = Path.Combine(GetPluginFolder(), "Assets", fileName);
			if (!File.Exists(text))
			{
				Plugin.Log.LogWarning((object)("Ransom: файл спрайта не найден: " + text));
				return null;
			}
			byte[] array = File.ReadAllBytes(text);
			Texture2D val = new Texture2D(2, 2);
			if (ImageConversion.LoadImage(val, array))
			{
				return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
			}
			Plugin.Log.LogWarning((object)("Ransom: не удалось загрузить спрайт: " + text));
			return null;
		}

		public static void AmplifyClip(AudioClip clip, float multiplier)
		{
			if (!((Object)(object)clip == (Object)null))
			{
				float[] array = new float[clip.samples * clip.channels];
				clip.GetData(array, 0);
				for (int i = 0; i < array.Length; i++)
				{
					array[i] = Mathf.Clamp(array[i] * multiplier, -1f, 1f);
				}
				clip.SetData(array, 0);
			}
		}

		public static IEnumerator LoadAudioClip(string fileName, Action<AudioClip> onLoaded)
		{
			string text = Path.Combine(GetPluginFolder(), "Assets", fileName);
			if (!File.Exists(text))
			{
				Plugin.Log.LogWarning((object)("Ransom: файл звука не найден: " + text));
				onLoaded(null);
				yield break;
			}
			string text2 = "file://" + text;
			UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(text2, (AudioType)13);
			try
			{
				yield return www.SendWebRequest();
				if ((int)www.result != 1)
				{
					Plugin.Log.LogWarning((object)("Ransom: ошибка загрузки звука: " + www.error));
					onLoaded(null);
				}
				else
				{
					AudioClip content = DownloadHandlerAudioClip.GetContent(www);
					onLoaded(content);
				}
			}
			finally
			{
				((IDisposable)www)?.Dispose();
			}
		}
	}
	public static class InputHelper
	{
		public static bool IsPlayerGivingInput()
		{
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			if (Keyboard.current != null)
			{
				flag = ((ButtonControl)Keyboard.current.wKey).isPressed || ((ButtonControl)Keyboard.current.aKey).isPressed || ((ButtonControl)Keyboard.current.sKey).isPressed || ((ButtonControl)Keyboard.current.rKey).isPressed || ((ButtonControl)Keyboard.current.dKey).isPressed || ((ButtonControl)Keyboard.current.fKey).isPressed || ((ButtonControl)Keyboard.current.gKey).isPressed || ((ButtonControl)Keyboard.current.qKey).isPressed || ((ButtonControl)Keyboard.current.eKey).isPressed || ((ButtonControl)Keyboard.current.zKey).isPressed || ((ButtonControl)Keyboard.current.tKey).isPressed || ((ButtonControl)Keyboard.current.iKey).isPressed || ((ButtonControl)Keyboard.current.backquoteKey).isPressed || ((ButtonControl)Keyboard.current.tabKey).isPressed || ((ButtonControl)Keyboard.current.leftShiftKey).isPressed || ((ButtonControl)Keyboard.current.rightShiftKey).isPressed || ((ButtonControl)Keyboard.current.leftCtrlKey).isPressed || ((ButtonControl)Keyboard.current.rightCtrlKey).isPressed || ((ButtonControl)Keyboard.current.enterKey).isPressed || ((ButtonControl)Keyboard.current.numpadEnterKey).isPressed || ((ButtonControl)Keyboard.current.leftAltKey).isPressed || ((ButtonControl)Keyboard.current.rightAltKey).isPressed || ((ButtonControl)Keyboard.current.digit1Key).isPressed || ((ButtonControl)Keyboard.current.digit2Key).isPressed || ((ButtonControl)Keyboard.current.digit3Key).isPressed || ((ButtonControl)Keyboard.current.digit4Key).isPressed || ((ButtonControl)Keyboard.current.digit5Key).isPressed || ((ButtonControl)Keyboard.current.digit6Key).isPressed || ((ButtonControl)Keyboard.current.digit7Key).isPressed || ((ButtonControl)Keyboard.current.digit8Key).isPressed || ((ButtonControl)Keyboard.current.digit9Key).isPressed;
			}
			bool flag2 = false;
			if (Mouse.current != null)
			{
				Vector2 val = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).delta).ReadValue();
				bool num = ((Vector2)(ref val)).sqrMagnitude > 0.01f;
				bool flag3 = Mouse.current.leftButton.isPressed || Mouse.current.rightButton.isPressed;
				bool flag4 = Mathf.Abs(((InputControl<Vector2>)(object)Mouse.current.scroll).ReadValue().y) > 0.01f;
				flag2 = num || flag3 || flag4;
			}
			return flag || flag2;
		}
	}
	[BepInPlugin("Ketchup.Ransom", "Ransom", "1.0.0")]
	[BepInDependency("NicholaScott.BepInEx.RuntimeNetcodeRPCValidator", "0.2.5")]
	[BepInDependency("com.sigurd.csync", "5.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private NetcodeValidator netcodeValidator;

		private void Awake()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"Ransom mod loaded.");
			RansomConfig.Setup(((BaseUnityPlugin)this).Config);
			SceneManager.sceneLoaded += OnSceneLoaded;
			netcodeValidator = new NetcodeValidator("Ketchup.Ransom");
			netcodeValidator.PatchAll();
			netcodeValidator.BindToPreExistingObjectByBehaviour<RansomNetworking, PlayerControllerB>();
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_002b: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			if (((Scene)(ref scene)).name == "SampleSceneRelay" || ((Scene)(ref scene)).name.Contains("Sample"))
			{
				GameObject val = new GameObject("RansomTestObject");
				val.AddComponent<RansomJumpscare>();
				val.AddComponent<RansomInfection>();
				val.AddComponent<RansomSpawner>();
			}
		}
	}
	public class RansomBehaviour : MonoBehaviour
	{
		private bool jumpscareActive;

		private float freezeCheckTimer;

		private float freezeCheckDuration = 5f;

		private int frameCounter;

		private void Awake()
		{
		}

		private void OnDestroy()
		{
			Plugin.Log.LogWarning((object)"RansomBehaviour УНИЧТОЖЕН!");
		}

		private void Update()
		{
			frameCounter++;
			_ = frameCounter % 60;
			if (Keyboard.current != null && ((ButtonControl)Keyboard.current.pKey).wasPressedThisFrame && !jumpscareActive)
			{
				StartJumpscareCheck();
			}
			if (!jumpscareActive)
			{
				return;
			}
			if (IsPlayerGivingMovementInput())
			{
				OnPlayerFailedCheck();
				return;
			}
			freezeCheckTimer -= Time.deltaTime;
			if (freezeCheckTimer <= 0f)
			{
				OnPlayerSucceededCheck();
			}
		}

		private void OnGUI()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle();
			val.fontSize = 24;
			val.normal.textColor = Color.red;
			GUI.Box(new Rect(5f, 5f, 420f, 100f), "");
			GUI.Label(new Rect(10f, 10f, 400f, 30f), "Frame: " + frameCounter, val);
			GUI.Label(new Rect(10f, 40f, 400f, 30f), "Jumpscare active: " + jumpscareActive, val);
			GUI.Label(new Rect(10f, 70f, 400f, 30f), "P key pressed: " + (Keyboard.current != null && ((ButtonControl)Keyboard.current.pKey).isPressed), val);
		}

		private bool IsPlayerGivingMovementInput()
		{
			return InputHelper.IsPlayerGivingInput();
		}

		private void StartJumpscareCheck()
		{
			jumpscareActive = true;
			freezeCheckTimer = freezeCheckDuration;
		}

		private void OnPlayerFailedCheck()
		{
			jumpscareActive = false;
		}

		private void OnPlayerSucceededCheck()
		{
			jumpscareActive = false;
		}
	}
	public enum SpawnFrequencyPreset
	{
		VeryOften,
		Often,
		Default,
		Rare,
		VeryRare
	}
	public enum ReactionSpeedPreset
	{
		Hard,
		Default,
		Easy
	}
	public enum RansomSumPreset
	{
		Unfair,
		MrCrabs,
		BigTaxes,
		Default,
		BlackFriday
	}
	public enum AggressivenessPreset
	{
		Angry,
		Default,
		Kind
	}
	public enum PopupDurationPreset
	{
		Nightmare,
		StubbornVirus,
		Default,
		Quarantine
	}
	public enum PopupTimingPreset
	{
		Hell,
		CantSeeAnything,
		Default,
		Antivirus,
		Easy,
		Disabled
	}
	public enum InfectionTimerPreset
	{
		ThinkFaster,
		Default,
		NoNeedToRush
	}
	public enum ControlHackPreset
	{
		On,
		Off
	}
	public enum RansomDamagePreset
	{
		Lethal,
		A90,
		Half,
		Default,
		Safe
	}
	public enum AbsoluteRansomPreset
	{
		Often,
		Rare,
		VeryRare,
		Off
	}
	public enum LetsGoGamblingPreset
	{
		On,
		Off
	}
	public enum InfectionMusicPreset
	{
		Default,
		SlightlyQuieter,
		Quieter,
		Off
	}
	public enum SellSoundPreset
	{
		Default,
		SlightlyQuieter,
		Quieter
	}
	public enum PopupSoundPreset
	{
		Default,
		SlightlyQuieter,
		Quieter
	}
	public enum CureSoundPreset
	{
		Default,
		SlightlyQuieter,
		Quieter
	}
	public class RansomSyncedConfig : SyncedConfig2<RansomSyncedConfig>
	{
		public SyncedEntry<SpawnFrequencyPreset> SpawnFrequency;

		public SyncedEntry<ReactionSpeedPreset> ReactionSpeed;

		public SyncedEntry<RansomSumPreset> RansomSum;

		public SyncedEntry<AggressivenessPreset> Aggressiveness;

		public SyncedEntry<PopupDurationPreset> PopupDuration;

		public SyncedEntry<PopupTimingPreset> PopupTiming;

		public SyncedEntry<InfectionTimerPreset> InfectionTimer;

		public SyncedEntry<ControlHackPreset> ControlHack;

		public SyncedEntry<RansomDamagePreset> RansomDamage;

		public SyncedEntry<AbsoluteRansomPreset> Relapse;

		public SyncedEntry<LetsGoGamblingPreset> LetsGoGambling;

		public ConfigEntry<InfectionMusicPreset> InfectionMusicVolume { get; private set; }

		public ConfigEntry<SellSoundPreset> SellSoundVolume { get; private set; }

		public ConfigEntry<PopupSoundPreset> PopupSoundVolume { get; private set; }

		public ConfigEntry<CureSoundPreset> CureSoundVolume { get; private set; }

		public RansomSyncedConfig(ConfigFile cfg)
			: base("Ketchup.Ransom")
		{
			//IL_0031: 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_004c: Expected O, but got Unknown
			//IL_004c: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_0078: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_00a4: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			//IL_00d0: Expected O, but got Unknown
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_00fc: Expected O, but got Unknown
			//IL_010d: 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_0128: Expected O, but got Unknown
			//IL_0128: Expected O, but got Unknown
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Expected O, but got Unknown
			//IL_0154: Expected O, but got Unknown
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Expected O, but got Unknown
			//IL_0180: Expected O, but got Unknown
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Expected O, but got Unknown
			//IL_01ac: Expected O, but got Unknown
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Expected O, but got Unknown
			//IL_01d8: Expected O, but got Unknown
			//IL_01e9: 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: Expected O, but got Unknown
			//IL_0204: Expected O, but got Unknown
			Sprite val = AssetLoader.LoadSprite("icon.png");
			if ((Object)(object)val != (Object)null)
			{
				LethalConfigManager.SetModIcon(val);
			}
			SpawnFrequency = SyncedBindingExtensions.BindSyncedEntry<SpawnFrequencyPreset>(cfg, new ConfigDefinition("General Settings", "SpawnFrequency"), SpawnFrequencyPreset.Default, new ConfigDescription("Configure how often Ransom appears during the game", (AcceptableValueBase)null, Array.Empty<object>()));
			ReactionSpeed = SyncedBindingExtensions.BindSyncedEntry<ReactionSpeedPreset>(cfg, new ConfigDefinition("General Settings", "ReactionSpeed"), ReactionSpeedPreset.Default, new ConfigDescription("Configure how hard it is to react to and avoid Ransom's jumpscare", (AcceptableValueBase)null, Array.Empty<object>()));
			RansomSum = SyncedBindingExtensions.BindSyncedEntry<RansomSumPreset>(cfg, new ConfigDefinition("General Settings", "RansomSum"), RansomSumPreset.Default, new ConfigDescription("Configure how much you need to pay as ransom", (AcceptableValueBase)null, Array.Empty<object>()));
			Aggressiveness = SyncedBindingExtensions.BindSyncedEntry<AggressivenessPreset>(cfg, new ConfigDefinition("General Settings", "Aggressiveness"), AggressivenessPreset.Default, new ConfigDescription("Configure how often Ransom attempts to attack during a round, and how long its cooldown is between attacks", (AcceptableValueBase)null, Array.Empty<object>()));
			PopupDuration = SyncedBindingExtensions.BindSyncedEntry<PopupDurationPreset>(cfg, new ConfigDefinition("General Settings", "PopupDuration"), PopupDurationPreset.Default, new ConfigDescription("Configure how long each popup stays active on screen during an active ransom", (AcceptableValueBase)null, Array.Empty<object>()));
			PopupTiming = SyncedBindingExtensions.BindSyncedEntry<PopupTimingPreset>(cfg, new ConfigDefinition("General Settings", "PopupTiming"), PopupTimingPreset.Default, new ConfigDescription("Configure how often popups appear during an active ransom", (AcceptableValueBase)null, Array.Empty<object>()));
			InfectionTimer = SyncedBindingExtensions.BindSyncedEntry<InfectionTimerPreset>(cfg, new ConfigDefinition("General Settings", "InfectionTimer"), InfectionTimerPreset.Default, new ConfigDescription("Configure how much time you're given to pay the ransom", (AcceptableValueBase)null, Array.Empty<object>()));
			RansomDamage = SyncedBindingExtensions.BindSyncedEntry<RansomDamagePreset>(cfg, new ConfigDefinition("General Settings", "RansomDamage"), RansomDamagePreset.Default, new ConfigDescription("Configure the damage from Ransom's first jumpscare", (AcceptableValueBase)null, Array.Empty<object>()));
			ControlHack = SyncedBindingExtensions.BindSyncedEntry<ControlHackPreset>(cfg, new ConfigDefinition("Extra Settings", "ControlHack"), ControlHackPreset.Off, new ConfigDescription("When enabled, your controls will be inverted while an active ransom is in effect", (AcceptableValueBase)null, Array.Empty<object>()));
			Relapse = SyncedBindingExtensions.BindSyncedEntry<AbsoluteRansomPreset>(cfg, new ConfigDefinition("Extra Settings", "AfterShock"), AbsoluteRansomPreset.Off, new ConfigDescription("When enabled, there a certain chance, after successfully fending off an attack, Ransom attacks again shortly after — but this time you won't have time to react", (AcceptableValueBase)null, Array.Empty<object>()));
			LetsGoGambling = SyncedBindingExtensions.BindSyncedEntry<LetsGoGamblingPreset>(cfg, new ConfigDefinition("Extra Settings", "LetsGoGambling"), LetsGoGamblingPreset.Off, new ConfigDescription("When enabled, Ransom becomes weaker, but you get a small, steadily increasing chance of exploding", (AcceptableValueBase)null, Array.Empty<object>()));
			InfectionMusicVolume = cfg.Bind<InfectionMusicPreset>("Sounds", "InfectionMusicVolume", InfectionMusicPreset.Default, "Volume of the music.");
			SellSoundVolume = cfg.Bind<SellSoundPreset>("Sounds", "SellSoundVolume", SellSoundPreset.Default, "Volume of the item-sell sound.");
			PopupSoundVolume = cfg.Bind<PopupSoundPreset>("Sounds", "PopupSoundVolume", PopupSoundPreset.Default, "Volume of the popup appearance sound.");
			CureSoundVolume = cfg.Bind<CureSoundPreset>("Sounds", "CureSoundVolume", CureSoundPreset.Default, "Volume of the cure sound.");
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<SpawnFrequencyPreset>(SpawnFrequency.Entry));
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<ReactionSpeedPreset>(ReactionSpeed.Entry));
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<RansomSumPreset>(RansomSum.Entry));
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<AggressivenessPreset>(Aggressiveness.Entry));
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<PopupDurationPreset>(PopupDuration.Entry));
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<PopupTimingPreset>(PopupTiming.Entry));
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<InfectionTimerPreset>(InfectionTimer.Entry));
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<RansomDamagePreset>(RansomDamage.Entry));
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<ControlHackPreset>(ControlHack.Entry));
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<AbsoluteRansomPreset>(Relapse.Entry));
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<LetsGoGamblingPreset>(LetsGoGambling.Entry));
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<InfectionMusicPreset>(InfectionMusicVolume));
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<SellSoundPreset>(SellSoundVolume));
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<PopupSoundPreset>(PopupSoundVolume));
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<CureSoundPreset>(CureSoundVolume));
			ApplyAll();
			SpawnFrequency.Changed += delegate
			{
				ApplySpawnFrequency(SpawnFrequency.Value);
			};
			ReactionSpeed.Changed += delegate
			{
				ApplyReactionSpeed(ReactionSpeed.Value);
			};
			RansomSum.Changed += delegate
			{
				ApplyRansomSum(RansomSum.Value);
			};
			Aggressiveness.Changed += delegate
			{
				ApplyAggressiveness(Aggressiveness.Value);
			};
			PopupDuration.Changed += delegate
			{
				ApplyPopupDuration(PopupDuration.Value);
			};
			PopupTiming.Changed += delegate
			{
				ApplyPopupTiming(PopupTiming.Value);
			};
			InfectionTimer.Changed += delegate
			{
				ApplyInfectionTimer(InfectionTimer.Value);
			};
			RansomDamage.Changed += delegate
			{
				ApplyRansomDamage(RansomDamage.Value);
			};
			ControlHack.Changed += delegate
			{
				ApplyControlHack(ControlHack.Value);
			};
			Relapse.Changed += delegate
			{
				ApplyAbsoluteRansom(Relapse.Value);
			};
			LetsGoGambling.Changed += delegate
			{
				ApplyLetsGoGambling(LetsGoGambling.Value);
			};
			InfectionMusicVolume.SettingChanged += delegate
			{
				ApplyInfectionMusicVolume(InfectionMusicVolume.Value);
			};
			SellSoundVolume.SettingChanged += delegate
			{
				ApplySellSoundVolume(SellSoundVolume.Value);
			};
			PopupSoundVolume.SettingChanged += delegate
			{
				ApplyPopupSoundVolume(PopupSoundVolume.Value);
			};
			CureSoundVolume.SettingChanged += delegate
			{
				ApplyCureSoundVolume(CureSoundVolume.Value);
			};
		}

		private void ApplyAll()
		{
			ApplySpawnFrequency(SpawnFrequency.Value);
			ApplyReactionSpeed(ReactionSpeed.Value);
			ApplyRansomSum(RansomSum.Value);
			ApplyAggressiveness(Aggressiveness.Value);
			ApplyPopupDuration(PopupDuration.Value);
			ApplyPopupTiming(PopupTiming.Value);
			ApplyInfectionTimer(InfectionTimer.Value);
			ApplyRansomDamage(RansomDamage.Value);
			ApplyControlHack(ControlHack.Value);
			ApplyAbsoluteRansom(Relapse.Value);
			ApplyLetsGoGambling(LetsGoGambling.Value);
			ApplyInfectionMusicVolume(InfectionMusicVolume.Value);
			ApplySellSoundVolume(SellSoundVolume.Value);
			ApplyPopupSoundVolume(PopupSoundVolume.Value);
			ApplyCureSoundVolume(CureSoundVolume.Value);
		}

		private void ApplySpawnFrequency(SpawnFrequencyPreset preset)
		{
			float veryEasy;
			float easy;
			float medium;
			float hard;
			float hardcore;
			switch (preset)
			{
			case SpawnFrequencyPreset.VeryOften:
				veryEasy = 0.1f;
				easy = 0.2f;
				medium = 0.4f;
				hard = 0.6f;
				hardcore = 0.8f;
				break;
			case SpawnFrequencyPreset.Often:
				veryEasy = 0.07f;
				easy = 0.15f;
				medium = 0.3f;
				hard = 0.45f;
				hardcore = 0.6f;
				break;
			case SpawnFrequencyPreset.Rare:
				veryEasy = 0.03f;
				easy = 0.06f;
				medium = 0.11f;
				hard = 0.14f;
				hardcore = 0.2f;
				break;
			case SpawnFrequencyPreset.VeryRare:
				veryEasy = 0.01f;
				easy = 0.04f;
				medium = 0.08f;
				hard = 0.12f;
				hardcore = 0.15f;
				break;
			default:
				veryEasy = 0.05f;
				easy = 0.1f;
				medium = 0.2f;
				hard = 0.3f;
				hardcore = 0.4f;
				break;
			}
			RansomSpawner.ApplyRoundChances(veryEasy, easy, medium, hard, hardcore);
		}

		private void ApplyReactionSpeed(ReactionSpeedPreset preset)
		{
			float phase1Duration;
			float phase2Duration;
			float phase2_5Duration;
			float phase3Duration;
			switch (preset)
			{
			case ReactionSpeedPreset.Hard:
				phase1Duration = 0.2f;
				phase2Duration = 0.3f;
				phase2_5Duration = 0.2f;
				phase3Duration = 0.5f;
				break;
			case ReactionSpeedPreset.Easy:
				phase1Duration = 0.35f;
				phase2Duration = 0.4f;
				phase2_5Duration = 0.35f;
				phase3Duration = 0.1f;
				break;
			default:
				phase1Duration = 0.3f;
				phase2Duration = 0.4f;
				phase2_5Duration = 0.3f;
				phase3Duration = 0.2f;
				break;
			}
			RansomJumpscare.phase1Duration = phase1Duration;
			RansomJumpscare.phase2Duration = phase2Duration;
			RansomJumpscare.phase2_5Duration = phase2_5Duration;
			RansomJumpscare.phase3Duration = phase3Duration;
		}

		private void ApplyRansomSum(RansomSumPreset preset)
		{
			float num;
			int ransomMinimum;
			switch (preset)
			{
			case RansomSumPreset.Unfair:
				num = 1f;
				ransomMinimum = 350;
				break;
			case RansomSumPreset.MrCrabs:
				num = 0.5f;
				ransomMinimum = 250;
				break;
			case RansomSumPreset.BigTaxes:
				num = 0.35f;
				ransomMinimum = 100;
				break;
			case RansomSumPreset.BlackFriday:
				num = 0.1f;
				ransomMinimum = 25;
				break;
			default:
				num = 0.25f;
				ransomMinimum = 50;
				break;
			}
			if (RansomSpawner.gamblingModeEnabled)
			{
				num = Mathf.Max(0f, num - 0.05f);
			}
			RansomInfection.ransomPercent = num;
			RansomInfection.ransomMinimum = ransomMinimum;
		}

		private void ApplyAggressiveness(AggressivenessPreset preset)
		{
			float num;
			float chance;
			switch (preset)
			{
			case AggressivenessPreset.Angry:
				num = 2.1f;
				chance = 0.07f;
				break;
			case AggressivenessPreset.Kind:
				num = 4f;
				chance = 0.01f;
				break;
			default:
				num = 3f;
				chance = 0.04f;
				break;
			}
			if (RansomSpawner.gamblingModeEnabled)
			{
				num += 0.5f;
			}
			RansomSpawner.ApplyAggressiveness(chance, num);
		}

		private void ApplyPopupDuration(PopupDurationPreset preset)
		{
			float num = preset switch
			{
				PopupDurationPreset.Nightmare => 18f, 
				PopupDurationPreset.StubbornVirus => 12f, 
				PopupDurationPreset.Quarantine => 4f, 
				_ => 8f, 
			};
			if (RansomSpawner.gamblingModeEnabled)
			{
				num = Mathf.Max(1f, num - 3f);
			}
			RansomInfection.microPopupLifetime = num;
		}

		private void ApplyPopupTiming(PopupTimingPreset preset)
		{
			RansomInfection.popupSpawningDisabledAfterInitial = false;
			switch (preset)
			{
			case PopupTimingPreset.Hell:
				RansomInfection.microPopupSpawnInterval = 0.5f;
				RansomInfection.microPopupSpawnIntervalUrgent = 0.25f;
				RansomInfection.microPopupSpawnIntervalCritical = 0.1f;
				break;
			case PopupTimingPreset.CantSeeAnything:
				RansomInfection.microPopupSpawnInterval = 1.5f;
				RansomInfection.microPopupSpawnIntervalUrgent = 0.8f;
				RansomInfection.microPopupSpawnIntervalCritical = 0.3f;
				break;
			case PopupTimingPreset.Antivirus:
				RansomInfection.microPopupSpawnInterval = 5f;
				RansomInfection.microPopupSpawnIntervalUrgent = 3f;
				RansomInfection.microPopupSpawnIntervalCritical = 1.5f;
				break;
			case PopupTimingPreset.Easy:
				RansomInfection.microPopupSpawnInterval = 8f;
				RansomInfection.microPopupSpawnIntervalUrgent = 5f;
				RansomInfection.microPopupSpawnIntervalCritical = 3f;
				break;
			case PopupTimingPreset.Disabled:
				RansomInfection.popupSpawningDisabledAfterInitial = true;
				break;
			default:
				RansomInfection.microPopupSpawnInterval = 3f;
				RansomInfection.microPopupSpawnIntervalUrgent = 1.5f;
				RansomInfection.microPopupSpawnIntervalCritical = 0.5f;
				break;
			}
		}

		private void ApplyInfectionTimer(InfectionTimerPreset preset)
		{
			switch (preset)
			{
			case InfectionTimerPreset.ThinkFaster:
				RansomInfection.infectionDuration = 45f;
				RansomInfection.infectionMusicVariant = 1;
				RansomInfection.stage2ThresholdSeconds = 30f;
				break;
			case InfectionTimerPreset.NoNeedToRush:
				RansomInfection.infectionDuration = 124f;
				RansomInfection.infectionMusicVariant = 2;
				RansomInfection.stage2ThresholdSeconds = 61f;
				break;
			default:
				RansomInfection.infectionDuration = 90f;
				RansomInfection.infectionMusicVariant = 0;
				RansomInfection.stage2ThresholdSeconds = 30f;
				break;
			}
		}

		private void ApplyControlHack(ControlHackPreset preset)
		{
			RansomInfection.invertControlsEnabled = preset == ControlHackPreset.On;
		}

		private void ApplyRansomDamage(RansomDamagePreset preset)
		{
			int num = preset switch
			{
				RansomDamagePreset.Lethal => 666, 
				RansomDamagePreset.A90 => 90, 
				RansomDamagePreset.Half => 50, 
				RansomDamagePreset.Safe => 0, 
				_ => 30, 
			};
			if (RansomSpawner.gamblingModeEnabled)
			{
				num = Mathf.Max(0, num - 15);
			}
			RansomJumpscare.phase4DamageAmount = num;
		}

		private void ApplyAbsoluteRansom(AbsoluteRansomPreset preset)
		{
			switch (preset)
			{
			case AbsoluteRansomPreset.Often:
				RansomJumpscare.absoluteRansomChance = 0.4f;
				break;
			case AbsoluteRansomPreset.Rare:
				RansomJumpscare.absoluteRansomChance = 0.15f;
				break;
			case AbsoluteRansomPreset.VeryRare:
				RansomJumpscare.absoluteRansomChance = 0.05f;
				break;
			default:
				RansomJumpscare.absoluteRansomChance = 0f;
				break;
			}
		}

		private void ApplyLetsGoGambling(LetsGoGamblingPreset preset)
		{
			RansomSpawner.gamblingModeEnabled = preset == LetsGoGamblingPreset.On;
			ApplyRansomSum(RansomSum.Value);
			ApplyRansomDamage(RansomDamage.Value);
			ApplyPopupDuration(PopupDuration.Value);
			ApplyAggressiveness(Aggressiveness.Value);
		}

		private void ApplyInfectionMusicVolume(InfectionMusicPreset preset)
		{
			switch (preset)
			{
			case InfectionMusicPreset.SlightlyQuieter:
				RansomInfection.infectionMusicEnabled = true;
				RansomInfection.infectionMusicVolumeMultiplier = 0.8f;
				break;
			case InfectionMusicPreset.Quieter:
				RansomInfection.infectionMusicEnabled = true;
				RansomInfection.infectionMusicVolumeMultiplier = 0.5f;
				break;
			case InfectionMusicPreset.Off:
				RansomInfection.infectionMusicEnabled = false;
				break;
			default:
				RansomInfection.infectionMusicEnabled = true;
				RansomInfection.infectionMusicVolumeMultiplier = 1f;
				break;
			}
		}

		private void ApplySellSoundVolume(SellSoundPreset preset)
		{
			switch (preset)
			{
			case SellSoundPreset.Quieter:
				RansomInfection.sellSoundVolumeMultiplier = 0.5f;
				break;
			case SellSoundPreset.SlightlyQuieter:
				RansomInfection.sellSoundVolumeMultiplier = 0.8f;
				break;
			default:
				RansomInfection.sellSoundVolumeMultiplier = 1f;
				break;
			}
		}

		private void ApplyPopupSoundVolume(PopupSoundPreset preset)
		{
			switch (preset)
			{
			case PopupSoundPreset.Quieter:
				RansomInfection.popupSoundVolumeMultiplier = 0.5f;
				break;
			case PopupSoundPreset.SlightlyQuieter:
				RansomInfection.popupSoundVolumeMultiplier = 0.8f;
				break;
			default:
				RansomInfection.popupSoundVolumeMultiplier = 1f;
				break;
			}
		}

		private void ApplyCureSoundVolume(CureSoundPreset preset)
		{
			switch (preset)
			{
			case CureSoundPreset.Quieter:
				RansomInfection.cureSoundVolumeMultiplier = 0.5f;
				break;
			case CureSoundPreset.SlightlyQuieter:
				RansomInfection.cureSoundVolumeMultiplier = 0.8f;
				break;
			default:
				RansomInfection.cureSoundVolumeMultiplier = 1f;
				break;
			}
		}
	}
	public static class RansomConfig
	{
		public static RansomSyncedConfig Instance;

		public static void Setup(ConfigFile config)
		{
			Instance = new RansomSyncedConfig(config);
		}
	}
	public class RansomControlHack : MonoBehaviour
	{
		private bool inverted;

		public void SetInverted(bool value)
		{
			//IL_004c: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_00c2: 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_00a8: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			if (inverted == value)
			{
				return;
			}
			inverted = value;
			PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
			if (!((Object)(object)val == (Object)null) && val.playerActions != null)
			{
				InputAction val2 = InputSystem.actions.FindAction("Move", false);
				MovementActions movement = val.playerActions.Movement;
				InputAction look = ((MovementActions)(ref movement)).Look;
				for (int i = 0; i < val2.bindings.Count; i++)
				{
					_ = val2.bindings[i];
				}
				InvertSimpleBindings(look, value);
				InvertSimpleBindings(val2, value);
				InvertMoveComposite(val2, value);
				for (int j = 0; j < val2.bindings.Count; j++)
				{
					_ = val2.bindings[j];
				}
			}
		}

		private void InvertSimpleBindings(InputAction action, bool invert)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_003a: 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)
			for (int i = 0; i < action.bindings.Count; i++)
			{
				InputBinding val = action.bindings[i];
				if (!((InputBinding)(ref val)).isPartOfComposite)
				{
					val = action.bindings[i];
					if (!((InputBinding)(ref val)).isComposite)
					{
						int num = i;
						val = default(InputBinding);
						((InputBinding)(ref val)).overrideProcessors = (invert ? "invertVector2" : "");
						InputActionRebindingExtensions.ApplyBindingOverride(action, num, val);
					}
				}
			}
		}

		private void InvertMoveComposite(InputAction action, bool invert)
		{
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_003d: 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_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)
			List<int> list = new List<int>();
			List<int> list2 = new List<int>();
			List<int> list3 = new List<int>();
			List<int> list4 = new List<int>();
			for (int i = 0; i < action.bindings.Count; i++)
			{
				InputBinding val = action.bindings[i];
				if (((InputBinding)(ref val)).isPartOfComposite)
				{
					val = action.bindings[i];
					switch (((InputBinding)(ref val)).name.ToLower())
					{
					case "up":
						list.Add(i);
						break;
					case "down":
						list2.Add(i);
						break;
					case "left":
						list3.Add(i);
						break;
					case "right":
						list4.Add(i);
						break;
					}
				}
			}
			int num = Mathf.Min(list.Count, list2.Count);
			for (int j = 0; j < num; j++)
			{
				SwapOrReset(action, list[j], list2[j], invert);
			}
			num = Mathf.Min(list3.Count, list4.Count);
			for (int k = 0; k < num; k++)
			{
				SwapOrReset(action, list3[k], list4[k], invert);
			}
		}

		private void SwapOrReset(InputAction action, int indexA, int indexB, bool invert)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_0022: 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_002b: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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)
			if (invert)
			{
				InputBinding val = action.bindings[indexA];
				string effectivePath = ((InputBinding)(ref val)).effectivePath;
				val = action.bindings[indexB];
				string effectivePath2 = ((InputBinding)(ref val)).effectivePath;
				val = default(InputBinding);
				((InputBinding)(ref val)).overridePath = effectivePath2;
				InputActionRebindingExtensions.ApplyBindingOverride(action, indexA, val);
				val = default(InputBinding);
				((InputBinding)(ref val)).overridePath = effectivePath;
				InputActionRebindingExtensions.ApplyBindingOverride(action, indexB, val);
			}
			else
			{
				InputActionRebindingExtensions.RemoveBindingOverride(action, indexA);
				InputActionRebindingExtensions.RemoveBindingOverride(action, indexB);
			}
		}
	}
	public class RansomInfection : MonoBehaviour
	{
		private bool infectionActive;

		private int ransomAmount;

		private int amountPaid;

		private float displayedAmount;

		private const float countUpSpeed = 250f;

		private float infectionTimer;

		public static float infectionDuration = 90f;

		public static float stage2ThresholdSeconds = 30f;

		public static float stage3ThresholdSeconds = 10f;

		public static int ransomMinimum = 50;

		public static float ransomPercent = 0.25f;

		private int lockedLootValue = -1;

		private static readonly Dictionary<string, int> equipmentPrices = new Dictionary<string, int>
		{
			{ "Walkie-talkie", 10 },
			{ "Flashlight", 10 },
			{ "Shovel", 15 },
			{ "Lockpicker", 10 },
			{ "Pro-flashlight", 20 },
			{ "Stun grenade", 15 },
			{ "Boombox", 30 },
			{ "TZP-Inhalant", 40 },
			{ "Zap gun", 200 },
			{ "Jetpack", 500 },
			{ "Extension ladder", 30 },
			{ "Radar-booster", 30 },
			{ "Spray paint", 25 },
			{ "Weed killer", 10 },
			{ "Belt bag", 35 }
		};

		private float repositionTimer;

		private const float cameraShakeInterval = 0.4f;

		private const float repositionInterval = 3f;

		private GameObject windowCanvasObject;

		private RectTransform windowPanel;

		private Vector3 windowBasePosition;

		private Vector2 panelDriftOffset = Vector2.zero;

		private float panelDriftTimer;

		private const float driftMagnitude = 10f;

		private Text moneyText;

		private Text timerText;

		private const float windowAnimDuration = 0.2f;

		private GameObject cureImageObject;

		private Canvas cureCanvas;

		private Image cureFrameImage;

		private Image cureBackgroundImage;

		private Image cureLikeImage;

		private Image cureThankYouImage;

		public static float cureFrameDelay = 0f;

		public static float cureFrameGrowDuration = 0.3f;

		public static Vector2 cureFrameSize = new Vector2(950f, 800f);

		public static float cureFramePopDuration = 0.1f;

		public static float cureFrameStandDuration = 0.1f;

		public static float cureFrameMoveDuration = 0.1f;

		public static Vector2 cureBackgroundSize = new Vector2(888f, 715f);

		public static Vector2 cureBackgroundPositionOffset = new Vector2(-5f, -16f);

		public static Vector2 cureLikeSize = new Vector2(900f, 500f);

		public static Vector2 cureLikePositionOffset = new Vector2(0f, -110f);

		public static float cureBackgroundPopDuration = 0.05f;

		public static float cureLikeDelayAfterBackground = 0.15f;

		public static float cureLikePopDuration = 0.16f;

		public static Vector2 cureThankYouSize = new Vector2(750f, 400f);

		public static Vector2 cureThankYouPositionOffset = new Vector2(0f, 250f);

		public static float cureThankYouDelayAfterLike = 0.55f;

		public static float cureThankYouPopDuration = 0.3f;

		public static float cureHoldDurationAfterThankYou = 2f;

		public static float cureShrinkDuration = 0.15f;

		private AudioSource audioSource;

		private AudioSource musicAudioSource;

		public static bool infectionMusicEnabled = true;

		public static float infectionMusicVolumeMultiplier = 1f;

		public static float sellSoundVolumeMultiplier = 1f;

		public static float popupSoundVolumeMultiplier = 1f;

		public static float cureSoundVolumeMultiplier = 1f;

		private AudioClip infectionMusic;

		private AudioClip infectionMusic2;

		private AudioClip infectionMusic3;

		public static int infectionMusicVariant = 0;

		private AudioClip cureSound;

		private AudioClip sellSound;

		private AudioClip[] errorSounds = (AudioClip[])(object)new AudioClip[5];

		private GameObject sellPromptObject;

		private GameObject vignetteObject;

		private Image vignetteImage;

		private const float vignetteMinAlpha = 0.04f;

		private const float vignetteMaxAlpha = 0.14f;

		private const float vignettePulseSpeed = 1.2f;

		private Text sellPromptText;

		private const int microSpriteCount = 43;

		private Sprite[] microSprites = (Sprite[])(object)new Sprite[43];

		private Coroutine microPopupLoopCoroutine;

		private List<GameObject> activeMicroPopups = new List<GameObject>();

		private Queue<int> recentMicroIndices = new Queue<int>();

		private const float microPopupAnimDuration = 0.1f;

		public static float microPopupLifetime = 8f;

		public static float microPopupSpawnInterval = 3f;

		public static float microPopupSpawnIntervalUrgent = 1.5f;

		public static float microPopupSpawnIntervalCritical = 0.5f;

		public static bool popupSpawningDisabledAfterInitial = false;

		private const float microPopupSize = 500f;

		private RansomJumpscare jumpscare;

		private RansomControlHack controlHack;

		public static bool invertControlsEnabled = false;

		private QuickMenuManager quickMenu;

		public static float cureLikeShakeMagnitude = 8f;

		public static float cureLikeShakeDuration = 0.25f;

		public bool IsInfectionActive => infectionActive;

		private void Awake()
		{
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
			audioSource.spatialBlend = 0f;
			musicAudioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
			musicAudioSource.spatialBlend = 0f;
			((MonoBehaviour)this).StartCoroutine(AssetLoader.LoadAudioClip("infection.mp3", delegate(AudioClip clip)
			{
				AssetLoader.AmplifyClip(clip, 7f);
				infectionMusic = clip;
			}));
			((MonoBehaviour)this).StartCoroutine(AssetLoader.LoadAudioClip("infection2.mp3", delegate(AudioClip clip)
			{
				AssetLoader.AmplifyClip(clip, 7f);
				infectionMusic2 = clip;
			}));
			((MonoBehaviour)this).StartCoroutine(AssetLoader.LoadAudioClip("infection3.mp3", delegate(AudioClip clip)
			{
				AssetLoader.AmplifyClip(clip, 7f);
				infectionMusic3 = clip;
			}));
			((MonoBehaviour)this).StartCoroutine(AssetLoader.LoadAudioClip("cured.mp3", delegate(AudioClip clip)
			{
				cureSound = clip;
			}));
			((MonoBehaviour)this).StartCoroutine(AssetLoader.LoadAudioClip("sell.mp3", delegate(AudioClip clip)
			{
				sellSound = clip;
			}));
			for (int num = 0; num < 5; num++)
			{
				int idx = num;
				((MonoBehaviour)this).StartCoroutine(AssetLoader.LoadAudioClip("Error" + (idx + 1) + ".mp3", delegate(AudioClip clip)
				{
					errorSounds[idx] = clip;
				}));
			}
			for (int num2 = 0; num2 < 43; num2++)
			{
				Sprite val = AssetLoader.LoadSprite("obstruction" + (num2 + 1) + ".png");
				if ((Object)(object)val == (Object)null)
				{
					val = CreateColorSprite(new Color(Random.value, Random.value, Random.value));
				}
				microSprites[num2] = val;
			}
			jumpscare = ((Component)this).GetComponent<RansomJumpscare>();
			controlHack = ((Component)this).gameObject.AddComponent<RansomControlHack>();
			quickMenu = Object.FindObjectOfType<QuickMenuManager>();
			SetupWindowUI();
			SetupCureUI();
			SetupSellPrompt();
			SetupVignette();
		}

		private Font GetTerminalFont(int size)
		{
			Font val = null;
			try
			{
				val = Font.CreateDynamicFontFromOSFont("3270", size);
			}
			catch
			{
				val = null;
			}
			if ((Object)(object)val == (Object)null)
			{
				val = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
			}
			return val;
		}

		private void SetupVignette()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_005d: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_00cb: 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)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			vignetteObject = new GameObject("RansomVignette");
			Canvas obj = vignetteObject.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 996;
			vignetteObject.AddComponent<CanvasScaler>();
			Texture2D val = GenerateVignetteTexture(256);
			Sprite sprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
			GameObject val2 = new GameObject("VignetteImage");
			val2.transform.SetParent(vignetteObject.transform, false);
			vignetteImage = val2.AddComponent<Image>();
			vignetteImage.sprite = sprite;
			((Graphic)vignetteImage).color = new Color(1f, 0f, 0f, 0.04f);
			RectTransform rectTransform = ((Graphic)vignetteImage).rectTransform;
			rectTransform.anchorMin = Vector2.zero;
			rectTransform.anchorMax = Vector2.one;
			rectTransform.offsetMin = Vector2.zero;
			rectTransform.offsetMax = Vector2.zero;
			vignetteObject.SetActive(false);
		}

		private Texture2D GenerateVignetteTexture(int size)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(size, size);
			((Texture)val).filterMode = (FilterMode)1;
			Color[] array = (Color[])(object)new Color[size * size];
			float num = (float)size / 2f;
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num2 = ((float)j - num) / num;
					float num3 = ((float)i - num) / num;
					float num4 = Mathf.Clamp01((Mathf.Sqrt(num2 * num2 + num3 * num3) - 0.7f) / 0.50000006f);
					array[i * size + j] = new Color(1f, 0f, 0f, num4);
				}
			}
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		private void SetupWindowUI()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			//IL_012e: 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_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: 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_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Expected O, but got Unknown
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			windowCanvasObject = new GameObject("RansomInfectionCanvas");
			Canvas obj = windowCanvasObject.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 998;
			windowCanvasObject.AddComponent<CanvasScaler>();
			windowCanvasObject.AddComponent<GraphicRaycaster>();
			Sprite val = AssetLoader.LoadSprite("ransom_panel.png");
			GameObject val2 = new GameObject("Panel");
			val2.transform.SetParent(windowCanvasObject.transform, false);
			Image val3 = val2.AddComponent<Image>();
			if ((Object)(object)val != (Object)null)
			{
				val3.sprite = val;
				((Graphic)val3).color = Color.white;
			}
			else
			{
				((Graphic)val3).color = new Color(0.1f, 0f, 0f, 0.9f);
			}
			windowPanel = ((Graphic)val3).rectTransform;
			windowPanel.sizeDelta = new Vector2(1057f, 800f);
			Font terminalFont = GetTerminalFont(28);
			GameObject val4 = new GameObject("MoneyText");
			val4.transform.SetParent(val2.transform, false);
			moneyText = val4.AddComponent<Text>();
			moneyText.font = terminalFont;
			moneyText.fontSize = 28;
			((Graphic)moneyText).color = Color.green;
			moneyText.alignment = (TextAnchor)3;
			RectTransform rectTransform = ((Graphic)moneyText).rectTransform;
			rectTransform.anchorMin = new Vector2(0.13f, 0.233f);
			rectTransform.anchorMax = new Vector2(0.94f, 0.313f);
			rectTransform.offsetMin = new Vector2(20f, 0f);
			rectTransform.offsetMax = new Vector2(-20f, 0f);
			GameObject val5 = new GameObject("Timer");
			val5.transform.SetParent(val2.transform, false);
			timerText = val5.AddComponent<Text>();
			timerText.font = terminalFont;
			timerText.fontSize = 30;
			((Graphic)timerText).color = Color.green;
			timerText.alignment = (TextAnchor)3;
			RectTransform rectTransform2 = ((Graphic)timerText).rectTransform;
			rectTransform2.anchorMin = new Vector2(0.6f, 0.233f);
			rectTransform2.anchorMax = new Vector2(0.7f, 0.313f);
			rectTransform2.offsetMin = new Vector2(10f, 0f);
			rectTransform2.offsetMax = new Vector2(-10f, 0f);
			windowCanvasObject.SetActive(false);
		}

		private void SetupCureUI()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_004d: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			cureImageObject = new GameObject("RansomCureCanvas");
			Canvas val = cureImageObject.AddComponent<Canvas>();
			val.renderMode = (RenderMode)0;
			val.sortingOrder = 997;
			cureImageObject.AddComponent<CanvasScaler>();
			cureCanvas = val;
			cureFrameImage = CreateCureLayer("Frame", "cure_frame.png", Color.white);
			cureBackgroundImage = CreateCureLayer("Background", "cure_background.png", Color.green);
			cureThankYouImage = CreateCureLayer("ThankYou", "cure_thankyou.png", Color.white);
			cureLikeImage = CreateCureLayer("Like", "cure_like.png", Color.white);
			cureImageObject.SetActive(false);
		}

		private Image CreateCureLayer(string name, string fileName, Color fallbackColor)
		{
			//IL_0019: 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_0064: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			Sprite val = AssetLoader.LoadSprite(fileName);
			if ((Object)(object)val == (Object)null)
			{
				val = CreateColorSprite(fallbackColor);
			}
			GameObject val2 = new GameObject(name);
			val2.transform.SetParent(cureImageObject.transform, false);
			Image obj = val2.AddComponent<Image>();
			obj.sprite = val;
			((Transform)((Graphic)obj).rectTransform).position = new Vector3((float)Screen.width / 2f, (float)Screen.height / 2f, 0f);
			((Transform)((Graphic)obj).rectTransform).localScale = Vector3.zero;
			return obj;
		}

		private void SetupSellPrompt()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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)
			sellPromptObject = new GameObject("RansomSellPrompt");
			Canvas obj = sellPromptObject.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 500;
			sellPromptObject.AddComponent<CanvasScaler>();
			GameObject val = new GameObject("SellPromptText");
			val.transform.SetParent(sellPromptObject.transform, false);
			sellPromptText = val.AddComponent<Text>();
			sellPromptText.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
			sellPromptText.fontSize = 20;
			((Graphic)sellPromptText).color = Color.white;
			sellPromptText.alignment = (TextAnchor)6;
			RectTransform rectTransform = ((Graphic)sellPromptText).rectTransform;
			rectTransform.anchorMin = new Vector2(0f, 0f);
			rectTransform.anchorMax = new Vector2(0f, 0f);
			rectTransform.pivot = new Vector2(0f, 0f);
			rectTransform.anchoredPosition = new Vector2(40f, 90f);
			rectTransform.sizeDelta = new Vector2(500f, 40f);
			sellPromptObject.SetActive(false);
		}

		private Sprite CreateColorSprite(Color color)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0019: 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_0021: 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_0029: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(2, 2);
			Color[] pixels = (Color[])(object)new Color[4] { color, color, color, color };
			val.SetPixels(pixels);
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, 2f, 2f), new Vector2(0.5f, 0.5f));
		}

		public void StartInfection()
		{
			//IL_0059: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			ransomAmount = CalculateRansomAmount();
			amountPaid = 0;
			displayedAmount = 0f;
			infectionTimer = infectionDuration;
			infectionActive = true;
			recentMicroIndices.Clear();
			windowBasePosition = new Vector3((float)Screen.width / 2f, (float)Screen.height / 2f, 0f);
			((Transform)windowPanel).position = windowBasePosition;
			repositionTimer = 3f;
			((MonoBehaviour)this).StartCoroutine(ShowInfectionWindow());
			UpdateTexts();
			vignetteObject.SetActive(true);
			microPopupLoopCoroutine = ((MonoBehaviour)this).StartCoroutine(MicroPopupLoop());
			if (invertControlsEnabled)
			{
				controlHack.SetInverted(value: true);
			}
			AudioClip val = infectionMusic;
			if (infectionMusicVariant == 1 && (Object)(object)infectionMusic2 != (Object)null)
			{
				val = infectionMusic2;
			}
			else if (infectionMusicVariant == 2 && (Object)(object)infectionMusic3 != (Object)null)
			{
				val = infectionMusic3;
			}
			if ((Object)(object)val != (Object)null && infectionMusicEnabled)
			{
				musicAudioSource.Stop();
				musicAudioSource.volume = infectionMusicVolumeMultiplier;
				musicAudioSource.clip = val;
				musicAudioSource.Play();
			}
		}

		public void CaptureLootValue()
		{
			lockedLootValue = GetTotalScrapValueOnLevel();
		}

		private IEnumerator ShowInfectionWindow()
		{
			windowCanvasObject.SetActive(true);
			float t = 0f;
			while (t < 0.2f)
			{
				t += Time.deltaTime;
				((Transform)windowPanel).localScale = Vector3.one * Mathf.Clamp01(t / 0.2f);
				yield return null;
			}
			((Transform)windowPanel).localScale = Vector3.one;
		}

		private IEnumerator HideInfectionWindow()
		{
			float t = 0f;
			while (t < 0.2f)
			{
				t += Time.deltaTime;
				((Transform)windowPanel).localScale = Vector3.one * (1f - Mathf.Clamp01(t / 0.2f));
				yield return null;
			}
			windowCanvasObject.SetActive(false);
		}

		private int CalculateRansomAmount()
		{
			int num = ((lockedLootValue >= 0) ? lockedLootValue : GetTotalScrapValueOnLevel());
			int num2 = Random.Range(-30, 51);
			return Mathf.Max(Mathf.RoundToInt((float)num * ransomPercent) + num2, ransomMinimum);
		}

		private int GetTotalScrapValueOnLevel()
		{
			int num = 0;
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			foreach (GrabbableObject val in array)
			{
				if ((Object)(object)val.itemProperties != (Object)null && val.itemProperties.isScrap && !val.isInShipRoom)
				{
					num += val.scrapValue;
				}
			}
			return num;
		}

		private int GetRouteCostPlaceholder()
		{
			return 0;
		}

		private int GetEquipmentSellValue(string itemName)
		{
			if (equipmentPrices.TryGetValue(itemName, out var value))
			{
				return value;
			}
			return 10;
		}

		private void Update()
		{
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: 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)
			if (!infectionActive)
			{
				return;
			}
			if ((Object)(object)StartOfRound.Instance != (Object)null && !StartOfRound.Instance.shipHasLanded)
			{
				OnLeftPlanet();
				return;
			}
			bool flag = (Object)(object)quickMenu != (Object)null && quickMenu.isMenuOpen;
			SetVisualsVisible(!flag);
			PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
			if ((Object)(object)val != (Object)null && (val.isPlayerDead || val.health <= 0))
			{
				AbortInfection();
				controlHack.SetInverted(value: false);
				return;
			}
			infectionTimer -= Time.deltaTime;
			displayedAmount = Mathf.MoveTowards(displayedAmount, (float)amountPaid, 250f * Time.deltaTime);
			UpdateTexts();
			if (!flag)
			{
				float shakeMagnitude = GetShakeMagnitude();
				Vector3 val2 = default(Vector3);
				((Vector3)(ref val2))..ctor(Random.Range(0f - shakeMagnitude, shakeMagnitude), Random.Range(0f - shakeMagnitude, shakeMagnitude), 0f);
				panelDriftTimer -= Time.deltaTime;
				if (panelDriftTimer <= 0f)
				{
					panelDriftOffset = Random.insideUnitCircle * 10f;
					panelDriftTimer = Random.Range(0.3f, 0.6f);
				}
				((Transform)windowPanel).position = windowBasePosition + val2 + Vector2.op_Implicit(panelDriftOffset);
				float num = (Mathf.Sin(Time.time * 1.2f) + 1f) / 2f;
				float num2 = Mathf.Lerp(0.04f, 0.14f, num);
				((Graphic)vignetteImage).color = new Color(1f, 0f, 0f, num2);
				repositionTimer -= Time.deltaTime;
				if (repositionTimer <= 0f)
				{
					RepositionWindow();
					repositionTimer = 3f;
				}
				PlayerControllerB val3 = GameNetworkManager.Instance?.localPlayerController;
				GrabbableObject val4 = (((Object)(object)val3 != (Object)null) ? val3.currentlyHeldObjectServer : null);
				bool flag2 = (Object)(object)val3 != (Object)null && val3.inTerminalMenu;
				bool flag3 = (Object)(object)val4 != (Object)null && !flag2;
				sellPromptObject.SetActive(false);
				int num3 = HUDManager.Instance.controlTipLines.Length - 1;
				if (flag3)
				{
					string text = (((Object)(object)val4.itemProperties != (Object)null) ? val4.itemProperties.itemName : "предмет");
					bool flag4 = (Object)(object)val4.itemProperties != (Object)null && val4.itemProperties.isScrap;
					string text2;
					if (text == "Key")
					{
						text2 = "Sell " + text + " for 3 credits: [C]";
					}
					else if (flag4)
					{
						text2 = "Sell " + text + " for " + val4.scrapValue + " credits: [C]";
					}
					else
					{
						int equipmentSellValue = GetEquipmentSellValue(text);
						text2 = "Sell " + text + " for " + equipmentSellValue + " credits: [C]";
					}
					HUDManager.Instance.ChangeControlTip(num3, text2, false);
				}
				else
				{
					HUDManager.Instance.ChangeControlTip(num3, "", false);
				}
				if (flag3 && Keyboard.current != null && ((ButtonControl)Keyboard.current.cKey).wasPressedThisFrame)
				{
					SellHeldItem(val3);
				}
			}
			if (displayedAmount >= (float)ransomAmount)
			{
				CureInfection();
				controlHack.SetInverted(value: false);
			}
			else if (infectionTimer <= 0f)
			{
				TriggerDeath();
				controlHack.SetInverted(value: false);
			}
		}

		private void SetVisualsVisible(bool visible)
		{
			if (windowCanvasObject.activeSelf != visible && infectionActive)
			{
				windowCanvasObject.SetActive(visible);
			}
			vignetteObject.SetActive(visible && infectionActive);
			foreach (GameObject activeMicroPopup in activeMicroPopups)
			{
				if (!((Object)(object)activeMicroPopup == (Object)null))
				{
					Canvas component = activeMicroPopup.GetComponent<Canvas>();
					if ((Object)(object)component != (Object)null)
					{
						((Behaviour)component).enabled = visible;
					}
				}
			}
		}

		private void AbortInfection()
		{
			infectionActive = false;
			windowCanvasObject.SetActive(false);
			sellPromptObject.SetActive(false);
			HUDManager.Instance.ChangeControlTip(HUDManager.Instance.controlTipLines.Length - 1, "", false);
			StopMicroPopups();
			vignetteObject.SetActive(false);
			audioSource.Stop();
			musicAudioSource.Stop();
		}

		private void OnLeftPlanet()
		{
			infectionActive = false;
			windowCanvasObject.SetActive(false);
			sellPromptObject.SetActive(false);
			HUDManager.Instance.ChangeControlTip(HUDManager.Instance.controlTipLines.Length - 1, "", false);
			StopMicroPopups();
			vignetteObject.SetActive(false);
			audioSource.Stop();
			musicAudioSource.Stop();
		}

		private void SellHeldItem(PlayerControllerB player)
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer;
			if (!((Object)(object)currentlyHeldObjectServer == (Object)null))
			{
				string text = (((Object)(object)currentlyHeldObjectServer.itemProperties != (Object)null) ? currentlyHeldObjectServer.itemProperties.itemName : "");
				int num = ((text == "Key") ? 3 : ((!((Object)(object)currentlyHeldObjectServer.itemProperties != (Object)null) || !currentlyHeldObjectServer.itemProperties.isScrap) ? GetEquipmentSellValue(text) : currentlyHeldObjectServer.scrapValue));
				amountPaid += num;
				if ((Object)(object)sellSound != (Object)null)
				{
					audioSource.PlayOneShot(sellSound, sellSoundVolumeMultiplier);
				}
				player.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true);
				if ((Object)(object)currentlyHeldObjectServer != (Object)null && (Object)(object)((Component)currentlyHeldObjectServer).gameObject != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)currentlyHeldObjectServer).gameObject);
				}
			}
		}

		private void CureInfection()
		{
			infectionActive = false;
			sellPromptObject.SetActive(false);
			HUDManager.Instance.ChangeControlTip(HUDManager.Instance.controlTipLines.Length - 1, "", false);
			StopMicroPopups();
			vignetteObject.SetActive(false);
			audioSource.Stop();
			musicAudioSource.Stop();
			((MonoBehaviour)this).StartCoroutine(CureSequence());
		}

		private IEnumerator CureSequence()
		{
			Vector3 panelLastPosition = ((Transform)windowPanel).position;
			yield return ((MonoBehaviour)this).StartCoroutine(HideInfectionWindow());
			yield return ((MonoBehaviour)this).StartCoroutine(ShowCureImage(panelLastPosition));
		}

		private IEnumerator ShowCureImage(Vector3 startPosition)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			cureImageObject.SetActive(true);
			Vector3 center = new Vector3((float)Screen.width / 2f, (float)Screen.height / 2f + 0f, 0f);
			((Graphic)cureFrameImage).rectTransform.sizeDelta = cureFrameSize;
			((Transform)((Graphic)cureFrameImage).rectTransform).position = startPosition;
			((Transform)((Graphic)cureFrameImage).rectTransform).localScale = Vector3.zero;
			((Graphic)cureBackgroundImage).rectTransform.sizeDelta = cureBackgroundSize;
			((Transform)((Graphic)cureBackgroundImage).rectTransform).position = center + Vector2.op_Implicit(cureBackgroundPositionOffset);
			((Transform)((Graphic)cureBackgroundImage).rectTransform).localScale = Vector3.zero;
			((Graphic)cureLikeImage).rectTransform.sizeDelta = cureLikeSize;
			((Transform)((Graphic)cureLikeImage).rectTransform).position = center + Vector2.op_Implicit(cureLikePositionOffset);
			((Transform)((Graphic)cureLikeImage).rectTransform).localScale = Vector3.zero;
			((Graphic)cureThankYouImage).rectTransform.sizeDelta = cureThankYouSize;
			((Transform)((Graphic)cureThankYouImage).rectTransform).position = center + Vector2.op_Implicit(cureThankYouPositionOffset);
			((Transform)((Graphic)cureThankYouImage).rectTransform).localScale = Vector3.zero;
			yield return GrowLayer(((Graphic)cureFrameImage).rectTransform, cureFramePopDuration);
			yield return HoldWithMenuCheck(cureFrameStandDuration);
			yield return MoveLayer(((Graphic)cureFrameImage).rectTransform, startPosition, center, cureFrameMoveDuration);
			if ((Object)(object)cureSound != (Object)null)
			{
				audioSource.volume = cureSoundVolumeMultiplier;
				audioSource.clip = cureSound;
				audioSource.Play();
			}
			yield return GrowLayer(((Graphic)cureBackgroundImage).rectTransform, cureBackgroundPopDuration);
			yield return HoldWithMenuCheck(cureLikeDelayAfterBackground);
			yield return GrowLayer(((Graphic)cureLikeImage).rectTransform, cureLikePopDuration);
			((MonoBehaviour)this).StartCoroutine(ShakeLikeOnce());
			yield return HoldWithMenuCheck(cureThankYouDelayAfterLike);
			yield return GrowAndMoveLayer(((Graphic)cureThankYouImage).rectTransform, center, center + Vector2.op_Implicit(cureThankYouPositionOffset), cureThankYouPopDuration);
			yield return HoldWithMenuCheck(cureHoldDurationAfterThankYou);
			yield return ShrinkAllCureLayers(cureShrinkDuration);
			cureImageObject.SetActive(false);
		}

		private IEnumerator GrowLayer(RectTransform rt, float duration)
		{
			float t = 0f;
			while (t < duration)
			{
				t += Time.deltaTime;
				((Transform)rt).localScale = Vector3.one * Mathf.Clamp01(t / duration);
				((Behaviour)cureCanvas).enabled = !((Object)(object)quickMenu != (Object)null) || !quickMenu.isMenuOpen;
				yield return null;
			}
			((Transform)rt).localScale = Vector3.one;
		}

		private IEnumerator GrowAndMoveLayer(RectTransform rt, Vector3 fromPos, Vector3 toPos, float duration)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			float t = 0f;
			while (t < duration)
			{
				t += Time.deltaTime;
				float num = Mathf.Clamp01(t / duration);
				((Transform)rt).localScale = Vector3.one * num;
				((Transform)rt).position = Vector3.Lerp(fromPos, toPos, num);
				yield return null;
			}
			((Transform)rt).localScale = Vector3.one;
			((Transform)rt).position = toPos;
		}

		private IEnumerator GrowLayersParallel(RectTransform[] layers, float duration)
		{
			float t = 0f;
			RectTransform[] array;
			while (t < duration)
			{
				t += Time.deltaTime;
				float num = Mathf.Clamp01(t / duration);
				array = layers;
				for (int i = 0; i < array.Length; i++)
				{
					((Transform)array[i]).localScale = Vector3.one * num;
				}
				((Behaviour)cureCanvas).enabled = !((Object)(object)quickMenu != (Object)null) || !quickMenu.isMenuOpen;
				yield return null;
			}
			array = layers;
			for (int i = 0; i < array.Length; i++)
			{
				((Transform)array[i]).localScale = Vector3.one;
			}
		}

		private IEnumerator ShakeLikeOnce()
		{
			Vector3 basePos = ((Transform)((Graphic)cureLikeImage).rectTransform).position;
			float t = 0f;
			Vector3 val = default(Vector3);
			while (t < cureLikeShakeDuration)
			{
				t += Time.deltaTime;
				((Vector3)(ref val))..ctor(Random.Range(0f - cureLikeShakeMagnitude, cureLikeShakeMagnitude), Random.Range(0f - cureLikeShakeMagnitude, cureLikeShakeMagnitude), 0f);
				((Transform)((Graphic)cureLikeImage).rectTransform).position = basePos + val;
				yield return null;
			}
			((Transform)((Graphic)cureLikeImage).rectTransform).position = basePos;
		}

		private IEnumerator MoveLayer(RectTransform rt, Vector3 from, Vector3 to, float duration)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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)
			float t = 0f;
			while (t < duration)
			{
				t += Time.deltaTime;
				((Transform)rt).position = Vector3.Lerp(from, to, Mathf.Clamp01(t / duration));
				((Behaviour)cureCanvas).enabled = !((Object)(object)quickMenu != (Object)null) || !quickMenu.isMenuOpen;
				yield return null;
			}
			((Transform)rt).position = to;
		}

		private IEnumerator HoldWithMenuCheck(float duration)
		{
			float t = 0f;
			while (t < duration)
			{
				t += Time.deltaTime;
				((Behaviour)cureCanvas).enabled = !((Object)(object)quickMenu != (Object)null) || !quickMenu.isMenuOpen;
				yield return null;
			}
		}

		private IEnumerator ShrinkAllCureLayers(float duration)
		{
			Vector3 center = new Vector3((float)Screen.width / 2f, (float)Screen.height / 2f, 0f);
			Vector3 thankYouStartPos = ((Transform)((Graphic)cureThankYouImage).rectTransform).position;
			float t = 0f;
			while (t < duration)
			{
				t += Time.deltaTime;
				float num = Mathf.Clamp01(t / duration);
				float num2 = 1f - num;
				((Transform)((Graphic)cureFrameImage).rectTransform).localScale = Vector3.one * num2;
				((Transform)((Graphic)cureBackgroundImage).rectTransform).localScale = Vector3.one * num2;
				((Transform)((Graphic)cureLikeImage).rectTransform).localScale = Vector3.one * num2;
				((Transform)((Graphic)cureThankYouImage).rectTransform).localScale = Vector3.one * num2;
				((Transform)((Graphic)cureThankYouImage).rectTransform).position = Vector3.Lerp(thankYouStartPos, center, num);
				((Behaviour)cureCanvas).enabled = !((Object)(object)quickMenu != (Object)null) || !quickMenu.isMenuOpen;
				yield return null;
			}
		}

		private IEnumerator GrowLayer(RectTransform rt, float waitBefore, float growDuration)
		{
			if (waitBefore > 0f)
			{
				yield return (object)new WaitForSeconds(waitBefore);
			}
			float t = 0f;
			while (t < growDuration)
			{
				t += Time.deltaTime;
				((Transform)rt).localScale = Vector3.one * Mathf.Clamp01(t / growDuration);
				((Behaviour)cureCanvas).enabled = !((Object)(object)quickMenu != (Object)null) || !quickMenu.isMenuOpen;
				yield return null;
			}
			((Transform)rt).localScale = Vector3.one;
		}

		private void TriggerDeath()
		{
			infectionActive = false;
			sellPromptObject.SetActive(false);
			HUDManager.Instance.ChangeControlTip(HUDManager.Instance.controlTipLines.Length - 1, "", false);
			StopMicroPopups();
			vignetteObject.SetActive(false);
			audioSource.Stop();
			musicAudioSource.Stop();
			((MonoBehaviour)this).StartCoroutine(HideInfectionWindow());
			jumpscare.TriggerDeathJumpscare(delegate
			{
				//IL_0056: 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_0036: 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_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
				if ((Object)(object)val != (Object)null)
				{
					RansomNetworking component = ((Component)val).GetComponent<RansomNetworking>();
					if ((Object)(object)component != (Object)null)
					{
						Vector3 position = ((Component)val).transform.position;
						component.TriggerExplosionServerRpc(position.x, position.y, position.z);
					}
					else
					{
						Landmine.SpawnExplosion(((Component)val).transform.position, true, 10f, 10f, 0, 0f, (GameObject)null, false);
					}
				}
			});
		}

		private void RepositionWindow()
		{
			//IL_0006: 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_0054: 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)
			float num = windowPanel.sizeDelta.x / 2f;
			float num2 = windowPanel.sizeDelta.y / 2f;
			float num3 = Random.Range(num, (float)Screen.width - num);
			float num4 = Random.Range(num2, (float)Screen.height - num2);
			windowBasePosition = new Vector3(num3, num4, 0f);
		}

		private float GetShakeMagnitude()
		{
			if (infectionTimer <= stage3ThresholdSeconds)
			{
				return 9f;
			}
			if (infectionTimer <= stage2ThresholdSeconds)
			{
				return 6f;
			}
			return 3f;
		}

		private void UpdateTexts()
		{
			if ((Object)(object)moneyText != (Object)null)
			{
				moneyText.text = "RANSOM: " + Mathf.RoundToInt(displayedAmount) + " / " + ransomAmount;
			}
			if ((Object)(object)timerText != (Object)null)
			{
				int num = Mathf.CeilToInt(Mathf.Max(0f, infectionTimer));
				int num2 = num / 60;
				int num3 = num % 60;
				timerText.text = $"{num2}:{num3:00}";
			}
		}

		private IEnumerator MicroPopupLoop()
		{
			while (infectionActive && !popupSpawningDisabledAfterInitial)
			{
				float num = ((infectionTimer <= stage3ThresholdSeconds) ? microPopupSpawnIntervalCritical : ((!(infectionTimer <= stage2ThresholdSeconds)) ? microPopupSpawnInterval : microPopupSpawnIntervalUrgent));
				yield return (object)new WaitForSeconds(num);
				SpawnMicroPopup();
			}
		}

		public void ShowVignette()
		{
			vignetteObject.SetActive(true);
		}

		public void HideVignette()
		{
			vignetteObject.SetActive(false);
		}

		private int PickMicroSpriteIndex()
		{
			List<int> list = new List<int>();
			for (int i = 0; i < microSprites.Length; i++)
			{
				if (!recentMicroIndices.Contains(i))
				{
					list.Add(i);
				}
			}
			if (list.Count == 0)
			{
				list.Add(Random.Range(0, microSprites.Length));
			}
			int num = list[Random.Range(0, list.Count)];
			recentMicroIndices.Enqueue(num);
			if (recentMicroIndices.Count > 28)
			{
				recentMicroIndices.Dequeue();
			}
			return num;
		}

		public void SpawnMicroPopup(bool playSound = true)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			Sprite sprite = microSprites[PickMicroSpriteIndex()];
			if (playSound)
			{
				AudioClip val = errorSounds[Random.Range(0, errorSounds.Length)];
				if ((Object)(object)val != (Object)null)
				{
					audioSource.PlayOneShot(val, 0.7f * popupSoundVolumeMultiplier);
				}
			}
			GameObject val2 = new GameObject("RansomMicroPopup");
			Canvas obj = val2.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 995;
			val2.AddComponent<CanvasScaler>();
			GameObject val3 = new GameObject("Image");
			val3.transform.SetParent(val2.transform, false);
			Image obj2 = val3.AddComponent<Image>();
			obj2.sprite = sprite;
			RectTransform rectTransform = ((Graphic)obj2).rectTransform;
			rectTransform.sizeDelta = new Vector2(500f, 500f);
			float num = 250f;
			float num2 = Random.Range(num, (float)Screen.width - num);
			float num3 = Random.Range(num, (float)Screen.height - num);
			((Transform)rectTransform).position = new Vector3(num2, num3, 0f);
			activeMicroPopups.Add(val2);
			((MonoBehaviour)this).StartCoroutine(MicroPopupLifecycle(val2, rectTransform, microPopupLifetime));
		}

		private IEnumerator MicroPopupLifecycle(GameObject obj, RectTransform rt, float lifetime)
		{
			float t = 0f;
			while (t < 0.1f)
			{
				if ((Object)(object)rt == (Object)null)
				{
					yield break;
				}
				t += Time.deltaTime;
				((Transform)rt).localScale = Vector3.one * Mathf.Clamp01(t / 0.1f);
				yield return null;
			}
			((Transform)rt).localScale = Vector3.one;
			Vector3 basePos = ((Transform)rt).position;
			float idleTime = 0f;
			Vector2 popupDriftOffset = Vector2.zero;
			float popupDriftTimer = 0f;
			float popupRepositionTimer = Random.Range(1.8f, 3.4f);
			float popupMargin = 250f;
			Vector3 val = default(Vector3);
			while (idleTime < lifetime)
			{
				if ((Object)(object)rt == (Object)null)
				{
					yield break;
				}
				idleTime += Time.deltaTime;
				popupDriftTimer -= Time.deltaTime;
				if (popupDriftTimer <= 0f)
				{
					popupDriftOffset = Random.insideUnitCircle * 10f;
					popupDriftTimer = Random.Range(0.3f, 0.6f);
				}
				popupRepositionTimer -= Time.deltaTime;
				if (popupRepositionTimer <= 0f)
				{
					float num = Random.Range(popupMargin, (float)Screen.width - popupMargin);
					float num2 = Random.Range(popupMargin, (float)Screen.height - popupMargin);
					basePos = new Vector3(num, num2, 0f);
					popupRepositionTimer = Random.Range(1.8f, 3.4f);
				}
				float shakeMagnitude = GetShakeMagnitude();
				((Vector3)(ref val))..ctor(Random.Range(0f - shakeMagnitude, shakeMagnitude), Random.Range(0f - shakeMagnitude, shakeMagnitude), 0f);
				((Transform)rt).position = basePos + val + Vector2.op_Implicit(popupDriftOffset);
				yield return null;
			}
			t = 0f;
			while (t < 0.1f)
			{
				if ((Object)(object)rt == (Object)null)
				{
					yield break;
				}
				t += Time.deltaTime;
				((Transform)rt).localScale = Vector3.one * (1f - Mathf.Clamp01(t / 0.1f));
				yield return null;
			}
			activeMicroPopups.Remove(obj);
			if ((Object)(object)obj != (Object)null)
			{
				Object.Destroy((Object)(object)obj);
			}
		}

		public void StopMicroPopups()
		{
			if (microPopupLoopCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(microPopupLoopCoroutine);
				microPopupLoopCoroutine = null;
			}
			List<GameObject> list = new List<GameObject>(activeMicroPopups);
			activeMicroPopups.Clear();
			foreach (GameObject item in list)
			{
				if (!((Object)(object)item == (Object)null))
				{
					Image componentInChildren = item.GetComponentInChildren<Image>();
					if ((Object)(object)componentInChildren != (Object)null)
					{
						((MonoBehaviour)this).StartCoroutine(FadeOutMicroPopup(item, ((Graphic)componentInChildren).rectTransform));
					}
					else
					{
						Object.Destroy((Object)(object)item);
					}
				}
			}
			Canvas[] array = Object.FindObjectsOfType<Canvas>();
			foreach (Canvas val in array)
			{
				if ((Object)(object)val != (Object)null && ((Object)((Component)val).gameObject).name == "RansomMicroPopup" && !list.Contains(((Component)val).gameObject))
				{
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
			}
		}

		private IEnumerator FadeOutMicroPopup(GameObject obj, RectTransform rt)
		{
			float t = 0f;
			while (t < 0.1f)
			{
				t += Time.deltaTime;
				if ((Object)(object)rt != (Object)null)
				{
					((Transform)rt).localScale = Vector3.one * (1f - Mathf.Clamp01(t / 0.1f));
				}
				yield return null;
			}
			if ((Object)(object)obj != (Object)null)
			{
				Object.Destroy((Object)(object)obj);
			}
		}
	}
	public class RansomJumpscare : MonoBehaviour
	{
		private enum State
		{
			Inactive,
			Phase1,
			Phase2,
			Phase2_5,
			Phase3,
			Phase4,
			Phase5,
			DeathReplay,
			AbsoluteFlash
		}

		private State state;

		private float timer;

		public static float phase1Duration = 0.3f;

		public static float phase2Duration = 0.4f;

		public static float phase2_5Duration = 0.3f;

		public static float phase3Duration = 0.2f;

		public static int phase4DamageAmount = 30;

		private const float phase4Duration = 1f;

		private const float phase5Duration = 0.91f;

		private const float deathReplayDuration = 1.2f;

		private GameObject canvasObject;

		private Image backgroundOverlay;

		private Image noiseOverlay;

		private Image faceImage;

		private AudioSource audioSource;

		private Sprite sprite1;

		private Sprite sprite2;

		private Sprite sprite3;

		private Sprite sprite4;

		private AudioClip approachSound;

		private AudioClip jumpscareSound;

		private AudioClip jumpscareSound2;

		private AudioClip stopSound;

		public static float absoluteRansomChance = 0f;

		private const float absoluteRansomDelay = 0.4f;

		private const float absoluteRansomDuration = 0.25f;

		private float loadingPopupTimer;

		private const float loadingPopupInterval = 0.15f;

		private Action deathReplayCallback;

		private Texture2D noiseTexture;

		private const int noiseTexSize = 64;

		private bool noiseActive;

		private float noiseDensity;

		private float noiseSpeckAlpha = 1f;

		private float noiseTimer;

		private const float noiseUpdateInterval = 0.05f;

		private Color baseBackgroundColor = Color.clear;

		private float animTimer;

		private const float animInterval = 0.1f;

		private bool showingSprite3 = true;

		private const float shakeMagnitude = 15f;

		private const bool debugSpawnKeyEnabled = false;

		public bool IsActive => state != State.Inactive;

		private void Awake()
		{
			audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
			audioSource.spatialBlend = 0f;
			SetupUI();
			LoadOrCreatePlaceholders();
			((MonoBehaviour)this).StartCoroutine(AssetLoader.LoadAudioClip("ransom.mp3", delegate(AudioClip clip)
			{
				approachSound = clip;
			}));
			((MonoBehaviour)this).StartCoroutine(AssetLoader.LoadAudioClip("jumpscare.mp3", delegate(AudioClip clip)
			{
				jumpscareSound = clip;
			}));
			((MonoBehaviour)this).StartCoroutine(AssetLoader.LoadAudioClip("stop.mp3", delegate(AudioClip clip)
			{
				stopSound = clip;
			}));
			((MonoBehaviour)this).StartCoroutine(AssetLoader.LoadAudioClip("jumpscare2.mp3", delegate(AudioClip clip)
			{
				AssetLoader.AmplifyClip(clip, 30f);
				jumpscareSound2 = clip;
			}));
		}

		private void SetupUI()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_011c: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			canvasObject = new GameObject("RansomCanvas");
			Canvas obj = canvasObject.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 999;
			canvasObject.AddComponent<CanvasScaler>();
			canvasObject.AddComponent<GraphicRaycaster>();
			GameObject val = new GameObject("Background");
			val.transform.SetParent(canvasObject.transform, false);
			backgroundOverlay = val.AddComponent<Image>();
			((Graphic)backgroundOverlay).color = new Color(0f, 0f, 0f, 0f);
			SetFullScreen(((Graphic)backgroundOverlay).rectTransform);
			noiseTexture = new Texture2D(64, 64);
			((Texture)noiseTexture).filterMode = (FilterMode)0;
			((Texture)noiseTexture).wrapMode = (TextureWrapMode)0;
			GameObject val2 = new GameObject("NoiseOverlay");
			val2.transform.SetParent(canvasObject.transform, false);
			noiseOverlay = val2.AddComponent<Image>();
			noiseOverlay.sprite = Sprite.Create(noiseTexture, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f));
			noiseOverlay.type = (Type)2;
			((Graphic)noiseOverlay).color = Color.white;
			SetFullScreen(((Graphic)noiseOverlay).rectTransform);
			GameObject val3 = new GameObject("FaceImage");
			val3.transform.SetParent(canvasObject.transform, false);
			faceImage = val3.AddComponent<Image>();
			((Graphic)faceImage).rectTransform.sizeDelta = new Vector2(200f, 200f);
			canvasObject.SetActive(false);
		}

		private void SetFullScreen(RectTransform rt)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = Vector2.zero;
			rt.anchorMax = Vector2.one;
			rt.offsetMin = Vector2.zero;
			rt.offsetMax = Vector2.zero;
		}

		private void GenerateNoiseTexture(float density, float speckAlpha)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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)
			Color[] array = (Color[])(object)new Color[4096];
			for (int i = 0; i < array.Length; i++)
			{
				if (Random.value < density)
				{
					float num = Random.Range(0.25f, 1f);
					array[i] = new Color(num, 0f, 0f, speckAlpha);
				}
				else
				{
					array[i] = new Color(0f, 0f, 0f, 0f);
				}
			}
			noiseTexture.SetPixels(array);
			noiseTexture.Apply();
		}

		private void SetNoise(bool active, float density, float speckAlpha)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			noiseActive = active;
			noiseDensity = density;
			noiseSpeckAlpha = speckAlpha;
			((Behaviour)noiseOverlay).enabled = active;
			if (!active)
			{
				((Graphic)noiseOverlay).rectTransform.anchoredPosition = Vector2.zero;
			}
		}

		private void LoadOrCreatePlaceholders()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			sprite1 = AssetLoader.LoadSprite("sprite1.png");
			if ((Object)(object)sprite1 == (Object)null)
			{
				sprite1 = CreateColorSprite(Color.yellow);
			}
			sprite2 = AssetLoader.LoadSprite("sprite2.png");
			if ((Object)(object)sprite2 == (Object)null)
			{
				sprite2 = CreateColorSprite(Color.white);
			}
			sprite3 = AssetLoader.LoadSprite("sprite3.png");
			if ((Object)(object)sprite3 == (Object)null)
			{
				sprite3 = CreateColorSprite(Color.red);
			}
			sprite4 = AssetLoader.LoadSprite("sprite4.png");
			if ((Object)(object)sprite4 == (Object)null)
			{
				sprite4 = CreateColorSprite(Color.magenta);
			}
		}

		private Sprite CreateColorSprite(Color color)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0019: 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_0021: 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_0029: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(2, 2);
			Color[] pixels = (Color[])(object)new Color[4] { color, color, color, color };
			val.SetPixels(pixels);
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, 2f, 2f), new Vector2(0.5f, 0.5f));
		}

		private void Update()
		{
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			if (state == State.Inactive)
			{
				return;
			}
			if ((Object)(object)StartOfRound.Instance != (Object)null && !StartOfRound.Instance.shipHasLanded)
			{
				state = State.Inactive;
				SetNoise(active: false, 0f, 0f);
				canvasObject.SetActive(false);
				audioSource.Stop();
				return;
			}
			timer -= Time.deltaTime;
			if (noiseActive)
			{
				noiseTimer -= Time.deltaTime;
				if (noiseTimer <= 0f)
				{
					GenerateNoiseTexture(noiseDensity, noiseSpeckAlpha);
					((Graphic)noiseOverlay).rectTransform.anchoredPosition = new Vector2(Random.Range(-8f, 8f), Random.Range(-8f, 8f));
					noiseTimer = 0.05f;
				}
				if (baseBackgroundColor.a > 0f)
				{
					float num = Random.Range(0.7f, 1f);
					((Graphic)backgroundOverlay).color = new Color(baseBackgroundColor.r * num, 0f, 0f, baseBackgroundColor.a);
				}
			}
			switch (state)
			{
			case State.Phase1:
				if (timer <= 0f)
				{
					EnterPhase2();
				}
				break;
			case State.Phase2:
				if (timer <= 0f)
				{
					EnterPhase2_5();
				}
				break;
			case State.Phase2_5:
				if (timer <= 0f)
				{
					EnterPhase3();
				}
				break;
			case State.Phase3:
				if (InputHelper.IsPlayerGivingInput())
				{
					EnterPhase4();
				}
				else if (timer <= 0f)
				{
					OnSurvived();
				}
				break;
			case State.Phase4:
				animTimer -= Time.deltaTime;
				if (animTimer <= 0f)
				{
					showingSprite3 = !showingSprite3;
					faceImage.sprite = (showingSprite3 ? sprite3 : sprite4);
					animTimer = 0.1f;
				}
				ApplyScreenShake();
				if (timer <= 0f)
				{
					PlayerControllerB val2 = GameNetworkManager.Instance?.localPlayerController;
					if ((Object)(object)val2 != (Object)null && val2.isPlayerDead)
					{
						state = State.Inactive;
						SetNoise(active: false, 0f, 0f);
						canvasObject.SetActive(false);
					}
					else
					{
						EnterPhase5();
					}
				}
				break;
			case State.Phase5:
			{
				loadingPopupTimer -= Time.deltaTime;
				if (loadingPopupTimer <= 0f)
				{
					((Component)this).GetComponent<RansomInfection>()?.SpawnMicroPopup(playSound: false);
					loadingPopupTimer = 0.15f;
				}
				if (!(timer <= 0f))
				{
					break;
				}
				state = State.Inactive;
				PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
				if ((Object)(object)val != (Object)null)
				{
					val.DamagePlayer(phase4DamageAmount, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				}
				if ((Object)(object)val != (Object)null && (val.isPlayerDead || val.health <= 0))
				{
					((Component)this).GetComponent<RansomInfection>()?.StopMicroPopups();
					((Component)this).GetComponent<RansomInfection>()?.HideVignette();
					RansomNetworking component = ((Component)val).GetComponent<RansomNetworking>();
					if ((Object)(object)component != (Object)null)
					{
						Plugin.Log.LogInfo((object)"Ransom DEBUG: сетевой компонент найден, вызываю RPC");
						Vector3 position = ((Component)val).transform.position;
						component.TriggerExplosionServerRpc(position.x, position.y, position.z);
					}
					else
					{
						Plugin.Log.LogWarning((object)"Ransom DEBUG: сетевой компонент НЕ найден, локальный взрыв без сети");
						Landmine.SpawnExplosion(((Component)val).transform.position, true, 0f, 0f, 0, 0f, (GameObject)null, false);
					}
				}
				else
				{
					((Component)this).GetComponent<RansomInfection>()?.StartInfection();
				}
				break;
			}
			case State.DeathReplay:
				animTimer -= Time.deltaTime;
				if (animTimer <= 0f)
				{
					showingSprite3 = !showingSprite3;
					faceImage.sprite = (showingSprite3 ? sprite3 : sprite4);
					animTimer = 0.1f;
				}
				ApplyScreenShake();
				if (timer <= 0f)
				{
					state = State.Inactive;
					SetNoise(active: false, 0f, 0f);
					canvasObject.SetActive(false);
					deathReplayCallback?.Invoke();
					deathReplayCallback = null;
				}
				break;
			}
		}

		private void ApplyScreenShake()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector2.op_Implicit(Random.insideUnitCircle * 15f);
			((Transform)((Graphic)faceImage).rectTransform).position = new Vector3((float)Screen.width / 2f, (float)Screen.height / 2f, 0f) + val;
		}

		public void TriggerAttack()
		{
			if (state == State.Inactive)
			{
				StartSequence();
			}
		}

		private void StartSequence()
		{
			//IL_0029: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			state = State.Phase1;
			timer = phase1Duration;
			canvasObject.SetActive(true);
			((Transform)((Graphic)faceImage).rectTransform).rotation = Quaternion.identity;
			baseBackgroundColor = new Color(0f, 0f, 0f, 0f);
			((Graphic)backgroundOverlay).color = baseBackgroundColor;
			SetNoise(active: false, 0f, 0f);
			faceImage.sprite = sprite1;
			((Graphic)faceImage).rectTransform.sizeDelta = new Vector2(400f, 400f);
			float num = Random.Range(150f, (float)Screen.width - 150f);
			float num2 = Random.Range(150f, (float)Screen.height - 150f);
			((Transform)((Graphic)faceImage).rectTransform).position = new Vector3(num, num2, 0f);
			PlaySound(approachSound);
		}

		private void EnterPhase2()
		{
			//IL_0027: 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_0038: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			state = State.Phase2;
			timer = phase2Duration;
			baseBackgroundColor = new Color(0f, 0f, 0f, 1f);