Decompiled source of Ransom v1.6.1

BepInEx/plugins/Ransom.dll

Decompiled 3 weeks 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 GameNetcodeStuff;
using LethalConfig;
using LethalConfig.ConfigItems;
using RuntimeNetcodeRPCValidator;
using TMPro;
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 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: error: " + 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: error2: " + 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: error3: " + 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: error4: " + 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.6.1")]
[BepInDependency("NicholaScott.BepInEx.RuntimeNetcodeRPCValidator", "0.2.5")]
public class Plugin : BaseUnityPlugin
{
	internal static ManualLogSource Log;

	public static ConfigFile ConfigFileInstance;

	private NetcodeValidator netcodeValidator;

	private void Awake()
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		Log.LogInfo((object)"Ransom mod loaded.");
		ConfigFileInstance = ((BaseUnityPlugin)this).Config;
		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)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: 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>();
			val.AddComponent<RansomEdgeNoise>();
			val.AddComponent<RansomComplexHack>();
		}
	}
}
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 Destroy");
	}

	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 class RansomComplexHack : MonoBehaviour
{
	private class LightEntry
	{
		public Light light;

		public Color original;

		public Color assigned;

		public float hueOffset;
	}

	public static bool enabledInConfig = false;

	public static bool partyModeInConfig = false;

	private const float FacilityMaxY = -100f;

	private const float PartyHueSpeed = 0.15f;

	private const float FlickerDuration = 0.7f;

	private const float FlickerStepMin = 0.04f;

	private const float FlickerStepMax = 0.12f;

	private const string FlickerSoundName = "";

	private const float FlickerSoundVolume = 0.8f;

	private static readonly Color RedColor = new Color(1f, 0.04f, 0.04f);

	private static readonly HashSet<int> infectedPlayerIds = new HashSet<int>();

	private readonly List<LightEntry> entries = new List<LightEntry>();

	private RansomInfection infection;

	private AudioSource audioSource;

	private AudioClip flickerClip;

	private bool flickerClipSearched;

	private bool lastReportedInfected;

	private bool effectActive;

	private bool transitioning;

	public static void SetPlayerInfected(int playerId, bool infected)
	{
		if (infected)
		{
			infectedPlayerIds.Add(playerId);
		}
		else
		{
			infectedPlayerIds.Remove(playerId);
		}
	}

	private void Awake()
	{
		audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
		audioSource.spatialBlend = 0f;
	}

	private void Update()
	{
		if ((Object)(object)infection == (Object)null)
		{
			infection = ((Component)this).GetComponent<RansomInfection>();
		}
		ReportLocalInfection();
		bool flag = (Object)(object)StartOfRound.Instance != (Object)null && StartOfRound.Instance.shipHasLanded;
		if (!flag)
		{
			infectedPlayerIds.Clear();
		}
		bool flag2 = enabledInConfig && flag && infectedPlayerIds.Count > 0;
		if (!transitioning)
		{
			if (flag2 != effectActive)
			{
				((MonoBehaviour)this).StartCoroutine(Transition(flag2));
			}
			else if (effectActive && partyModeInConfig)
			{
				UpdatePartyColors();
			}
		}
	}

	private void ReportLocalInfection()
	{
		bool flag = (Object)(object)infection != (Object)null && infection.IsInfectionActive;
		if (flag == lastReportedInfected)
		{
			return;
		}
		lastReportedInfected = flag;
		PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
		if (!((Object)(object)val == (Object)null))
		{
			int playerId = (int)val.playerClientId;
			RansomNetworking component = ((Component)val).GetComponent<RansomNetworking>();
			if ((Object)(object)component != (Object)null)
			{
				component.SetInfectedServerRpc(playerId, flag ? 1 : 0);
			}
			else
			{
				SetPlayerInfected(playerId, flag);
			}
		}
	}

	private IEnumerator Transition(bool toActive)
	{
		transitioning = true;
		PlayFlickerSound();
		List<LightEntry> targets;
		if (toActive)
		{
			CollectLights();
			targets = entries;
		}
		else
		{
			targets = new List<LightEntry>();
			foreach (LightEntry entry in entries)
			{
				if ((Object)(object)entry.light != (Object)null && ColorsClose(entry.light.color, entry.assigned))
				{
					targets.Add(entry);
				}
			}
		}
		float end = Time.time + 0.7f;
		while (Time.time < end)
		{
			foreach (LightEntry item in targets)
			{
				if (!((Object)(object)item.light == (Object)null))
				{
					item.light.color = ((Random.value > 0.5f) ? TargetColor(item, toActive) : Color.black);
				}
			}
			yield return (object)new WaitForSeconds(Random.Range(0.04f, 0.12f));
		}
		foreach (LightEntry item2 in targets)
		{
			if (!((Object)(object)item2.light == (Object)null))
			{
				Color val = TargetColor(item2, toActive);
				item2.light.color = val;
				item2.assigned = val;
			}
		}
		if (!toActive)
		{
			entries.Clear();
		}
		effectActive = toActive;
		transitioning = false;
	}

	private void CollectLights()
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Invalid comparison between Unknown and I4
		//IL_0034: 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)
		//IL_0075: 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_0081: Unknown result type (might be due to invalid IL or missing references)
		entries.Clear();
		Light[] array = Object.FindObjectsOfType<Light>();
		foreach (Light val in array)
		{
			if (!((Object)(object)val == (Object)null) && (int)val.type != 1 && !(((Component)val).transform.position.y > -100f) && !((Object)(object)((Component)val).GetComponentInParent<PlayerControllerB>() != (Object)null) && !((Object)(object)((Component)val).GetComponentInParent<GrabbableObject>() != (Object)null))
			{
				LightEntry lightEntry = new LightEntry();
				lightEntry.light = val;
				lightEntry.original = val.color;
				lightEntry.assigned = val.color;
				lightEntry.hueOffset = Random.value;
				entries.Add(lightEntry);
			}
		}
		if (entries.Count == 0)
		{
			Plugin.Log.LogWarning((object)"Ransom: ComplexHack found no facility lights to recolor");
		}
	}

	private Color TargetColor(LightEntry e, bool toActive)
	{
		//IL_0004: 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_0037: Unknown result type (might be due to invalid IL or missing references)
		if (!toActive)
		{
			return e.original;
		}
		if (partyModeInConfig)
		{
			return Color.HSVToRGB(Mathf.Repeat(Time.time * 0.15f + e.hueOffset, 1f), 1f, 1f);
		}
		return RedColor;
	}

	private void UpdatePartyColors()
	{
		//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_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: 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)
		float num = Time.time * 0.15f;
		foreach (LightEntry entry in entries)
		{
			if (!((Object)(object)entry.light == (Object)null))
			{
				Color val = Color.HSVToRGB(Mathf.Repeat(num + entry.hueOffset, 1f), 1f, 1f);
				entry.light.color = val;
				entry.assigned = val;
			}
		}
	}

	private static bool ColorsClose(Color a, Color b)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: 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_0025: 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)
		return Mathf.Abs(a.r - b.r) + Mathf.Abs(a.g - b.g) + Mathf.Abs(a.b - b.b) < 0.03f;
	}

	private void PlayFlickerSound()
	{
		AudioClip val = FindFlickerClip();
		if ((Object)(object)val != (Object)null)
		{
			audioSource.PlayOneShot(val, 0.8f);
		}
	}

	private AudioClip FindFlickerClip()
	{
		if (flickerClipSearched)
		{
			return flickerClip;
		}
		flickerClipSearched = true;
		AudioClip[] array = Resources.FindObjectsOfTypeAll<AudioClip>();
		AudioClip[] array2 = array;
		foreach (AudioClip val in array2)
		{
			if (!((Object)(object)val == (Object)null))
			{
				string text = ((Object)val).name.ToLowerInvariant();
				if ((!string.IsNullOrEmpty("") && ((Object)val).name == "") || (string.IsNullOrEmpty("") && text.Contains("flicker")))
				{
					flickerClip = val;
					Plugin.Log.LogInfo((object)("Ransom: flicker sound = " + ((Object)val).name));
					return val;
				}
			}
		}
		array2 = array;
		foreach (AudioClip val2 in array2)
		{
			if (!((Object)(object)val2 == (Object)null))
			{
				string text2 = ((Object)val2).name.ToLowerInvariant();
				if (text2.Contains("breaker") || text2.Contains("power") || text2.Contains("lights") || text2.Contains("lamp"))
				{
					Plugin.Log.LogInfo((object)("Ransom: flicker sound candidate: " + ((Object)val2).name));
				}
			}
		}
		return null;
	}
}
public enum SpawnFrequencyPreset
{
	Always,
	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
{
	On,
	Off
}
public enum LetsGoGamblingPreset
{
	On,
	Off
}
public enum SpawnRansomPreset
{
	On,
	Off
}
public enum ComplexHackPreset
{
	On,
	Off
}
public enum EdgeNoisePreset
{
	On,
	Off
}
public enum RedVignettePreset
{
	On,
	Off
}
public enum PartyModePreset
{
	On,
	Off
}
public enum InfectionMusicPreset
{
	Default,
	SlightlyQuieter,
	Quieter,
	Off
}
public enum SellSoundPreset
{
	Default,
	SlightlyQuieter,
	Quieter,
	Off
}
public enum PopupSoundPreset
{
	Default,
	SlightlyQuieter,
	Quieter,
	Off
}
public enum CureSoundPreset
{
	Default,
	SlightlyQuieter,
	Quieter,
	Off
}
public class RansomSettings
{
	public ConfigEntry<SpawnFrequencyPreset> SpawnFrequency { get; private set; }

	public ConfigEntry<ReactionSpeedPreset> ReactionSpeed { get; private set; }

	public ConfigEntry<RansomSumPreset> RansomSum { get; private set; }

	public ConfigEntry<AggressivenessPreset> Aggressiveness { get; private set; }

	public ConfigEntry<PopupDurationPreset> PopupDuration { get; private set; }

	public ConfigEntry<PopupTimingPreset> PopupTiming { get; private set; }

	public ConfigEntry<InfectionTimerPreset> InfectionTimer { get; private set; }

	public ConfigEntry<ControlHackPreset> ControlHack { get; private set; }

	public ConfigEntry<RansomDamagePreset> RansomDamage { get; private set; }

	public ConfigEntry<AbsoluteRansomPreset> Relapse { get; private set; }

	public ConfigEntry<LetsGoGamblingPreset> LetsGoGambling { get; private set; }

	public ConfigEntry<RedVignettePreset> RedVignette { get; private set; }

	public ConfigEntry<EdgeNoisePreset> ScreenEdgeNoise { get; private set; }

	public ConfigEntry<ComplexHackPreset> ComplexHack { get; private set; }

	public ConfigEntry<PartyModePreset> PartyMode { get; private set; }

	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 RansomSettings(ConfigFile cfg)
	{
		Sprite val = AssetLoader.LoadSprite("icon.png");
		if ((Object)(object)val != (Object)null)
		{
			LethalConfigManager.SetModIcon(val);
		}
		SpawnFrequency = cfg.Bind<SpawnFrequencyPreset>("General Settings", "SpawnFrequency", SpawnFrequencyPreset.Default, "Configure how often Ransom appears during the game");
		ReactionSpeed = cfg.Bind<ReactionSpeedPreset>("General Settings", "ReactionSpeed", ReactionSpeedPreset.Default, "Configure how hard it is to react to and avoid Ransom's jumpscare");
		RansomSum = cfg.Bind<RansomSumPreset>("General Settings", "RansomSum", RansomSumPreset.Default, "Configure how much you need to pay as ransom");
		Aggressiveness = cfg.Bind<AggressivenessPreset>("General Settings", "Aggressiveness", AggressivenessPreset.Default, "Configure how often Ransom attempts to attack during a round, and how long its cooldown is between attacks");
		InfectionTimer = cfg.Bind<InfectionTimerPreset>("General Settings", "InfectionTimer", InfectionTimerPreset.Default, "Configure how much time you're given to pay the ransom");
		RansomDamage = cfg.Bind<RansomDamagePreset>("General Settings", "RansomDamage", RansomDamagePreset.Default, "Configure the damage from Ransom's first jumpscare");
		ControlHack = cfg.Bind<ControlHackPreset>("Modifiers", "ControlHack", ControlHackPreset.Off, "When enabled, you get infinite stamina during an active ransom, but your controls are inverted");
		Relapse = cfg.Bind<AbsoluteRansomPreset>("Modifiers", "AfterShock", AbsoluteRansomPreset.Off, "With a certain chance, after successfully fending off an attack, Ransom attacks again shortly after with no time to react — but selling items to Ransom is worth more while this is enabled");
		LetsGoGambling = cfg.Bind<LetsGoGamblingPreset>("Modifiers", "LetsGoGambling", LetsGoGamblingPreset.Off, "When enabled, you have a small, steadily increasing chance of exploding when Ransom would appear — but paying off a ransom fully heals you");
		PartyMode = cfg.Bind<PartyModePreset>("Modifiers", "PartyMode", PartyModePreset.Off, "Requires ComplexHack to be enabled. During the infection, the facility lighting will switch from red to some cool party lights");
		RedVignette = cfg.Bind<RedVignettePreset>("Visual", "RedVignette", RedVignettePreset.On, "Show the red vignette around the screen during an active ransom");
		ScreenEdgeNoise = cfg.Bind<EdgeNoisePreset>("Visual", "ScreenEdgeNoise", EdgeNoisePreset.On, "Show red pixel noise along the screen edges during an active ransom");
		ComplexHack = cfg.Bind<ComplexHackPreset>("Visual", "ComplexHack", ComplexHackPreset.On, "When enabled, the facility lights turn red while any player in the lobby is infected. For the best experience, everyone in the lobby should have this enabled");
		PopupDuration = cfg.Bind<PopupDurationPreset>("Visual", "PopupDuration", PopupDurationPreset.Default, "Configure how long each popup stays active on screen during an active ransom");
		PopupTiming = cfg.Bind<PopupTimingPreset>("Visual", "PopupTiming", PopupTimingPreset.Default, "Configure how often popups appear during an active ransom");
		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));
		LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<ReactionSpeedPreset>(ReactionSpeed));
		LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<RansomSumPreset>(RansomSum));
		LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<AggressivenessPreset>(Aggressiveness));
		LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<InfectionTimerPreset>(InfectionTimer));
		LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<RansomDamagePreset>(RansomDamage));
		LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<ControlHackPreset>(ControlHack));
		LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<AbsoluteRansomPreset>(Relapse));
		LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<LetsGoGamblingPreset>(LetsGoGambling));
		LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<PartyModePreset>(PartyMode));
		LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<RedVignettePreset>(RedVignette));
		LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<EdgeNoisePreset>(ScreenEdgeNoise));
		LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<ComplexHackPreset>(ComplexHack));
		LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<PopupDurationPreset>(PopupDuration));
		LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<PopupTimingPreset>(PopupTiming));
		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();
		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);
		ApplyRedVignette(RedVignette.Value);
		ApplyEdgeNoise(ScreenEdgeNoise.Value);
		ApplyComplexHack(ComplexHack.Value);
		ApplyPartyMode(PartyMode.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.Always:
			veryEasy = 1f;
			easy = 1f;
			medium = 1f;
			hard = 1f;
			hardcore = 1f;
			break;
		case SpawnFrequencyPreset.VeryOften:
			veryEasy = 0.22f;
			easy = 0.35f;
			medium = 0.5f;
			hard = 0.6f;
			hardcore = 0.8f;
			break;
		case SpawnFrequencyPreset.Often:
			veryEasy = 0.14f;
			easy = 0.2f;
			medium = 0.33f;
			hard = 0.45f;
			hardcore = 0.6f;
			break;
		case SpawnFrequencyPreset.Rare:
			veryEasy = 0.03f;
			easy = 0.06f;
			medium = 0.13f;
			hard = 0.16f;
			hardcore = 0.25f;
			break;
		case SpawnFrequencyPreset.VeryRare:
			veryEasy = 0.01f;
			easy = 0.04f;
			medium = 0.07f;
			hard = 0.1f;
			hardcore = 0.15f;
			break;
		default:
			veryEasy = 0.05f;
			easy = 0.1f;
			medium = 0.22f;
			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.3f;
			ransomMinimum = 100;
			break;
		case RansomSumPreset.BlackFriday:
			num = 0.1f;
			ransomMinimum = 25;
			break;
		default:
			num = 0.17f;
			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.09f;
			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 ApplyPartyMode(PartyModePreset preset)
	{
		RansomComplexHack.partyModeInConfig = preset == PartyModePreset.On;
	}

	private void ApplyAbsoluteRansom(AbsoluteRansomPreset preset)
	{
		if (preset == AbsoluteRansomPreset.On)
		{
			RansomJumpscare.absoluteRansomChance = 0.2f;
			RansomInfection.sellValueMultiplier = 1.25f;
		}
		else
		{
			RansomJumpscare.absoluteRansomChance = 0f;
			RansomInfection.sellValueMultiplier = 1f;
		}
	}

	private void ApplyLetsGoGambling(LetsGoGamblingPreset preset)
	{
		RansomSpawner.gamblingModeEnabled = preset == LetsGoGamblingPreset.On;
	}

	private void ApplyRedVignette(RedVignettePreset preset)
	{
		RansomInfection.vignetteEnabled = preset == RedVignettePreset.On;
	}

	private void ApplyEdgeNoise(EdgeNoisePreset preset)
	{
		RansomInfection.edgeNoiseEnabled = preset == EdgeNoisePreset.On;
	}

	private void ApplyComplexHack(ComplexHackPreset preset)
	{
		RansomComplexHack.enabledInConfig = preset == ComplexHackPreset.On;
	}

	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.Off:
			RansomInfection.sellSoundVolumeMultiplier = 0f;
			break;
		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.Off:
			RansomInfection.popupSoundVolumeMultiplier = 0f;
			break;
		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.Off:
			RansomInfection.cureSoundVolumeMultiplier = 0f;
			break;
		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 RansomSettings Instance;

	private static bool moonConfigsRegistered;

	public static void Setup(ConfigFile config)
	{
		Instance = new RansomSettings(config);
	}

	public static void TryRegisterMoonDifficulties(ConfigFile config)
	{
		if (moonConfigsRegistered || (Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.levels == null)
		{
			return;
		}
		List<(string, ConfigEntry<RansomSpawner.Difficulty>)> list = new List<(string, ConfigEntry<RansomSpawner.Difficulty>)>();
		SelectableLevel[] levels = StartOfRound.Instance.levels;
		foreach (SelectableLevel val in levels)
		{
			string normalized = NormalizeName(val.PlanetName);
			if (!string.IsNullOrEmpty(normalized) && !RansomSpawner.excludedFromMoonConfig.Contains(normalized) && !list.Exists(((string normalized, ConfigEntry<RansomSpawner.Difficulty> entry) e) => e.normalized == normalized))
			{
				RansomSpawner.Difficulty defaultDifficultyFor = RansomSpawner.GetDefaultDifficultyFor(normalized);
				ConfigEntry<RansomSpawner.Difficulty> item = config.Bind<RansomSpawner.Difficulty>("Moon Difficulties", normalized, defaultDifficultyFor, "Configure the difficulty level for " + normalized + ". The higher the difficulty, the higher the chance that Ransom will spawn during the game on this moon. If you want Ransom to never appear on this moon, set this to Safe. If you want Ransom to always appear on this moon, set this to Guaranteed.");
				list.Add((normalized, item));
			}
		}
		list.Sort(delegate((string normalized, ConfigEntry<RansomSpawner.Difficulty> entry) a, (string normalized, ConfigEntry<RansomSpawner.Difficulty> entry) b)
		{
			int value = (int)a.entry.Value;
			int value2 = (int)b.entry.Value;
			return (value != value2) ? value.CompareTo(value2) : string.Compare(a.normalized, b.normalized, StringComparison.Ordinal);
		});
		foreach (var item2 in list)
		{
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<RansomSpawner.Difficulty>(item2.Item2));
			RansomSpawner.moonDifficultyOverrides[item2.Item1] = item2.Item2.Value;
		}
		ConfigEntry<SpawnRansomPreset> obj = config.Bind<SpawnRansomPreset>("Dev Tools", "SpawnRansom", SpawnRansomPreset.Off, "When enabled, you can summon Ransom at any time by pressing J. Handy for seeing how Ransom works or testing your settings.");
		LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<SpawnRansomPreset>(obj));
		RansomJumpscare.debugSpawnKeyEnabled = obj.Value == SpawnRansomPreset.On;
		moonConfigsRegistered = true;
		Plugin.Log.LogInfo((object)("Ransom: registered " + list.Count + " moon difficulty settings"));
	}

	private static string NormalizeName(string raw)
	{
		if (string.IsNullOrEmpty(raw))
		{
			return raw;
		}
		int i;
		for (i = 0; i < raw.Length && (char.IsDigit(raw[i]) || raw[i] == ' '); i++)
		{
		}
		return raw.Substring(i);
	}
}
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 RansomEdgeNoise : MonoBehaviour
{
	private const int TextureWidth = 640;

	private const int TextureHeight = 360;

	private const float OuterThickness = 0.03f;

	private const float InnerThickness = 0.01f;

	private const float CornerRadius = 0.12f;

	private const float Density = 0.8f;

	private const float OuterOpacity = 0.2f;

	private const float InnerOpacity = 0.55f;

	private const float FlickerInterval = 0.08f;

	private const int PixelSize = 3;

	private GameObject canvasObject;

	private Texture2D outerTexture;

	private Texture2D innerTexture;

	private Color32[] outerPixels;

	private Color32[] innerPixels;

	private float updateTimer;

	private readonly Random random = new Random();

	private void Awake()
	{
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Expected O, but got Unknown
		outerTexture = CreateTexture();
		innerTexture = CreateTexture();
		outerPixels = (Color32[])(object)new Color32[230400];
		innerPixels = (Color32[])(object)new Color32[230400];
		canvasObject = new GameObject("RansomEdgeNoiseCanvas");
		canvasObject.transform.SetParent(((Component)this).transform, false);
		Canvas obj = canvasObject.AddComponent<Canvas>();
		obj.renderMode = (RenderMode)0;
		obj.sortingOrder = 996;
		CreateImage(canvasObject.transform, outerTexture, "OuterNoise");
		CreateImage(canvasObject.transform, innerTexture, "InnerNoise");
		canvasObject.SetActive(false);
	}

	public void SetVisible(bool visible)
	{
		if (!((Object)(object)canvasObject == (Object)null) && canvasObject.activeSelf != visible)
		{
			canvasObject.SetActive(visible);
			if (visible)
			{
				updateTimer = 0f;
				Regenerate();
			}
		}
	}

	private Texture2D CreateTexture()
	{
		//IL_000c: 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_0020: Expected O, but got Unknown
		return new Texture2D(640, 360, (TextureFormat)4, false)
		{
			filterMode = (FilterMode)0,
			wrapMode = (TextureWrapMode)1
		};
	}

	private void CreateImage(Transform parent, Texture2D texture, string objectName)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: 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)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(objectName);
		val.transform.SetParent(parent, false);
		RawImage obj = val.AddComponent<RawImage>();
		obj.texture = (Texture)(object)texture;
		((Graphic)obj).raycastTarget = false;
		RectTransform rectTransform = ((Graphic)obj).rectTransform;
		rectTransform.anchorMin = Vector2.zero;
		rectTransform.anchorMax = Vector2.one;
		rectTransform.offsetMin = Vector2.zero;
		rectTransform.offsetMax = Vector2.zero;
	}

	private void Update()
	{
		if (!((Object)(object)canvasObject == (Object)null) && canvasObject.activeSelf)
		{
			updateTimer += Time.unscaledDeltaTime;
			if (!(updateTimer < 0.08f))
			{
				updateTimer = 0f;
				Regenerate();
			}
		}
	}

	private static float BandDepth(float nx, float ny, float thickness, float radius)
	{
		float num = Mathf.Abs(nx - 0.5f);
		float num2 = Mathf.Abs(ny - 0.5f);
		float num3 = 0.5f - thickness;
		float num4 = Mathf.Min(radius, num3);
		float num5 = num - (num3 - num4);
		float num6 = num2 - (num3 - num4);
		float num7 = Mathf.Max(num5, 0f);
		float num8 = Mathf.Max(num6, 0f);
		float num9 = Mathf.Sqrt(num7 * num7 + num8 * num8);
		float num10 = Mathf.Min(Mathf.Max(num5, num6), 0f);
		return num9 + num10 - num4;
	}

	private void Regenerate()
	{
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		Array.Clear(outerPixels, 0, outerPixels.Length);
		Array.Clear(innerPixels, 0, innerPixels.Length);
		for (int i = 0; i < 360; i += 3)
		{
			for (int j = 0; j < 640; j += 3)
			{
				float nx = ((float)j + 1.5f) / 640f;
				float ny = ((float)i + 1.5f) / 360f;
				float num = BandDepth(nx, ny, 0.03f, 0.12f);
				float num2 = BandDepth(nx, ny, 0.01f, 0.12f);
				if (num > 0f)
				{
					float num3 = Mathf.Lerp(0.6f, 1f, Mathf.Clamp01(num / 0.03f));
					if (random.NextDouble() < (double)(0.52f * num3))
					{
						FillBlock(outerPixels, j, i, PickNoiseColor(inner: false, 0.2f));
					}
				}
				if (num2 > 0f)
				{
					float num4 = Mathf.Lerp(0.6f, 1f, Mathf.Clamp01(num2 / 0.01f));
					if (random.NextDouble() < (double)(0.44000003f * num4))
					{
						FillBlock(innerPixels, j, i, PickNoiseColor(inner: true, 0.55f));
					}
				}
			}
		}
		outerTexture.SetPixels32(outerPixels);
		outerTexture.Apply(false, false);
		innerTexture.SetPixels32(innerPixels);
		innerTexture.Apply(false, false);
	}

	private void FillBlock(Color32[] pixels, int startX, int startY, Color32 color)
	{
		//IL_002a: 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)
		for (int i = 0; i < 3; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				int num = startX + j;
				int num2 = startY + i;
				if (num < 640 && num2 < 360)
				{
					pixels[num2 * 640 + num] = color;
				}
			}
		}
	}

	private Color32 PickNoiseColor(bool inner, float opacity)
	{
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		double num = random.NextDouble();
		byte b;
		byte b2;
		byte b3;
		if (num < 0.82)
		{
			b = (byte)random.Next(inner ? 175 : 85, 256);
			b2 = (byte)random.Next(0, inner ? 45 : 65);
			b3 = (byte)random.Next(0, inner ? 40 : 55);
		}
		else if (num < 0.98)
		{
			b = (byte)random.Next(15, 110);
			b2 = (byte)random.Next(0, 20);
			b3 = (byte)random.Next(0, 25);
		}
		else if (num < 0.987)
		{
			b = byte.MaxValue;
			b2 = (byte)random.Next(150, 256);
			b3 = (byte)random.Next(0, 35);
		}
		else if (num < 0.995)
		{
			b = (byte)random.Next(0, 35);
			b2 = (byte)random.Next(150, 256);
			b3 = (byte)random.Next(0, 40);
		}
		else
		{
			b = (byte)random.Next(0, 35);
			b2 = (byte)random.Next(25, 100);
			b3 = (byte)random.Next(160, 256);
		}
		int minValue = (inner ? 150 : 35);
		byte b4 = (byte)Mathf.Clamp(Mathf.RoundToInt(opacity * (float)random.Next(minValue, 256)), 0, 255);
		return new Color32(b, b2, b3, b4);
	}

	private void OnDestroy()
	{
		if ((Object)(object)outerTexture != (Object)null)
		{
			Object.Destroy((Object)(object)outerTexture);
		}
		if ((Object)(object)innerTexture != (Object)null)
		{
			Object.Destroy((Object)(object)innerTexture);
		}
	}
}
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;

	public static float sellValueMultiplier = 1f;

	public static bool vignetteEnabled = true;

	public static bool edgeNoiseEnabled = true;

	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;

	public static string apparatusItemName = "Apparatus";

	public static float apparatusSellDelay = 6f;

	public static int apparatusPriceMin = 350;

	public static int apparatusPriceMax = 500;

	private readonly Dictionary<int, int> apparatusPrices = new Dictionary<int, int>();

	private readonly Dictionary<int, float> apparatusPickupTimes = new Dictionary<int, float>();

	private readonly HashSet<int> apparatusSeenThisFrame = new HashSet<int>();

	private readonly List<int> apparatusToRemove = new List<int>();

	private AudioSource audioSource;

	private AudioSource sfxAudioSource;

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

	private const float vignetteMaxAlpha = 0.07f;

	private const float vignettePulseSpeed = 1.2f;

	private Text sellPromptText;

	public static float sellPickupDelay = 0.3f;

	private GrabbableObject lastHeldForSell;

	private float heldSellUnlockTime;

	private const int microSpriteCount = 52;

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

	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;

	public static string[] tipGlitchPhrases = new string[9] { "Run", "Error", "Ransom hacked you", "I found you", "You are an idiot", "Make haste", "You will die", "Ransom.exe", "Pay or die" };

	public static Vector2 tipGlitchIntervalRange = new Vector2(3f, 8f);

	public static Vector2 tipGlitchDurationRange = new Vector2(1f, 3f);

	private float[] tipNextGlitchTime;

	private float[] tipGlitchEndTime;

	private string[] tipGlitchPhrase;

	private GrabbableObject tipGlitchItem;

	private bool tipGlitchDirty;

	private string lastSellTipText = "";

	private RansomJumpscare jumpscare;

	private RansomControlHack controlHack;

	public static bool invertControlsEnabled = false;

	private QuickMenuManager quickMenu;

	private RansomEdgeNoise edgeNoise;

	public static float cureLikeShakeMagnitude = 8f;

	public static float cureLikeShakeDuration = 0.25f;

	public bool IsInfectionActive => infectionActive;

	private void Awake()
	{
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
		audioSource.spatialBlend = 0f;
		sfxAudioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
		sfxAudioSource.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 < 52; 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 void TrackHeldForSell()
	{
		PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
		GrabbableObject val2 = (((Object)(object)val != (Object)null) ? val.currentlyHeldObjectServer : null);
		if ((Object)(object)val2 != (Object)(object)lastHeldForSell)
		{
			lastHeldForSell = val2;
			heldSellUnlockTime = Time.time + sellPickupDelay;
		}
	}

	private bool SellDelayPassed()
	{
		return Time.time >= heldSellUnlockTime;
	}

	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 UpdateEdgeNoiseVisibility()
	{
		if ((Object)(object)edgeNoise == (Object)null)
		{
			edgeNoise = ((Component)this).GetComponent<RansomEdgeNoise>();
		}
		if (!((Object)(object)edgeNoise == (Object)null))
		{
			edgeNoise.SetVisible(edgeNoiseEnabled && (Object)(object)vignetteObject != (Object)null && vignetteObject.activeSelf);
		}
	}

	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_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		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;
		((Behaviour)vignetteImage).enabled = vignetteEnabled;
		((Graphic)vignetteImage).color = new Color(1f, 0f, 0f, 0.02f);
		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.78f) / 0.42000008f);
				array[i * size + j] = new Color(1f, 0f, 0f, num4);
			}
		}
		val.SetPixels(array);
		val.Apply();
		return val;
	}

	private void LateUpdate()
	{
		TrackApparatus();
		TrackHeldForSell();
		UpdateTipGlitch();
	}

	private void ResetTipGlitchState(int lineCount)
	{
		tipNextGlitchTime = new float[lineCount];
		tipGlitchEndTime = new float[lineCount];
		tipGlitchPhrase = new string[lineCount];
		for (int i = 0; i < lineCount; i++)
		{
			tipNextGlitchTime[i] = Time.time + Random.Range(tipGlitchIntervalRange.x, tipGlitchIntervalRange.y);
		}
	}

	private string PickGlitchPhrase(int lineIndex)
	{
		string text = tipGlitchPhrases[Random.Range(0, tipGlitchPhrases.Length)];
		for (int i = 0; i < 6; i++)
		{
			bool flag = false;
			for (int j = 0; j < tipGlitchPhrase.Length; j++)
			{
				if (j != lineIndex && tipGlitchEndTime[j] > 0f && tipGlitchPhrase[j] == text)
				{
					flag = true;
				}
			}
			if (!flag)
			{
				break;
			}
			text = tipGlitchPhrases[Random.Range(0, tipGlitchPhrases.Length)];
		}
		return text;
	}

	private void UpdateTipGlitch()
	{
		if ((Object)(object)HUDManager.Instance == (Object)null)
		{
			return;
		}
		TextMeshProUGUI[] controlTipLines = HUDManager.Instance.controlTipLines;
		if (controlTipLines == null || controlTipLines.Length == 0)
		{
			return;
		}
		PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
		GrabbableObject val2 = (((Object)(object)val != (Object)null) ? val.currentlyHeldObjectServer : null);
		if (!infectionActive)
		{
			if (tipGlitchDirty)
			{
				if ((Object)(object)val2 != (Object)null)
				{
					val2.SetControlTipsForItem();
				}
				else
				{
					HUDManager.Instance.ClearControlTips();
				}
				tipGlitchDirty = false;
			}
			tipNextGlitchTime = null;
			return;
		}
		if (tipNextGlitchTime == null || tipNextGlitchTime.Length != controlTipLines.Length || (Object)(object)val2 != (Object)(object)tipGlitchItem)
		{
			ResetTipGlitchState(controlTipLines.Length);
			tipGlitchItem = val2;
			tipGlitchDirty = false;
		}
		if ((Object)(object)val2 == (Object)null)
		{
			return;
		}
		int num = controlTipLines.Length - 1;
		bool flag = false;
		for (int i = 0; i < controlTipLines.Length; i++)
		{
			if (tipGlitchEndTime[i] > 0f)
			{
				if (Time.time >= tipGlitchEndTime[i])
				{
					tipGlitchEndTime[i] = 0f;
					tipNextGlitchTime[i] = Time.time + Random.Range(tipGlitchIntervalRange.x, tipGlitchIntervalRange.y);
					if (i != num)
					{
						flag = true;
					}
				}
			}
			else if (Time.time >= tipNextGlitchTime[i])
			{
				if (string.IsNullOrEmpty(((TMP_Text)controlTipLines[i]).text))
				{
					tipNextGlitchTime[i] = Time.time + 1f;
					continue;
				}
				tipGlitchPhrase[i] = PickGlitchPhrase(i);
				tipGlitchEndTime[i] = Time.time + Random.Range(tipGlitchDurationRange.x, tipGlitchDurationRange.y);
			}
		}
		if (flag)
		{
			val2.SetControlTipsForItem();
			((TMP_Text)controlTipLines[num]).text = lastSellTipText;
		}
		bool flag2 = false;
		for (int j = 0; j < controlTipLines.Length; j++)
		{
			if (tipGlitchEndTime[j] > 0f)
			{
				((TMP_Text)controlTipLines[j]).text = tipGlitchPhrase[j];
				flag2 = true;
			}
		}
		tipGlitchDirty = flag2;
	}

	private void HealPlayerToMax()
	{
		PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
		if ((Object)(object)val == (Object)null || val.isPlayerDead)
		{
			return;
		}
		int observedMaxHealth = RansomSpawner.observedMaxHealth;
		if (val.health < observedMaxHealth)
		{
			val.health = observedMaxHealth;
			HUDManager.Instance.UpdateHealthUI(observedMaxHealth, false);
			if (val.criticallyInjured)
			{
				val.MakeCriticallyInjured(false);
			}
		}
	}

	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 TrackApparatus()
	{
		PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
		if ((Object)(object)val == (Object)null || val.ItemSlots == null)
		{
			return;
		}
		apparatusSeenThisFrame.Clear();
		GrabbableObject[] itemSlots = val.ItemSlots;
		foreach (GrabbableObject val2 in itemSlots)
		{
			if (!IsApparatus(val2))
			{
				continue;
			}
			int instanceID = ((Object)val2).GetInstanceID();
			apparatusSeenThisFrame.Add(instanceID);
			if (!apparatusPickupTimes.ContainsKey(instanceID))
			{
				apparatusPickupTimes[instanceID] = Time.time;
				if (!apparatusPrices.ContainsKey(instanceID))
				{
					apparatusPrices[instanceID] = Random.Range(apparatusPriceMin, apparatusPriceMax + 1);
				}
			}
		}
		apparatusToRemove.Clear();
		foreach (int key in apparatusPickupTimes.Keys)
		{
			if (!apparatusSeenThisFrame.Contains(key))
			{
				apparatusToRemove.Add(key);
			}
		}
		foreach (int item in apparatusToRemove)
		{
			apparatusPickupTimes.Remove(item);
		}
	}

	private bool IsApparatus(GrabbableObject item)
	{
		if ((Object)(object)item != (Object)null && (Object)(object)item.itemProperties != (Object)null)
		{
			return item.itemProperties.itemName == apparatusItemName;
		}
		return false;
	}

	private bool ApparatusSellReady(GrabbableObject item)
	{
		if (!IsApparatus(item))
		{
			return true;
		}
		if (!apparatusPickupTimes.TryGetValue(((Object)item).GetInstanceID(), out var value))
		{
			return false;
		}
		return Time.time - value >= apparatusSellDelay;
	}

	private int GetApparatusPrice(GrabbableObject item)
	{
		int instanceID = ((Object)item).GetInstanceID();
		if (!apparatusPrices.TryGetValue(instanceID, out var value))
		{
			value = Random.Range(apparatusPriceMin, apparatusPriceMax + 1);
			apparatusPrices[instanceID] = value;
		}
		return value;
	}

	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_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		UpdateEdgeNoiseVisibility();
		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.02f, 0.07f, num);
			((Graphic)vignetteImage).color = new Color(1f, 0f, 0f, num2);
			repositionTimer -= Time.deltaTime;
			if (repositionTimer <= 0f)
			{
				RepositionWindow();
				repositionTimer = 3f;
			}
			PlayerControllerB val3 = GameNetworkManager.Instance?.localPlayerController;
			if (invertControlsEnabled && (Object)(object)val3 != (Object)null)
			{
				val3.sprintMeter = 1f;
			}
			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 == "Maneater")
				{
					int num4 = Mathf.RoundToInt(500f * sellValueMultiplier);
					text2 = "Sell " + text + " for " + num4 + " credits: [C]";
				}
				else if (text == "Body")
				{
					int num5 = Mathf.RoundToInt(250f * sellValueMultiplier);
					text2 = "Sell " + text + " for " + num5 + " credits: [C]";
				}
				else if (IsApparatus(val4))
				{
					text2 = ((!ApparatusSellReady(val4)) ? "Calculating the item's value, please wait..." : ("Sell " + text + " for " + Mathf.RoundToInt((float)GetApparatusPrice(val4) * sellValueMultiplier) + " credits: [C]"));
				}
				else if (text == "Key")
				{
					int num6 = Mathf.RoundToInt(3f * sellValueMultiplier);
					text2 = "Sell " + text + " for " + num6 + " credits: [C]";
				}
				else if (flag4)
				{
					int num7 = Mathf.RoundToInt((float)val4.scrapValue * sellValueMultiplier);
					text2 = "Sell " + text + " for " + num7 + " credits: [C]";
				}
				else
				{
					int num8 = Mathf.RoundToInt((float)GetEquipmentSellValue(text) * sellValueMultiplier);
					text2 = "Sell " + text + " for " + num8 + " credits: [C]";
				}
				HUDManager.Instance.ChangeControlTip(num3, text2, false);
				lastSellTipText = text2;
			}
			else
			{
				HUDManager.Instance.ChangeControlTip(num3, "", false);
				lastSellTipText = "";
			}
			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();
		controlHack.SetInverted(value: false);
		apparatusPrices.Clear();
		apparatusPickupTimes.Clear();
	}

	private void SellHeldItem(PlayerControllerB player)
	{
		//IL_0117: 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)
		TrackHeldForSell();
		if (!SellDelayPassed())
		{
			return;
		}
		GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer;
		if (!((Object)(object)currentlyHeldObjectServer == (Object)null) && ApparatusSellReady(currentlyHeldObjectServer))
		{
			string text = (((Object)(object)currentlyHeldObjectServer.itemProperties != (Object)null) ? currentlyHeldObjectServer.itemProperties.itemName : "");
			int num;
			switch (text)
			{
			case "Maneater":
			case "Cave Dweller":
				num = 500;
				break;
			case "Body":
				num = 250;
				break;
			case "Key":
				num = 3;
				break;
			default:
				num = ((!IsApparatus(currentlyHeldObjectServer)) ? ((!((Object)(object)currentlyHeldObjectServer.itemProperties != (Object)null) || !currentlyHeldObjectServer.itemProperties.isScrap) ? GetEquipmentSellValue(text) : currentlyHeldObjectServer.scrapValue) : GetApparatusPrice(currentlyHeldObjectServer));
				break;
			}
			num = Mathf.RoundToInt((float)num * sellValueMultiplier);
			amountPaid += num;
			if ((Object)(object)sellSound != (Object)null)
			{
				sfxAudioSource.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;
		if (RansomSpawner.gamblingModeEnabled)
		{
			HealPlayerToMax();
		}
		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;
		Vector3 likeStartPos = ((Transform)((Graphic)cureLikeImage).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)cureLikeImage).rectTransform).position = Vector3.Lerp(likeStartPos, center, num);
			((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)) ? mic