Decompiled source of CUCheats v1.9.3

CUCheats.dll

Decompiled an hour 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.Text;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.Win32.SafeHandles;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyMetadata("Notice", "Copyright (c) casualexpie. All rights reserved. Do NOT decompile, disassemble, or reverse-engineer this assembly. Report bug symptoms on the Nexus Bugs page; do not post decompiled or reconstructed source. Reverse-engineering this DLL is not authorized.")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace CUCheats;

[BepInPlugin("cucheats", "CU Cheats", "1.9.1")]
public class Plugin : BaseUnityPlugin
{
	public const string Version = "1.9.1";

	internal static ConfigEntry<bool> ShowTerminal;

	internal static ConfigEntry<float> TerminalStatusSeconds;

	internal static ConfigEntry<bool> NoFallDamage;

	internal static ConfigEntry<bool> GodMode;

	internal static ConfigEntry<bool> ShowOverlay;

	internal static ConfigEntry<bool> InfiniteStamina;

	internal static ConfigEntry<bool> NoHunger;

	internal static ConfigEntry<bool> NoThirst;

	internal static ConfigEntry<bool> NoTiredness;

	internal static ConfigEntry<bool> MoodLock;

	internal static ConfigEntry<bool> FreezeEnemies;

	internal static ConfigEntry<bool> OneHitKills;

	internal static ConfigEntry<bool> MaxTraderRep;

	internal static ConfigEntry<bool> FreeShopping;

	internal static ConfigEntry<bool> InstantMine;

	internal static ConfigEntry<bool> UnlimitedAmmo;

	internal static ConfigEntry<bool> LongerEscape;

	internal static ConfigEntry<bool> CharacterComments;

	internal static ConfigEntry<bool> ShowTrainerAd;

	internal static ConfigEntry<bool> TurnedOff;

	internal static ConfigEntry<bool> NoBleeding;

	internal static ConfigEntry<bool> NoPain;

	internal static ConfigEntry<bool> NoInfection;

	internal static ConfigEntry<bool> NoSickness;

	internal static ConfigEntry<bool> NoRadiation;

	internal static ConfigEntry<bool> UnlimitedOxygen;

	internal static ConfigEntry<bool> StableTemperature;

	internal static ConfigEntry<bool> FasterHealing;

	internal static ConfigEntry<bool> MoreXp;

	internal static ConfigEntry<bool> FasterMovement;

	internal static ConfigEntry<bool> FasterClimbing;

	internal static ConfigEntry<bool> HigherJumps;

	internal static ConfigEntry<bool> UnlimitedJumps;

	internal static ConfigEntry<bool> UnlimitedWallJumps;

	internal static ConfigEntry<bool> LowGravity;

	internal static ConfigEntry<bool> FlyMode;

	internal static ConfigEntry<bool> Noclip;

	internal static ConfigEntry<bool> ClickTeleport;

	internal static ConfigEntry<bool> FreeCrafting;

	internal static ConfigEntry<bool> NoCraftFail;

	internal static ConfigEntry<bool> AllRecipes;

	internal static ConfigEntry<bool> NoDegradation;

	internal static ConfigEntry<bool> UnlimitedCarry;

	internal static ConfigEntry<bool> UnlimitedLiquids;

	internal static ConfigEntry<bool> UnlimitedBattery;

	internal static ConfigEntry<bool> MasterLockpick;

	internal static ConfigEntry<bool> NoGunJams;

	internal static ConfigEntry<bool> NoRecoil;

	internal static ConfigEntry<bool> MoreDamage;

	internal static ConfigEntry<bool> FasterAttacks;

	internal static ConfigEntry<bool> Invisibility;

	internal static ConfigEntry<bool> DisableTraps;

	internal static ConfigEntry<bool> PauseRadiation;

	internal static ConfigEntry<bool> NoEarthquakes;

	internal static ConfigEntry<bool> MoreLoot;

	internal static ConfigEntry<bool> FullBright;

	internal static ConfigEntry<bool> FreeCamera;

	internal static ConfigEntry<bool> FragileBody;

	internal static ConfigEntry<bool> FastMetabolism;

	internal static ConfigEntry<bool> HopelessStart;

	internal static ConfigEntry<bool> BrittleGear;

	internal static ConfigEntry<bool> StrongerEnemies;

	internal static ConfigEntry<bool> FastRadiation;

	internal static ConfigEntry<bool> UnchippedChallenge;

	internal static ConfigEntry<bool> ColdCaves;

	internal static ConfigEntry<bool> MoreTraps;

	internal static ConfigEntry<bool> LootScarcity;

	internal static ConfigEntry<float> MoveSpeedMult;

	internal static ConfigEntry<float> ClimbSpeedMult;

	internal static ConfigEntry<float> JumpMult;

	internal static ConfigEntry<float> GravityScale;

	internal static ConfigEntry<float> FlySpeed;

	internal static ConfigEntry<float> HealingMult;

	internal static ConfigEntry<float> XpMult;

	internal static ConfigEntry<float> DamageMult;

	internal static ConfigEntry<float> AttackSpeedMult;

	internal static ConfigEntry<float> LootMult;

	internal static float GameSpeed = 1f;

	internal static float CameraZoom = 1f;

	internal static readonly List<ConfigEntry<bool>> CheatList = new List<ConfigEntry<bool>>();

	internal static readonly List<ConfigEntry<bool>> ChallengeList = new List<ConfigEntry<bool>>();

	internal static Body MoodBody;

	internal static float MoodTarget = float.NaN;

	internal static ConfigEntry<KeyCode> OverlayKey;

	internal static ConfigEntry<KeyCode> MenuKey;

	internal static ManualLogSource Log;

	internal static float RagdollUntil;

	internal static Harmony HarmonyInstance;

	internal static Body PausedBody;

	internal static string PauseReason;

	internal static bool PauseResumable;

	internal static float PausedAt;

	private ConfigEntry<bool> Cheat(string key, string desc)
	{
		ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>("Cheats", key, false, desc);
		CheatList.Add(val);
		return val;
	}

	private ConfigEntry<bool> Challenge(string key, string desc)
	{
		ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>("Challenges", key, false, desc);
		ChallengeList.Add(val);
		return val;
	}

	internal static bool AnyCheatOn()
	{
		for (int i = 0; i < CheatList.Count; i++)
		{
			if (CheatList[i].Value)
			{
				return true;
			}
		}
		if (GameSpeed == 1f)
		{
			return CameraZoom != 1f;
		}
		return true;
	}

	internal static bool AnyChallengeOn()
	{
		for (int i = 0; i < ChallengeList.Count; i++)
		{
			if (ChallengeList[i].Value)
			{
				return true;
			}
		}
		return false;
	}

	internal static void ApplyKeeps(Body b)
	{
		Limb[] limbs = b.limbs;
		if (limbs != null && (NoBleeding.Value || NoPain.Value || NoInfection.Value))
		{
			foreach (Limb val in limbs)
			{
				if (!((Object)(object)val == (Object)null) && !val.dismembered)
				{
					if (NoBleeding.Value)
					{
						val.bleedAmount = 0f;
					}
					if (NoPain.Value)
					{
						val.pain = 0f;
					}
					if (NoInfection.Value)
					{
						val.infectionAmount = 0f;
						val.infected = false;
					}
				}
			}
		}
		if (NoBleeding.Value)
		{
			b.internalBleeding = 0f;
			b.hemothorax = 0f;
		}
		if (NoPain.Value)
		{
			b.painShock = 0f;
		}
		if (NoInfection.Value)
		{
			b.septicShock = 0f;
		}
		if (NoSickness.Value)
		{
			b.sicknessAmount = 0f;
			b.venomCurrent = 0f;
		}
		if (NoRadiation.Value)
		{
			b.radiationSickness = 0f;
		}
		if (UnlimitedOxygen.Value)
		{
			b.bloodOxygen = 100f;
		}
		if (StableTemperature.Value)
		{
			b.temperature = 37f;
		}
		if (UnlimitedCarry.Value)
		{
			b.overEncumberance = 0f;
		}
		if (InfiniteStamina.Value)
		{
			b.stamina = 100f;
		}
		if (NoHunger.Value && b.hunger < 100f)
		{
			b.hunger = 100f;
		}
		if (NoThirst.Value && b.thirst < 100f)
		{
			b.thirst = 100f;
		}
		if (NoTiredness.Value)
		{
			b.energy = 100f;
		}
		if (MoodLock.Value)
		{
			if ((Object)(object)MoodBody != (Object)(object)b || float.IsNaN(MoodTarget))
			{
				MoodBody = b;
				MoodTarget = Mathf.Max(b.happiness, 60f);
			}
			b.happiness = MoodTarget;
			b.traumaAmount = 0f;
		}
		else
		{
			MoodTarget = float.NaN;
		}
	}

	internal static float MoodMax(Body b)
	{
		return 100f * ((b.charType == 2) ? 1.5151515f : 1f);
	}

	internal static void SetMood(Body b, float v)
	{
		float num = MoodMax(b);
		v = Mathf.Clamp(v, 0f - num, num);
		b.happiness = v;
		if (MoodLock.Value)
		{
			MoodBody = b;
			MoodTarget = v;
		}
	}

	private void Awake()
	{
		//IL_07fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0807: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		TurnedOff = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "TurnedOff", false, "CU Cheats is retired. When true it loads nothing at all (no menu, no cheats, no patches), so it can't clash with the Ultra Paradise CU:Trainer. Set it back to false to use CU Cheats again.");
		if (TurnedOff.Value)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"CU Cheats 1.9.1 is turned off (TurnedOff = true in BepInEx\\config\\cucheats.cfg). It's retired; use the Ultra Paradise CU:Trainer instead: https://www.nexusmods.com/scavprototype/mods/1203");
			((Behaviour)this).enabled = false;
			return;
		}
		NoFallDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("Cheats", "NoFallDamage", true, "Ignore all impact/fall damage on the player.");
		GodMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Cheats", "GodMode", true, "Player cannot be hurt or killed.");
		CheatList.Add(NoFallDamage);
		CheatList.Add(GodMode);
		InfiniteStamina = Cheat("InfiniteStamina", "Stamina never runs out.");
		NoHunger = Cheat("NoHunger", "Hunger stays full.");
		NoThirst = Cheat("NoThirst", "Thirst stays full.");
		NoTiredness = Cheat("NoTiredness", "Energy stays full (you can't sleep while this is on).");
		MoodLock = Cheat("MoodLock", "Mood never drops low.");
		FreezeEnemies = Cheat("FreezeEnemies", "Enemies can't move or attack.");
		OneHitKills = Cheat("OneHitKills", "Your melee hits and gunshots kill enemies in one hit.");
		MaxTraderRep = Cheat("MaxTraderReputation", "Nearby survivors always have max reputation and are never hostile.");
		FreeShopping = Cheat("FreeShopping", "Everything survivors sell costs 0.");
		InstantMine = Cheat("InstantMine", "Your melee hits break any breakable block in one hit.");
		UnlimitedAmmo = Cheat("UnlimitedAmmo", "Your loaded gun never runs out. Load it once (magazine in, or a shell in the shotgun) and it keeps refilling.");
		LongerEscape = Cheat("LongerEscapeTimer", "The escape countdown at the end lab is 2 minutes instead of 1 before the guards come.");
		NoBleeding = Cheat("NoBleeding", "You never bleed, inside or out.");
		NoPain = Cheat("NoPain", "You feel no pain.");
		NoInfection = Cheat("NoInfection", "Wounds never get infected.");
		NoSickness = Cheat("NoSickness", "No sickness, nausea or venom.");
		NoRadiation = Cheat("NoRadiationSickness", "Radiation never builds up.");
		UnlimitedOxygen = Cheat("UnlimitedOxygen", "Your blood oxygen stays full, even underwater.");
		StableTemperature = Cheat("StableBodyTemperature", "Your body temperature stays at 37C.");
		FasterHealing = Cheat("FasterHealing", "Wounds, bones and blood heal faster (see HealingMultiplier).");
		MoreXp = Cheat("IncreasedXpGain", "Skills level up faster (see XpMultiplier).");
		FasterMovement = Cheat("FasterMovement", "You walk and run faster (see MoveSpeedMultiplier).");
		FasterClimbing = Cheat("FasterClimbing", "You climb ropes and ladders faster (see ClimbSpeedMultiplier).");
		HigherJumps = Cheat("HigherJumps", "You jump higher (see JumpMultiplier).");
		UnlimitedJumps = Cheat("UnlimitedJumps", "Jump again in mid-air as often as you like.");
		UnlimitedWallJumps = Cheat("UnlimitedWallJumps", "Wall jump off the same wall over and over.");
		LowGravity = Cheat("LowGravity", "You fall slower and float further (see GravityScale).");
		FlyMode = Cheat("FlyMode", "Fly with your movement keys (W/A/S/D). You still bump into walls. Hold Shift to go faster.");
		Noclip = Cheat("Noclip", "Fly through walls with your movement keys. Hold Shift to go faster.");
		ClickTeleport = Cheat("MiddleClickTeleport", "Middle mouse button teleports you to the cursor.");
		FreeCrafting = Cheat("FreeCrafting", "Craft any recipe you can see without ingredients.");
		NoCraftFail = Cheat("NoCraftingFailures", "Crafting never fails, even above your Intelligence.");
		AllRecipes = Cheat("ShowAllRecipes", "Every recipe shows in the crafting menu, whatever your Intelligence.");
		NoDegradation = Cheat("NoItemDegradation", "Tools, weapons, armor, containers and batteries never lose condition.");
		UnlimitedCarry = Cheat("UnlimitedCarryWeight", "You're never over-encumbered: carrying too much never slows you, tires you or makes your attacks slower.");
		UnlimitedLiquids = Cheat("UnlimitedLiquids", "Liquids in containers never run out.");
		UnlimitedBattery = Cheat("UnlimitedBattery", "Batteries never drain.");
		MasterLockpick = Cheat("MasterLockpicker", "Every lock opens the moment you turn it, with a lockpicking kit or bare claws. No hurt claws, no worn-out kit.");
		NoGunJams = Cheat("NoGunJams", "Guns never jam.");
		NoRecoil = Cheat("NoRecoil", "Guns don't kick you back or spread.");
		MoreDamage = Cheat("IncreasedDamage", "Your melee and gun hits do more damage (see DamageMultiplier).");
		FasterAttacks = Cheat("FasterAttacks", "Shorter wait between melee swings (see AttackSpeedMultiplier).");
		Invisibility = Cheat("Invisibility", "Enemies and turrets can't attack you.");
		DisableTraps = Cheat("DisableTraps", "Mines, bear traps, spike stabbers, fans, sound cannons and turrets do nothing.");
		PauseRadiation = Cheat("PauseRadiationLine", "The layer timer and the radiation line stop.");
		NoEarthquakes = Cheat("NoEarthquakes", "Earthquakes never happen.");
		MoreLoot = Cheat("IncreasedLoot", "New layers have more loot (see LootMultiplier).");
		FullBright = Cheat("FullBright", "Lights up everything.");
		FreeCamera = Cheat("FreeCamera", "Move the camera on its own with the arrow keys. Hold Shift to go faster.");
		FragileBody = Challenge("FragileBody", "You take double damage.");
		FastMetabolism = Challenge("FasterHungerAndThirst", "Hunger, thirst and tiredness drain twice as fast.");
		HopelessStart = Challenge("HopelessStart", "New runs start with no supplies at all.");
		BrittleGear = Challenge("BrittleGear", "Items decay three times faster.");
		StrongerEnemies = Challenge("StrongerEnemies", "Enemies take half damage and creatures are stronger.");
		FastRadiation = Challenge("FastRadiationLine", "The layer timer runs out twice as fast and the radiation line moves twice as fast.");
		UnchippedChallenge = Challenge("UnchippedMode", "Play unchipped: no health readouts and limited vision.");
		ColdCaves = Challenge("ColdCaves", "The caves are 15C colder.");
		MoreTraps = Challenge("MoreTraps", "New layers have twice as many traps.");
		LootScarcity = Challenge("LootScarcity", "New layers have much less loot.");
		MoveSpeedMult = ((BaseUnityPlugin)this).Config.Bind<float>("Values", "MoveSpeedMultiplier", 1.6f, "Faster Movement speed.");
		ClimbSpeedMult = ((BaseUnityPlugin)this).Config.Bind<float>("Values", "ClimbSpeedMultiplier", 2f, "Faster Climbing speed.");
		JumpMult = ((BaseUnityPlugin)this).Config.Bind<float>("Values", "JumpMultiplier", 1.5f, "Higher Jumps strength.");
		GravityScale = ((BaseUnityPlugin)this).Config.Bind<float>("Values", "GravityScale", 0.4f, "Low Gravity: 1 is normal gravity.");
		FlySpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Values", "FlySpeed", 18f, "Fly Mode speed.");
		HealingMult = ((BaseUnityPlugin)this).Config.Bind<float>("Values", "HealingMultiplier", 3f, "Faster Healing rate.");
		XpMult = ((BaseUnityPlugin)this).Config.Bind<float>("Values", "XpMultiplier", 3f, "Increased XP Gain rate.");
		DamageMult = ((BaseUnityPlugin)this).Config.Bind<float>("Values", "DamageMultiplier", 2f, "Increased Damage amount.");
		AttackSpeedMult = ((BaseUnityPlugin)this).Config.Bind<float>("Values", "AttackSpeedMultiplier", 2.5f, "Faster Attacks speed.");
		LootMult = ((BaseUnityPlugin)this).Config.Bind<float>("Values", "LootMultiplier", 2f, "Increased Loot amount on new layers.");
		CharacterComments = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "CharacterComments", true, "Your character sometimes comments on cheats being on. Also in the game's Settings > Game tab.");
		ShowTrainerAd = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowRetiredNotice", true, "Show the 'CU Cheats is retired' notice once per game launch on the main menu. Also in F10 > Settings.");
		ShowOverlay = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "ShowOverlay", false, "Show the debug overlay window.");
		ShowTerminal = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Terminal", false, "Open a separate terminal window that shows everything the game, BepInEx and the mods log, plus live player and world status. A copy is saved to BepInEx\\CUCheats_terminal.log.");
		TerminalStatusSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Debug", "TerminalStatusSeconds", 10f, "How often (in seconds) the terminal prints a full status block. Minimum 1.");
		MenuKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Hotkeys", "ToggleMenu", (KeyCode)291, "Opens the CU Cheats menu.");
		OverlayKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Hotkeys", "ToggleOverlay", (KeyCode)290, "Opens the debug overlay.");
		Feed.Hook();
		Terminal.Hook();
		if (ShowTerminal.Value)
		{
			Terminal.Open();
		}
		LoadedNotice.Hook();
		HarmonyInstance = new Harmony("cucheats");
		HarmonyInstance.PatchAll(typeof(Plugin).Assembly);
		Runner.Ensure();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"CU Cheats loaded. F10 = cheat menu, F9 = debug overlay.");
		Feed.Mod("Plugin loaded, Harmony patches applied");
	}

	internal static void SetTerminal(bool on)
	{
		if (ShowTerminal.Value != on || Terminal.IsOpen != on)
		{
			ShowTerminal.Value = on;
			if (on)
			{
				Terminal.Open();
			}
			else
			{
				Terminal.Close();
			}
		}
	}

	internal static bool IsPlayer(Body body)
	{
		if ((Object)(object)body != (Object)null && (Object)(object)PlayerCamera.main != (Object)null)
		{
			return (Object)(object)PlayerCamera.main.body == (Object)(object)body;
		}
		return false;
	}

	internal static bool GodOn(Body body)
	{
		if (GodMode.Value && IsPlayer(body))
		{
			return !Paused(body);
		}
		return false;
	}

	internal static bool Paused(Body body)
	{
		if ((Object)(object)body != (Object)null && (Object)(object)PausedBody != (Object)null)
		{
			return (Object)(object)body == (Object)(object)PausedBody;
		}
		return false;
	}

	internal static void Pause(Body body, string reason, bool resumable)
	{
		if (!((Object)(object)body == (Object)null) && (!Paused(body) || PauseResumable))
		{
			PausedBody = body;
			PauseReason = reason;
			PauseResumable = resumable;
			PausedAt = Time.time;
			Log.LogInfo((object)("God Mode paused: " + reason));
			Feed.Add("WARNING", "#ff6b6b", "God Mode PAUSED: " + reason);
		}
	}

	internal static void TryResume()
	{
		Body pausedBody = PausedBody;
		if ((Object)(object)pausedBody == (Object)null || !PauseResumable)
		{
			return;
		}
		if (!pausedBody.alive)
		{
			PauseResumable = false;
			return;
		}
		bool flag = (Object)(object)pausedBody.harmer != (Object)null && pausedBody.harmer.harming;
		if (Time.time - PausedAt > 20f && pausedBody.totalBleedSpeed < 0.01f && !flag && !pausedBody.forceNoMovement)
		{
			PausedBody = null;
			PauseReason = null;
			Log.LogInfo((object)"God Mode resumed (survived).");
			Feed.Add("WARNING", "#9cff8a", "Survived - God Mode resumed");
		}
	}

	internal static string DamageSummary(Body b)
	{
		List<string> list = new List<string>();
		if (b.brainHealth < 99.9f)
		{
			list.Add("brain -" + (100f - b.brainHealth).ToString("0.0"));
		}
		if (b.bloodVolume < 99f)
		{
			list.Add("blood -" + (100f - b.bloodVolume).ToString("0.0"));
		}
		if (b.internalBleeding > 0.1f)
		{
			list.Add("internal bleed");
		}
		Limb[] limbs = b.limbs;
		if (limbs != null)
		{
			foreach (Limb val in limbs)
			{
				if (!((Object)(object)val == (Object)null) && !val.dismembered)
				{
					float num = 100f - val.skinHealth + (100f - val.muscleHealth);
					if (num > 0.5f || val.bleedAmount > 0.1f || val.shrapnel > 0)
					{
						list.Add(((Object)((Component)val).gameObject).name + " -" + num.ToString("0.0") + ((val.bleedAmount > 0.1f) ? " bleeding" : ""));
					}
				}
			}
		}
		if (list.Count != 0)
		{
			return string.Join(", ", list.ToArray());
		}
		return null;
	}

	internal static void Restore(Body b)
	{
		Stats.Restores++;
		b.brainHealth = 100f;
		if (!b.sleeping)
		{
			b.consciousness = 100f;
		}
		b.bloodVolume = 100f;
		b.bloodOxygen = 100f;
		if (b.bloodPressure < 100f)
		{
			b.bloodPressure = 100f;
		}
		else if (b.bloodPressure > 140f)
		{
			b.bloodPressure = 140f;
		}
		if (b.heartRate > 160f)
		{
			b.heartRate = 160f;
		}
		b.fibrillationProgress = 0f;
		b.hasPulmonaryEmbolism = false;
		b.strokeAmount = 0f;
		b.shock = ((Time.time < RagdollUntil) ? 20f : 0f);
		b.painShock = 0f;
		b.internalBleeding = 0f;
		b.hemothorax = 0f;
		b.septicShock = 0f;
		b.sicknessAmount = 0f;
		b.radiationSickness = 0f;
		b.venomCurrent = 0f;
		b.barotrauma = 0f;
		b.temperature = 37f;
		if (b.hunger < 30f)
		{
			b.hunger = 30f;
		}
		if (b.thirst < 30f)
		{
			b.thirst = 30f;
		}
		if (b.thirst > 150f)
		{
			b.thirst = 150f;
		}
		Limb[] limbs = b.limbs;
		if (limbs == null)
		{
			return;
		}
		foreach (Limb val in limbs)
		{
			if (!((Object)(object)val == (Object)null) && !val.dismembered)
			{
				val.skinHealth = 100f;
				val.muscleHealth = 100f;
				val.bleedAmount = 0f;
				val.pain = 0f;
				val.infectionAmount = 0f;
				val.infected = false;
				val.shrapnel = 0;
			}
		}
	}
}
internal static class Stats
{
	internal static int Restores;

	private static readonly Dictionary<string, int> counts = new Dictionary<string, int>();

	internal static readonly List<string> Order = new List<string>();

	internal static void Hit(string key)
	{
		if (!counts.TryGetValue(key, out var value))
		{
			Order.Add(key);
		}
		counts[key] = value + 1;
	}

	internal static int Get(string key)
	{
		counts.TryGetValue(key, out var value);
		return value;
	}
}
internal class FeedEntry
{
	public float time;

	public string tag;

	public string color;

	public string text;

	public int repeat = 1;
}
internal static class Feed
{
	private const int Max = 60;

	private static readonly List<FeedEntry> entries = new List<FeedEntry>();

	private static readonly object gate = new object();

	private static float now;

	internal static void Hook()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		Application.logMessageReceivedThreaded += new LogCallback(OnUnityLog);
		SceneManager.sceneLoaded += delegate(Scene s, LoadSceneMode m)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			Add("SCENE", "#7fd4ff", string.Concat("Loaded scene '", ((Scene)(ref s)).name, "' (", m, ")"));
		};
	}

	internal static void Tick()
	{
		now = Time.realtimeSinceStartup;
	}

	internal static void Mod(string text)
	{
		Add("MOD", "#9cff8a", text);
	}

	private static void OnUnityLog(string msg, string stack, LogType type)
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Invalid comparison between Unknown and I4
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Invalid comparison between Unknown and I4
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Invalid comparison between Unknown and I4
		if (msg != null && !msg.StartsWith("[CUCheats]"))
		{
			string text = msg.Split('\n')[0];
			if (text.Length > 160)
			{
				text = text.Substring(0, 160) + "...";
			}
			string color = "#cfcfcf";
			if ((int)type == 2)
			{
				color = "#ffd966";
			}
			else if ((int)type == 0 || (int)type == 4 || (int)type == 1)
			{
				color = "#ff6b6b";
			}
			Add("GAME:" + type, color, text);
		}
	}

	internal static void Add(string tag, string color, string text)
	{
		if (!tag.StartsWith("GAME:") && tag != "SCENE")
		{
			Terminal.Line(Terminal.ColorFor(color), "CUCHEATS:" + tag, text);
		}
		lock (gate)
		{
			if (entries.Count > 0)
			{
				FeedEntry feedEntry = entries[entries.Count - 1];
				if (feedEntry.tag == tag && feedEntry.text == text)
				{
					feedEntry.repeat++;
					feedEntry.time = now;
					return;
				}
			}
			FeedEntry feedEntry2 = new FeedEntry();
			feedEntry2.time = now;
			feedEntry2.tag = tag;
			feedEntry2.color = color;
			feedEntry2.text = text;
			entries.Add(feedEntry2);
			if (entries.Count > 60)
			{
				entries.RemoveAt(0);
			}
		}
	}

	internal static void Clear()
	{
		lock (gate)
		{
			entries.Clear();
		}
	}

	internal static void Render(StringBuilder sb, int lines)
	{
		lock (gate)
		{
			int num = Mathf.Max(0, entries.Count - lines);
			for (int num2 = entries.Count - 1; num2 >= num; num2--)
			{
				FeedEntry feedEntry = entries[num2];
				int num3 = (int)feedEntry.time;
				sb.Append("<color=#777777>").Append((num3 / 60).ToString("00")).Append(':')
					.Append((num3 % 60).ToString("00"))
					.Append("</color> ");
				sb.Append("<color=").Append(feedEntry.color).Append(">[")
					.Append(feedEntry.tag)
					.Append("]</color> ");
				sb.Append(Escape(feedEntry.text));
				if (feedEntry.repeat > 1)
				{
					sb.Append(" <color=#ffaa55>x").Append(feedEntry.repeat).Append("</color>");
				}
				sb.Append('\n');
			}
			if (entries.Count == 0)
			{
				sb.Append("<color=#777777>(no events yet)</color>\n");
			}
		}
	}

	private static string Escape(string s)
	{
		return s.Replace("<", "‹").Replace(">", "›");
	}
}
internal static class Quip
{
	private const float First = 120f;

	private const float Every = 1800f;

	private static Body lastBody;

	private static float nextAt;

	internal static void Tick()
	{
		WorldGeneration world = WorldGeneration.world;
		Body val = (((Object)(object)PlayerCamera.main != (Object)null) ? PlayerCamera.main.body : null);
		if ((Object)(object)world == (Object)null || (Object)(object)val == (Object)null)
		{
			lastBody = null;
			return;
		}
		float realTimeElapsed = world.realTimeElapsed;
		if ((Object)(object)val != (Object)(object)lastBody)
		{
			lastBody = val;
			nextAt = ((realTimeElapsed < 120f) ? 120f : (120f + Mathf.Ceil((realTimeElapsed - 120f) / 1800f) * 1800f));
		}
		if (!(realTimeElapsed < nextAt) && Plugin.AnyCheatOn() && Plugin.CharacterComments.Value && val.alive && val.conscious && !val.sleeping && !((Object)(object)val.talker == (Object)null) && val.talker.FinishedTalking() && !PauseHandler.paused)
		{
			string text = ((val.charType == 1) ? "I'm cheating? Pathetic..." : ((val.charType == 2) ? "D-Dune cheat..?" : "Wait.... why am i cheating?"));
			val.talker.Talk(text, (Limb)null, true, false);
			nextAt += 1800f;
			while (nextAt <= realTimeElapsed)
			{
				nextAt += 1800f;
			}
		}
	}
}
internal static class MultiplayerGuard
{
	internal static bool Detected;

	internal static readonly List<string> Found = new List<string>();

	private static readonly string[] PluginKeywords = new string[10] { "krokmp", "krokosha", "casualtiestogether", "casualtiesmp", "multiplayer", "coop", "netplay", "netcode", "lobby", "latejoin" };

	private static readonly string[] NetLibraries = new string[13]
	{
		"mirror", "unity.netcode", "fishnet", "photon", "litenetlib", "riptide", "kcp2k", "telepathy", "lidgren", "facepunch.steamworks",
		"unity.networking.transport", "unity.services.lobby", "unity.services.relay"
	};

	private static bool offLogged;

	private static bool libLogged;

	private static readonly Dictionary<string, bool> offCache = new Dictionary<string, bool>();

	private static string Normalize(string s)
	{
		if (s == null)
		{
			return "";
		}
		return s.ToLowerInvariant().Replace(" ", "").Replace("-", "")
			.Replace("_", "")
			.Replace(".", "");
	}

	private static bool HasKeyword(string hay)
	{
		for (int i = 0; i < PluginKeywords.Length; i++)
		{
			if (hay.Contains(PluginKeywords[i]))
			{
				return true;
			}
		}
		return false;
	}

	private static Assembly AssemblyOf(PluginInfo p)
	{
		try
		{
			if (!object.ReferenceEquals(p.Instance, null))
			{
				return ((object)p.Instance).GetType().Assembly;
			}
		}
		catch (Exception)
		{
		}
		if (string.IsNullOrEmpty(p.Location))
		{
			return null;
		}
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly in assemblies)
		{
			try
			{
				if (!assembly.IsDynamic && string.Equals(assembly.Location, p.Location, StringComparison.OrdinalIgnoreCase))
				{
					return assembly;
				}
			}
			catch (Exception)
			{
			}
		}
		return null;
	}

	private static bool SwitchedOff(PluginInfo p)
	{
		string gUID = p.Metadata.GUID;
		if (offCache.TryGetValue(gUID, out var value))
		{
			return value;
		}
		value = SwitchedOffNow(p);
		if (!object.ReferenceEquals(p.Instance, null))
		{
			offCache[gUID] = value;
		}
		return value;
	}

	private static bool SwitchedOffNow(PluginInfo p)
	{
		Assembly assembly = AssemblyOf(p);
		if (assembly == null)
		{
			return false;
		}
		Type[] types;
		try
		{
			types = assembly.GetTypes();
		}
		catch (ReflectionTypeLoadException ex)
		{
			types = ex.Types;
		}
		catch (Exception)
		{
			return false;
		}
		BindingFlags bindingAttr = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
		Type[] array = types;
		foreach (Type type in array)
		{
			if (type == null)
			{
				continue;
			}
			try
			{
				PropertyInfo property = type.GetProperty("FORCE_DISABLE_MP_MOD", bindingAttr);
				if (property != null && property.PropertyType == typeof(bool) && (bool)property.GetValue(null, null))
				{
					return true;
				}
				FieldInfo field = type.GetField("FORCE_DISABLE_MP_MOD", bindingAttr);
				if (field != null && field.FieldType == typeof(bool) && (bool)field.GetValue(null))
				{
					return true;
				}
			}
			catch (Exception)
			{
			}
		}
		return false;
	}

	private static bool OwnedByOff(Assembly lib, List<PluginInfo> off)
	{
		string text = null;
		try
		{
			if (!lib.IsDynamic && !string.IsNullOrEmpty(lib.Location))
			{
				text = Path.GetDirectoryName(lib.Location);
			}
		}
		catch (Exception)
		{
		}
		string name = lib.GetName().Name;
		foreach (PluginInfo item in off)
		{
			try
			{
				if (text != null && !string.IsNullOrEmpty(item.Location) && string.Equals(Path.GetDirectoryName(item.Location), text, StringComparison.OrdinalIgnoreCase))
				{
					return true;
				}
				Assembly assembly = AssemblyOf(item);
				if (assembly == null)
				{
					continue;
				}
				AssemblyName[] referencedAssemblies = assembly.GetReferencedAssemblies();
				foreach (AssemblyName assemblyName in referencedAssemblies)
				{
					if (string.Equals(assemblyName.Name, name, StringComparison.OrdinalIgnoreCase))
					{
						return true;
					}
				}
			}
			catch (Exception)
			{
			}
		}
		return false;
	}

	internal static bool Check()
	{
		if (Detected)
		{
			return true;
		}
		List<string> list = new List<string>();
		HashSet<string> hashSet = new HashSet<string>();
		Dictionary<string, PluginInfo> pluginInfos = Chainloader.PluginInfos;
		HashSet<string> hashSet2 = new HashSet<string>();
		List<PluginInfo> list2 = new List<PluginInfo>();
		List<string> list3 = new List<string>();
		foreach (KeyValuePair<string, PluginInfo> item in pluginInfos)
		{
			PluginInfo value = item.Value;
			if (value != null && value.Metadata != null && !(value.Metadata.GUID == "cucheats"))
			{
				string s = "";
				try
				{
					s = Path.GetFileNameWithoutExtension(value.Location);
				}
				catch (Exception)
				{
				}
				_ = Normalize(value.Metadata.GUID) + "|" + Normalize(value.Metadata.Name) + "|" + Normalize(s);
				if (SwitchedOff(value))
				{
					hashSet2.Add(value.Metadata.GUID);
					list2.Add(value);
					list3.Add(value.Metadata.Name);
				}
			}
		}
		if (hashSet2.Count > 0)
		{
			foreach (KeyValuePair<string, PluginInfo> item2 in pluginInfos)
			{
				PluginInfo value2 = item2.Value;
				if (value2 == null || value2.Metadata == null || hashSet2.Contains(value2.Metadata.GUID) || value2.Dependencies == null)
				{
					continue;
				}
				foreach (BepInDependency dependency in value2.Dependencies)
				{
					if (dependency != null && hashSet2.Contains(dependency.DependencyGUID))
					{
						hashSet2.Add(value2.Metadata.GUID);
						list2.Add(value2);
						list3.Add(value2.Metadata.Name + " (add-on)");
						break;
					}
				}
			}
			if (!offLogged)
			{
				offLogged = true;
				Plugin.Log.LogInfo((object)("Multiplayer mod found but switched off: " + string.Join(", ", list3.ToArray()) + ". CU Cheats stays on."));
			}
		}
		foreach (KeyValuePair<string, PluginInfo> item3 in pluginInfos)
		{
			PluginInfo value3 = item3.Value;
			if (value3 != null && value3.Metadata != null && !(value3.Metadata.GUID == "cucheats") && !hashSet2.Contains(value3.Metadata.GUID))
			{
				string s2 = "";
				try
				{
					s2 = Path.GetFileNameWithoutExtension(value3.Location);
				}
				catch (Exception)
				{
				}
				string hay = Normalize(value3.Metadata.GUID) + "|" + Normalize(value3.Metadata.Name) + "|" + Normalize(s2);
				if (HasKeyword(hay))
				{
					hashSet.Add(value3.Metadata.GUID);
					list.Add(value3.Metadata.Name);
				}
			}
		}
		foreach (KeyValuePair<string, PluginInfo> item4 in pluginInfos)
		{
			PluginInfo value4 = item4.Value;
			if (value4 == null || value4.Metadata == null || hashSet.Contains(value4.Metadata.GUID) || hashSet2.Contains(value4.Metadata.GUID) || value4.Dependencies == null)
			{
				continue;
			}
			foreach (BepInDependency dependency2 in value4.Dependencies)
			{
				if (dependency2 != null && hashSet.Contains(dependency2.DependencyGUID))
				{
					list.Add(value4.Metadata.Name + " (multiplayer add-on)");
					break;
				}
			}
		}
		List<string> list4 = new List<string>();
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		for (int i = 0; i < assemblies.Length; i++)
		{
			string name;
			try
			{
				name = assemblies[i].GetName().Name;
			}
			catch (Exception)
			{
				continue;
			}
			if (name == null)
			{
				continue;
			}
			string text = name.ToLowerInvariant();
			for (int j = 0; j < NetLibraries.Length; j++)
			{
				if (text.StartsWith(NetLibraries[j]))
				{
					if (list2.Count <= 0 || !OwnedByOff(assemblies[i], list2))
					{
						list4.Add(name + " (network library)");
					}
					break;
				}
			}
		}
		if (list.Count == 0)
		{
			if (list4.Count > 0 && !libLogged)
			{
				libLogged = true;
				Plugin.Log.LogInfo((object)("Network library loaded by another mod (" + string.Join(", ", list4.ToArray()) + "), but no multiplayer mod found. CU Cheats stays on."));
			}
			return false;
		}
		list.AddRange(list4);
		Detected = true;
		Found.AddRange(list);
		try
		{
			if (Plugin.HarmonyInstance != null)
			{
				Plugin.HarmonyInstance.UnpatchSelf();
			}
		}
		catch (Exception ex4)
		{
			Plugin.Log.LogWarning((object)("Unpatch failed: " + ex4.Message));
		}
		Plugin.Log.LogWarning((object)("Multiplayer detected (" + string.Join(", ", list.ToArray()) + "). CU Cheats is now fully disabled."));
		Feed.Add("WARNING", "#ff9a3c", "Multiplayer detected - CU Cheats disabled");
		Terminal.Close();
		return true;
	}
}
internal static class Terminal
{
	private struct Entry
	{
		public ConsoleColor Color;

		public string Text;
	}

	private sealed class Listener : ILogListener, IDisposable
	{
		public void LogEvent(object sender, LogEventArgs e)
		{
			//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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			if (e != null && e.Source != null && !(e.Source.SourceName == "Unity Log"))
			{
				ConsoleColor color = ConsoleColor.Gray;
				if ((e.Level & 3) != 0)
				{
					color = ConsoleColor.Red;
				}
				else if ((e.Level & 4) != 0)
				{
					color = ConsoleColor.Yellow;
				}
				else if ((e.Level & 0x20) != 0)
				{
					color = ConsoleColor.DarkGray;
				}
				Line(color, "BEPINEX:" + e.Source.SourceName + ":" + e.Level, (e.Data == null) ? "null" : e.Data.ToString());
			}
		}

		public void Dispose()
		{
		}
	}

	private const int MaxQueue = 20000;

	private static IntPtr conHandle = IntPtr.Zero;

	private static StreamWriter con;

	private static readonly object gate = new object();

	private static readonly Queue<Entry> queue = new Queue<Entry>();

	private static readonly Stopwatch clock = Stopwatch.StartNew();

	private static readonly Regex tags = new Regex("<[^>]+>");

	private static Thread writer;

	private static StreamWriter file;

	private static volatile bool open;

	private static bool created;

	private static bool hooked;

	private static int dropped;

	private static string lastText;

	private static bool sceneSeen;

	private static float nextWatch;

	private static Body wBody;

	private static bool wAlive;

	private static bool wConscious;

	private static bool wSleeping;

	private static bool wPaused;

	private static int wLayer = -1;

	private static float wTimeScale = -1f;

	private static string wHeld;

	private static string[] wLimbs;

	internal static bool IsOpen => open;

	internal static string FilePath => Path.Combine(Paths.BepInExRootPath, "CUCheats_terminal.log");

	[DllImport("kernel32.dll")]
	private static extern IntPtr GetConsoleWindow();

	[DllImport("kernel32.dll")]
	private static extern bool SetConsoleCtrlHandler(IntPtr handler, bool add);

	[DllImport("user32.dll")]
	private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool revert);

	[DllImport("user32.dll")]
	private static extern bool DeleteMenu(IntPtr menu, uint position, uint flags);

	[DllImport("user32.dll")]
	private static extern bool DrawMenuBar(IntPtr hWnd);

	[DllImport("kernel32.dll")]
	private static extern bool AllocConsole();

	[DllImport("kernel32.dll")]
	private static extern bool FreeConsole();

	[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
	private static extern bool SetConsoleTitle(string title);

	[DllImport("kernel32.dll")]
	private static extern bool SetConsoleOutputCP(uint codePage);

	[DllImport("kernel32.dll")]
	private static extern bool SetConsoleTextAttribute(IntPtr handle, ushort attributes);

	[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
	private static extern IntPtr CreateFile(string name, uint access, uint share, IntPtr security, uint disposition, uint flags, IntPtr template);

	internal static void Hook()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Expected O, but got Unknown
		if (hooked)
		{
			return;
		}
		hooked = true;
		Application.logMessageReceivedThreaded += new LogCallback(OnUnityLog);
		SceneManager.sceneLoaded += delegate(Scene s, LoadSceneMode m)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			Line(ConsoleColor.Cyan, "SCENE", string.Concat("Loaded '", ((Scene)(ref s)).name, "' (", m, ", build index ", ((Scene)(ref s)).buildIndex, ", ", ((Scene)(ref s)).rootCount, " root objects)"));
			if (!sceneSeen)
			{
				sceneSeen = true;
				if (open)
				{
					Inventory();
				}
			}
		};
		SceneManager.sceneUnloaded += delegate(Scene s)
		{
			Line(ConsoleColor.DarkCyan, "SCENE", "Unloaded '" + ((Scene)(ref s)).name + "'");
		};
		SceneManager.activeSceneChanged += delegate(Scene a, Scene b)
		{
			Line(ConsoleColor.DarkCyan, "SCENE", "Active scene '" + ((Scene)(ref a)).name + "' -> '" + ((Scene)(ref b)).name + "'");
		};
		Application.lowMemory += (LowMemoryCallback)delegate
		{
			Line(ConsoleColor.Red, "SYSTEM", "Low memory warning from the OS");
		};
		Application.focusChanged += delegate(bool f)
		{
			Line(ConsoleColor.DarkGray, "SYSTEM", f ? "Game window focused" : "Game window lost focus");
		};
		Application.quitting += delegate
		{
			Line(ConsoleColor.Cyan, "SYSTEM", "Game is quitting");
			Close();
		};
		try
		{
			Logger.Listeners.Add((ILogListener)(object)new Listener());
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("Terminal: couldn't listen to BepInEx logs: " + ex.Message));
		}
	}

	private static void OnUnityLog(string msg, string stack, LogType type)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Invalid comparison between Unknown and I4
		//IL_0016: 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_001b: Invalid comparison between Unknown and I4
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Invalid comparison between Unknown and I4
		//IL_002f: 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_0034: Invalid comparison between Unknown and I4
		//IL_005a: 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: Invalid comparison between Unknown and I4
		if (open)
		{
			ConsoleColor color = ConsoleColor.White;
			if ((int)type == 2)
			{
				color = ConsoleColor.Yellow;
			}
			else if ((int)type == 0 || (int)type == 4 || (int)type == 1)
			{
				color = ConsoleColor.Red;
			}
			string text = msg ?? "null";
			if (((int)type == 0 || (int)type == 4 || (int)type == 1) && !string.IsNullOrEmpty(stack))
			{
				text = text + "\n" + stack.TrimEnd();
			}
			Line(color, "UNITY:" + type, text);
		}
	}

	internal static ConsoleColor ColorFor(string hex)
	{
		switch (hex)
		{
		case "#ff6b6b":
		case "#ff3030":
			return ConsoleColor.Red;
		case "#ff9a3c":
		case "#ffaa55":
			return ConsoleColor.DarkYellow;
		case "#ffd966":
			return ConsoleColor.Yellow;
		case "#9cff8a":
			return ConsoleColor.Green;
		case "#7fd4ff":
			return ConsoleColor.Cyan;
		default:
			return ConsoleColor.Gray;
		}
	}

	private static string Stamp()
	{
		TimeSpan elapsed = clock.Elapsed;
		return $"{(int)elapsed.TotalHours:00}:{elapsed.Minutes:00}:{elapsed.Seconds:00}.{elapsed.Milliseconds:000}";
	}

	internal static void Line(ConsoleColor color, string tag, string text)
	{
		if (!open || text == null)
		{
			return;
		}
		string text2 = Stamp() + " [" + tag + "] ";
		string text3 = new string(' ', text2.Length);
		string[] array = text.Replace("\r", "").Split('\n');
		lock (gate)
		{
			if (array.Length != 1 || !(text == lastText))
			{
				lastText = ((array.Length == 1) ? text : null);
				Entry item = default(Entry);
				for (int i = 0; i < array.Length && (i <= 0 || i != array.Length - 1 || array[i].Length != 0); i++)
				{
					item.Color = color;
					item.Text = ((i == 0) ? text2 : text3) + array[i];
					queue.Enqueue(item);
				}
				while (queue.Count > 20000)
				{
					queue.Dequeue();
					dropped++;
				}
				Monitor.Pulse(gate);
			}
		}
	}

	internal static void Block(ConsoleColor color, string tag, string text)
	{
		Line(color, tag, tags.Replace(text, "").TrimEnd());
	}

	internal static void Open()
	{
		if (open)
		{
			return;
		}
		try
		{
			created = AllocConsole();
			IntPtr intPtr = CreateFile("CONOUT$", 3221225472u, 3u, IntPtr.Zero, 3u, 0u, IntPtr.Zero);
			if (intPtr == IntPtr.Zero || intPtr == new IntPtr(-1))
			{
				throw new Exception("no console output handle");
			}
			conHandle = intPtr;
			SetConsoleOutputCP(65001u);
			FileStream stream = new FileStream(new SafeFileHandle(intPtr, ownsHandle: true), FileAccess.Write);
			con = new StreamWriter(stream, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false));
			SetConsoleTitle("CU Cheats Terminal - Casualties: Unknown");
			if (created)
			{
				LockWindow();
			}
		}
		catch (Exception ex)
		{
			con = null;
			conHandle = IntPtr.Zero;
			if (created)
			{
				try
				{
					FreeConsole();
				}
				catch (Exception)
				{
				}
				created = false;
			}
			Plugin.Log.LogWarning((object)("Terminal: couldn't open a console window (" + ex.Message + "). Writing to " + FilePath + " only."));
		}
		try
		{
			file = new StreamWriter(FilePath, append: false, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false));
		}
		catch (Exception ex3)
		{
			file = null;
			Plugin.Log.LogWarning((object)("Terminal: couldn't create " + FilePath + ": " + ex3.Message));
		}
		lock (gate)
		{
			queue.Clear();
			dropped = 0;
			lastText = null;
		}
		open = true;
		writer = new Thread(WriterLoop);
		writer.IsBackground = true;
		writer.Name = "CUCheats Terminal";
		writer.Start();
		Header();
		Plugin.Log.LogInfo((object)("Terminal window opened. Copy saved to " + FilePath));
	}

	internal static void Close()
	{
		if (!open)
		{
			return;
		}
		Line(ConsoleColor.Cyan, "TERMINAL", "Terminal closed");
		lock (gate)
		{
			open = false;
			Monitor.PulseAll(gate);
		}
		if (writer != null)
		{
			writer.Join(2000);
		}
		writer = null;
		try
		{
			if (file != null)
			{
				file.Close();
			}
		}
		catch (Exception)
		{
		}
		file = null;
		try
		{
			if (con != null)
			{
				con.Flush();
				SetConsoleTextAttribute(conHandle, 7);
				con.Close();
			}
		}
		catch (Exception)
		{
		}
		con = null;
		conHandle = IntPtr.Zero;
		try
		{
			if (created)
			{
				FreeConsole();
			}
		}
		catch (Exception)
		{
		}
		created = false;
	}

	private static void LockWindow()
	{
		try
		{
			SetConsoleCtrlHandler(IntPtr.Zero, add: true);
			IntPtr consoleWindow = GetConsoleWindow();
			if (!(consoleWindow == IntPtr.Zero))
			{
				IntPtr systemMenu = GetSystemMenu(consoleWindow, revert: false);
				if (systemMenu != IntPtr.Zero)
				{
					DeleteMenu(systemMenu, 61536u, 0u);
				}
				DrawMenuBar(consoleWindow);
			}
		}
		catch (Exception)
		{
		}
	}

	private static void WriterLoop()
	{
		List<Entry> list = new List<Entry>();
		ConsoleColor consoleColor = (ConsoleColor)(-1);
		Entry item = default(Entry);
		while (true)
		{
			int num;
			lock (gate)
			{
				while (queue.Count == 0 && open)
				{
					Monitor.Wait(gate, 250);
				}
				if (queue.Count == 0 && !open)
				{
					break;
				}
				while (queue.Count > 0)
				{
					list.Add(queue.Dequeue());
				}
				num = dropped;
				dropped = 0;
			}
			StreamWriter streamWriter = con;
			if (num > 0)
			{
				item.Color = ConsoleColor.Red;
				item.Text = Stamp() + " [TERMINAL] " + num + " lines dropped (the terminal couldn't keep up, or text was being selected)";
				list.Insert(0, item);
			}
			for (int i = 0; i < list.Count; i++)
			{
				Entry entry = list[i];
				if (streamWriter != null)
				{
					try
					{
						if (entry.Color != consoleColor)
						{
							streamWriter.Flush();
							SetConsoleTextAttribute(conHandle, (ushort)entry.Color);
							consoleColor = entry.Color;
						}
						streamWriter.WriteLine(entry.Text);
					}
					catch (Exception)
					{
						streamWriter = null;
					}
				}
				if (file != null)
				{
					try
					{
						file.WriteLine(entry.Text);
					}
					catch (Exception)
					{
					}
				}
			}
			try
			{
				streamWriter?.Flush();
			}
			catch (Exception)
			{
			}
			try
			{
				if (file != null)
				{
					file.Flush();
				}
			}
			catch (Exception)
			{
			}
			list.Clear();
		}
	}

	private static void Header()
	{
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
		ConsoleColor color = ConsoleColor.Cyan;
		Line(color, "TERMINAL", "CU Cheats 1.9.1 terminal. Everything the game, BepInEx and the mods log shows here.");
		Line(ConsoleColor.DarkGray, "TERMINAL", "Copy saved to " + FilePath + ". Turn this window off in the F10 menu (ADVANCED). The X button is disabled because closing a console window kills the game.");
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.Append("Game ").Append(Application.productName).Append(' ')
			.Append(Application.version)
			.Append(" | Unity ")
			.Append(Application.unityVersion)
			.Append(" | BepInEx ")
			.Append(typeof(Paths).Assembly.GetName().Version)
			.Append(" | Harmony ")
			.Append(typeof(Harmony).Assembly.GetName().Version)
			.Append('\n');
		stringBuilder.Append("OS ").Append(SystemInfo.operatingSystem).Append(" | ")
			.Append(SystemInfo.systemMemorySize)
			.Append(" MB RAM\n");
		stringBuilder.Append("CPU ").Append(SystemInfo.processorType).Append(" (")
			.Append(SystemInfo.processorCount)
			.Append(" threads)\n");
		stringBuilder.Append("GPU ").Append(SystemInfo.graphicsDeviceName).Append(" (")
			.Append(SystemInfo.graphicsMemorySize)
			.Append(" MB, ")
			.Append(SystemInfo.graphicsDeviceVersion)
			.Append(")\n");
		StringBuilder stringBuilder2 = stringBuilder.Append("Screen ").Append(Screen.width).Append('x')
			.Append(Screen.height)
			.Append(" @ ");
		Resolution currentResolution = Screen.currentResolution;
		RefreshRate refreshRateRatio = ((Resolution)(ref currentResolution)).refreshRateRatio;
		stringBuilder2.Append(((RefreshRate)(ref refreshRateRatio)).value.ToString("0")).Append(" Hz, ").Append(Screen.fullScreenMode)
			.Append(", vSync ")
			.Append(QualitySettings.vSyncCount)
			.Append(", target FPS ")
			.Append(Application.targetFrameRate)
			.Append('\n');
		stringBuilder.Append("Game folder ").Append(Paths.GameRootPath);
		Block(color, "SYSTEM", stringBuilder.ToString());
		if (sceneSeen)
		{
			Inventory();
		}
		else
		{
			Line(ConsoleColor.DarkGray, "TERMINAL", "The plugin and Harmony patch lists print once the main menu has loaded (other mods are still loading).");
		}
	}

	private static void Inventory()
	{
		ConsoleColor color = ConsoleColor.Cyan;
		StringBuilder stringBuilder = new StringBuilder();
		foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
		{
			PluginInfo value = pluginInfo.Value;
			if (value != null && value.Metadata != null)
			{
				string value2 = "";
				try
				{
					value2 = Path.GetFileName(value.Location);
				}
				catch (Exception)
				{
				}
				stringBuilder.Append(value.Metadata.Name).Append(' ').Append(value.Metadata.Version)
					.Append("  [")
					.Append(value.Metadata.GUID)
					.Append("]  ")
					.Append(value2)
					.Append('\n');
			}
		}
		Block(color, "PLUGINS", Chainloader.PluginInfos.Count + " loaded:\n" + stringBuilder);
		stringBuilder.Length = 0;
		int num = 0;
		try
		{
			foreach (MethodBase allPatchedMethod in Harmony.GetAllPatchedMethods())
			{
				Patches patchInfo = Harmony.GetPatchInfo(allPatchedMethod);
				if (patchInfo != null)
				{
					num++;
					stringBuilder.Append((allPatchedMethod.DeclaringType != null) ? allPatchedMethod.DeclaringType.Name : "?").Append('.').Append(allPatchedMethod.Name)
						.Append("  <- ")
						.Append(string.Join(", ", new List<string>(patchInfo.Owners).ToArray()))
						.Append("  (pre ")
						.Append(patchInfo.Prefixes.Count)
						.Append(", post ")
						.Append(patchInfo.Postfixes.Count)
						.Append(", trans ")
						.Append(patchInfo.Transpilers.Count)
						.Append(", fin ")
						.Append(patchInfo.Finalizers.Count)
						.Append(")\n");
				}
			}
		}
		catch (Exception ex2)
		{
			stringBuilder.Append("couldn't list patches: ").Append(ex2.Message);
		}
		Block(ConsoleColor.DarkCyan, "HARMONY", num + " patched methods:\n" + stringBuilder);
		Block(ConsoleColor.Green, "CHEATS", CheatStates());
	}

	internal static string CheatStates()
	{
		List<string> list = new List<string>();
		for (int i = 0; i < Plugin.CheatList.Count; i++)
		{
			if (Plugin.CheatList[i].Value)
			{
				list.Add(((ConfigEntryBase)Plugin.CheatList[i]).Definition.Key);
			}
		}
		List<string> list2 = new List<string>();
		for (int j = 0; j < Plugin.ChallengeList.Count; j++)
		{
			if (Plugin.ChallengeList[j].Value)
			{
				list2.Add(((ConfigEntryBase)Plugin.ChallengeList[j]).Definition.Key);
			}
		}
		return "ON: " + ((list.Count == 0) ? "none" : string.Join(", ", list.ToArray())) + "\nChallenges: " + ((list2.Count == 0) ? "none" : string.Join(", ", list2.ToArray())) + "\nGame speed x" + Plugin.GameSpeed.ToString("0.##") + ", camera zoom x" + Plugin.CameraZoom.ToString("0.##");
	}

	internal static void Status(string snapshot)
	{
		if (open)
		{
			Line(ConsoleColor.DarkGray, "STATUS", "------------------------------------------------------------");
			Block(ConsoleColor.Gray, "STATUS", snapshot);
			Body val = (((Object)(object)PlayerCamera.main != (Object)null) ? PlayerCamera.main.body : null);
			if ((Object)(object)val != (Object)null)
			{
				Block(ConsoleColor.White, "PLAYER", Vitals(val));
			}
			Block(ConsoleColor.DarkGreen, "CHEATS", CheatStates());
		}
	}

	private static string F(float v)
	{
		return v.ToString("0.0");
	}

	private static string Vitals(Body b)
	{
		//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_0016: 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_0025: 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)
		StringBuilder stringBuilder = new StringBuilder();
		Vector2 val = Vector2.op_Implicit(((Component)b).transform.position);
		Vector2 val2 = (((Object)(object)b.rb != (Object)null) ? b.rb.velocity : Vector2.zero);
		stringBuilder.Append("Character ").Append(b.charType).Append(b.alive ? ", alive" : ", DEAD")
			.Append(b.conscious ? ", conscious" : ", UNCONSCIOUS")
			.Append(b.sleeping ? ", sleeping" : "")
			.Append(Plugin.Paused(b) ? (", God Mode PAUSED (" + Plugin.PauseReason + ")") : "")
			.Append(" | pos ")
			.Append(F(val.x))
			.Append(", ")
			.Append(F(val.y))
			.Append(" | vel ")
			.Append(F(val2.x))
			.Append(", ")
			.Append(F(val2.y))
			.Append('\n');
		stringBuilder.Append("Brain ").Append(F(b.brainHealth)).Append(" | consciousness ")
			.Append(F(b.consciousness))
			.Append(" | blood ")
			.Append(F(b.bloodVolume))
			.Append(" | oxygen ")
			.Append(F(b.bloodOxygen))
			.Append(" | BP ")
			.Append(F(b.bloodPressure))
			.Append(" | HR ")
			.Append(F(b.heartRate))
			.Append(" | fibrillation ")
			.Append(F(b.fibrillationProgress))
			.Append(" | embolism ")
			.Append(b.hasPulmonaryEmbolism)
			.Append('\n');
		stringBuilder.Append("Shock ").Append(F(b.shock)).Append(" | pain shock ")
			.Append(F(b.painShock))
			.Append(" | internal bleed ")
			.Append(F(b.internalBleeding))
			.Append(" | hemothorax ")
			.Append(F(b.hemothorax))
			.Append(" | septic ")
			.Append(F(b.septicShock))
			.Append(" | stroke ")
			.Append(F(b.strokeAmount))
			.Append(" | bleed speed ")
			.Append(b.totalBleedSpeed.ToString("0.000"))
			.Append('\n');
		stringBuilder.Append("Sickness ").Append(F(b.sicknessAmount)).Append(" | radiation ")
			.Append(F(b.radiationSickness))
			.Append(" | venom ")
			.Append(F(b.venomCurrent))
			.Append(" | barotrauma ")
			.Append(F(b.barotrauma))
			.Append(" | temp ")
			.Append(F(b.temperature))
			.Append("C | hearing loss ")
			.Append(F(b.hearingLoss))
			.Append('\n');
		stringBuilder.Append("Hunger ").Append(F(b.hunger)).Append(" | thirst ")
			.Append(F(b.thirst))
			.Append(" | energy ")
			.Append(F(b.energy))
			.Append(" | stamina ")
			.Append(F(b.stamina))
			.Append(" | mood ")
			.Append(F(b.totalHappiness))
			.Append(" (base ")
			.Append(F(b.happiness))
			.Append(") | trauma ")
			.Append(F(b.traumaAmount))
			.Append('\n');
		Limb[] limbs = b.limbs;
		if (limbs != null)
		{
			foreach (Limb val3 in limbs)
			{
				if (!((Object)(object)val3 == (Object)null))
				{
					stringBuilder.Append("  ").Append(((Object)((Component)val3).gameObject).name.PadRight(14));
					if (val3.dismembered)
					{
						stringBuilder.Append("LOST\n");
					}
					else
					{
						stringBuilder.Append(" skin ").Append(F(val3.skinHealth).PadLeft(5)).Append(" muscle ")
							.Append(F(val3.muscleHealth).PadLeft(5))
							.Append(" bleed ")
							.Append(val3.bleedAmount.ToString("0.00"))
							.Append(" pain ")
							.Append(F(val3.pain))
							.Append(" infection ")
							.Append(F(val3.infectionAmount))
							.Append(" shrapnel ")
							.Append(val3.shrapnel)
							.Append(LimbFlags(val3))
							.Append('\n');
					}
				}
			}
		}
		return stringBuilder.ToString();
	}

	private static string LimbFlags(Limb l)
	{
		string text = "";
		if (l.broken)
		{
			text += " BROKEN";
		}
		if (l.dislocated)
		{
			text += " DISLOCATED";
		}
		if (l.infected)
		{
			text += " INFECTED";
		}
		return text;
	}

	private static string LimbState(Limb l)
	{
		if ((Object)(object)l == (Object)null)
		{
			return "";
		}
		if (l.dismembered)
		{
			return "lost";
		}
		string text = LimbFlags(l).Trim().ToLowerInvariant();
		if (l.bleedAmount > 0.1f)
		{
			text = text + ((text.Length > 0) ? " " : "") + "bleeding";
		}
		if (text.Length != 0)
		{
			return text;
		}
		return "fine";
	}

	private static string Held(Body b)
	{
		try
		{
			Item item = b.GetItem(b.handSlot);
			return ((Object)(object)item != (Object)null) ? item.id : "nothing";
		}
		catch (Exception)
		{
			return "?";
		}
	}

	internal static void Watch()
	{
		if (!open || Time.unscaledTime < nextWatch)
		{
			return;
		}
		nextWatch = Time.unscaledTime + 0.25f;
		ConsoleColor consoleColor = ConsoleColor.Magenta;
		if (Time.timeScale != wTimeScale)
		{
			if (wTimeScale >= 0f)
			{
				Line(consoleColor, "EVENT", "Time scale " + wTimeScale.ToString("0.##") + " -> " + Time.timeScale.ToString("0.##"));
			}
			wTimeScale = Time.timeScale;
		}
		if (PauseHandler.paused != wPaused)
		{
			wPaused = PauseHandler.paused;
			Line(consoleColor, "EVENT", wPaused ? "Game paused" : "Game unpaused");
		}
		WorldGeneration world = WorldGeneration.world;
		int num = (((Object)(object)world != (Object)null) ? world.biomeDepth : (-1));
		if (num != wLayer)
		{
			wLayer = num;
			if ((Object)(object)world != (Object)null)
			{
				string text = ((world.biomeTitles != null && num >= 0 && num < world.biomeTitles.Length) ? world.biomeTitles[num] : "?");
				Line(consoleColor, "EVENT", "Now on layer " + (num + 1) + "/" + world.amountOfLayers + " - " + text + ((world.endlessLoops > 0) ? (" (loop " + world.endlessLoops + ")") : ""));
			}
		}
		Body val = (((Object)(object)PlayerCamera.main != (Object)null) ? PlayerCamera.main.body : null);
		if ((Object)(object)val != (Object)(object)wBody)
		{
			wBody = val;
			if ((Object)(object)val != (Object)null)
			{
				Line(consoleColor, "EVENT", "Player body: " + ((Object)((Component)val).gameObject).name + " (character " + val.charType + ")");
			}
			else if (wLimbs != null)
			{
				Line(consoleColor, "EVENT", "Player body gone");
			}
			wLimbs = null;
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			wAlive = val.alive;
			wConscious = val.conscious;
			wSleeping = val.sleeping;
			wHeld = Held(val);
		}
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		if (val.alive != wAlive)
		{
			wAlive = val.alive;
			Line(wAlive ? consoleColor : ConsoleColor.Red, "EVENT", wAlive ? "Player is alive again" : "PLAYER DIED");
		}
		if (val.conscious != wConscious)
		{
			wConscious = val.conscious;
			Line(consoleColor, "EVENT", wConscious ? "Player woke up / regained consciousness" : "Player lost consciousness");
		}
		if (val.sleeping != wSleeping)
		{
			wSleeping = val.sleeping;
			Line(consoleColor, "EVENT", wSleeping ? "Player fell asleep" : "Player stopped sleeping");
		}
		string text2 = Held(val);
		if (text2 != wHeld)
		{
			Line(consoleColor, "EVENT", "Holding: " + wHeld + " -> " + text2);
			wHeld = text2;
		}
		Limb[] limbs = val.limbs;
		if (limbs == null)
		{
			return;
		}
		if (wLimbs == null || wLimbs.Length != limbs.Length)
		{
			wLimbs = new string[limbs.Length];
			for (int i = 0; i < limbs.Length; i++)
			{
				wLimbs[i] = LimbState(limbs[i]);
			}
			return;
		}
		for (int j = 0; j < limbs.Length; j++)
		{
			string text3 = LimbState(limbs[j]);
			if (!(text3 == wLimbs[j]))
			{
				Line(ConsoleColor.DarkYellow, "EVENT", "Limb " + (((Object)(object)limbs[j] != (Object)null) ? ((Object)((Component)limbs[j]).gameObject).name : ("#" + j)) + ": " + wLimbs[j] + " -> " + text3);
				wLimbs[j] = text3;
			}
		}
	}
}
internal static class LoadedNotice
{
	private static bool shown;

	private static GameObject canvasGo;

	internal static void Hook()
	{
		SceneManager.sceneLoaded += delegate
		{
			if (!shown)
			{
				shown = true;
				Runner.Ensure();
				((MonoBehaviour)Runner.Instance).StartCoroutine(Show());
			}
		};
	}

	private static TMP_FontAsset GameFont()
	{
		TMP_Text[] array = Object.FindObjectsOfType<TMP_Text>();
		for (int i = 0; i < array.Length; i++)
		{
			if ((Object)(object)array[i] != (Object)null && (Object)(object)array[i].font != (Object)null)
			{
				return array[i].font;
			}
		}
		return TMP_Settings.defaultFontAsset;
	}

	private static IEnumerator Show()
	{
		yield return (object)new WaitForSecondsRealtime(1.2f);
		if (!MultiplayerGuard.Check())
		{
			if ((Object)(object)canvasGo == (Object)null)
			{
				canvasGo = new GameObject("CUCheatsNoticeCanvas");
				Object.DontDestroyOnLoad((Object)(object)canvasGo);
				Canvas val = canvasGo.AddComponent<Canvas>();
				val.renderMode = (RenderMode)0;
				val.sortingOrder = 32001;
				CanvasScaler val2 = canvasGo.AddComponent<CanvasScaler>();
				val2.uiScaleMode = (ScaleMode)1;
				val2.referenceResolution = new Vector2(1920f, 1080f);
				val2.matchWidthOrHeight = 0.5f;
			}
			bool lewd = Chainloader.PluginInfos.ContainsKey("lewdstatus");
			string version = "?";
			if (Chainloader.PluginInfos.TryGetValue("cucheats", out var info))
			{
				version = info.Metadata.Version.ToString();
			}
			GameObject go = new GameObject("CUCheatsNotice");
			go.transform.SetParent(canvasGo.transform, false);
			TextMeshProUGUI t = go.AddComponent<TextMeshProUGUI>();
			TMP_FontAsset font = GameFont();
			if ((Object)(object)font != (Object)null)
			{
				((TMP_Text)t).font = font;
			}
			((TMP_Text)t).fontSize = 20f;
			((TMP_Text)t).alignment = (TextAlignmentOptions)1025;
			((TMP_Text)t).enableWordWrapping = false;
			((TMP_Text)t).richText = true;
			((Graphic)t).raycastTarget = false;
			((TMP_Text)t).text = "> CUCheats.dll v" + version + " loaded";
			((Graphic)t).color = new Color(1f, 0.55f, 0.1f, 1f);
			((TMP_Text)t).outlineWidth = 0.2f;
			((TMP_Text)t).outlineColor = new Color32((byte)0, (byte)0, (byte)0, (byte)200);
			RectTransform rt = ((TMP_Text)t).rectTransform;
			rt.pivot = Vector2.zero;
			rt.anchorMin = Vector2.zero;
			rt.anchorMax = Vector2.zero;
			rt.anchoredPosition = new Vector2(16f, lewd ? 42f : 12f);
			rt.sizeDelta = new Vector2(900f, 30f);
			Plugin.Log.LogInfo((object)("Startup notice: CUCheats.dll v" + version));
			while (Runner.WarningOpen)
			{
				yield return null;
			}
			yield return (object)new WaitForSecondsRealtime(8f);
			float a = 1f;
			while (a > 0f && (Object)(object)t != (Object)null)
			{
				a -= Time.unscaledDeltaTime * 1.5f;
				((TMP_Text)t).alpha = Mathf.Max(0f, a);
				yield return null;
			}
			if ((Object)(object)go != (Object)null)
			{
				Object.Destroy((Object)(object)go);
			}
		}
	}
}
public class Runner : MonoBehaviour
{
	private const float TraderRange = 20f;

	private const int InfiniteCredit = 9999;

	private const float MenuColW = 360f;

	private const float MenuGap = 14f;

	private const float MenuFullW = 768f;

	private static Runner instance;

	private bool mpPopupOpen;

	private bool mpHandled;

	private float nextNetCheck;

	private string toast;

	private float toastUntil;

	private Rect window = new Rect(20f, 70f, 470f, 720f);

	private Vector2 feedScroll;

	private string cached = "";

	private float nextSample;

	private float fpsSmoothed;

	private int restoresLastSecond;

	private int restoreBaseline;

	private GUIStyle textStyle;

	private bool menuOpen;

	private bool infiniteCredit;

	private Rect menuWindow = new Rect(40f, 70f, 930f, 380f);

	private Vector2 menuScroll;

	private float menuContentH;

	private GUIStyle sectionStyle;

	private bool warningDismissed;

	private GUIStyle warnTitleStyle;

	private GUIStyle warnBodyStyle;

	private GUIStyle warnButtonStyle;

	private GUIStyle watermarkStyle;

	private TraderScript trader;

	private float traderDist;

	private float nextFind;

	private float nextMoodCheck;

	private float nextTermStatus;

	private float nextTickError;

	private float nextWorldSync;

	private bool lastFullBright;

	private bool lastNoclip;

	private bool lastFreecam;

	private bool weSetUnchipped;

	private float appliedSpeed = 1f;

	private Camera zoomCam;

	private float zoomBase;

	private Behaviour zoomPpc;

	private bool zoomPpcWasOn;

	private static readonly FieldInfo BonusTemp = AccessTools.Field(typeof(WorldGeneration), "bonusTemperatureOffset");

	private GameObject clickBlocker;

	private int tab;

	private static readonly string[] TabNames = new string[8] { "Player", "Movement", "Items", "Combat", "World", "Traders", "Challenges", "Settings" };

	private string spawnSearch = "";

	private string lastSearch;

	private int spawnAmountIndex;

	private static readonly int[] SpawnAmounts = new int[3] { 1, 5, 10 };

	private static readonly string[] SpawnAmountNames = new string[3] { "x1", "x5", "x10" };

	private Vector2 spawnScroll;

	private List<KeyValuePair<string, string>> itemNames;

	private readonly List<KeyValuePair<string, string>> searchHits = new List<KeyValuePair<string, string>>();

	private GUIStyle itemButtonStyle;

	internal static Runner Instance => instance;

	internal static bool WarningOpen
	{
		get
		{
			if ((Object)(object)instance != (Object)null)
			{
				return !instance.warningDismissed;
			}
			return false;
		}
	}

	internal static void Ensure()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		if (!((Object)(object)instance != (Object)null))
		{
			GameObject val = new GameObject("CUCheatsRunner");
			((Object)val).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)val);
			instance = val.AddComponent<Runner>();
			Plugin.Log.LogInfo((object)"Hotkey runner started.");
		}
	}

	private void Update()
	{
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		Feed.Tick();
		float unscaledDeltaTime = Time.unscaledDeltaTime;
		if (unscaledDeltaTime > 0f)
		{
			fpsSmoothed = ((fpsSmoothed <= 0f) ? (1f / unscaledDeltaTime) : Mathf.Lerp(fpsSmoothed, 1f / unscaledDeltaTime, 0.05f));
		}
		if (!mpHandled)
		{
			bool flag = MultiplayerGuard.Detected;
			if (!flag && Time.unscaledTime >= nextNetCheck)
			{
				nextNetCheck = Time.unscaledTime + 3f;
				flag = MultiplayerGuard.Check();
			}
			if (flag)
			{
				mpHandled = true;
				mpPopupOpen = true;
				warningDismissed = true;
				menuOpen = false;
				infiniteCredit = false;
			}
		}
		if (MultiplayerGuard.Detected)
		{
			BlockGameUI(mpPopupOpen);
			return;
		}
		BlockGameUI(!warningDismissed && !InGame());
		if (Input.GetKeyDown(Plugin.OverlayKey.Value))
		{
			Plugin.ShowOverlay.Value = !Plugin.ShowOverlay.Value;
		}
		if (Input.GetKeyDown(Plugin.MenuKey.Value))
		{
			menuOpen = !menuOpen;
			nextFind = 0f;
		}
		try
		{
			CheatTick();
		}
		catch (Exception ex)
		{
			if (Time.unscaledTime >= nextTickError)
			{
				nextTickError = Time.unscaledTime + 10f;
				Plugin.Log.LogWarning((object)("Cheat tick failed: " + ex));
			}
		}
		if (Time.unscaledTime >= nextMoodCheck)
		{
			nextMoodCheck = Time.unscaledTime + 0.5f;
			MoodWatch.Tick();
			Durability.Sweep();
			Quip.Tick();
			if (SteamManager.disableAchievements)
			{
				SteamManager.disableAchievements = false;
				Feed.Mod("Cleared the game's cheated-save flag (achievements stay on)");
			}
			Plugin.TryResume();
		}
		if ((menuOpen || infiniteCredit || Plugin.MaxTraderRep.Value) && Time.unscaledTime >= nextFind)
		{
			nextFind = Time.unscaledTime + 0.5f;
			FindTrader();
		}
		if (infiniteCredit && (Object)(object)trader != (Object)null && trader.valueGiven < 9999)
		{
			SetCredit(9999, log: false);
		}
		if (Plugin.MaxTraderRep.Value && (Object)(object)trader != (Object)null && (trader.reputation < 200f || trader.hostility > 0f))
		{
			trader.reputation = 200f;
			trader.hostility = 0f;
			RefreshTraderUI();
		}
		if (Terminal.IsOpen)
		{
			Terminal.Watch();
			if (Time.unscaledTime >= nextTermStatus)
			{
				nextTermStatus = Time.unscaledTime + Mathf.Max(1f, Plugin.TerminalStatusSeconds.Value);
				try
				{
					Terminal.Status(BuildSnapshot());
				}
				catch (Exception ex2)
				{
					Terminal.Line(ConsoleColor.Red, "TERMINAL", "Status failed: " + ex2);
				}
			}
		}
		if (Plugin.ShowOverlay.Value && Time.unscaledTime >= nextSample)
		{
			nextSample = Time.unscaledTime + 1f;
			restoresLastSecond = Stats.Restores - restoreBaseline;
			restoreBaseline = Stats.Restores;
			cached = BuildSnapshot();
		}
	}

	private void CheatTick()
	{
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		bool flag = InGame();
		ConsoleScript val = ConsoleScript.instance;
		Body val2 = (flag ? PlayerCamera.main.body : null);
		if ((Object)(object)val != (Object)null)
		{
			if (Plugin.FullBright.Value)
			{
				val.fullBright = true;
			}
			else if (lastFullBright)
			{
				val.fullBright = false;
			}
		}
		lastFullBright = Plugin.FullBright.Value;
		if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null && (Object)(object)val2.rb != (Object)null)
		{
			if (Plugin.Noclip.Value && !val.noClip)
			{
				val.noClip = true;
				val.noClipPos = Vector2.op_Implicit(((Component)val2).transform.position);
				val2.rb.simulated = false;
			}
			else if (!Plugin.Noclip.Value && lastNoclip && val.noClip)
			{
				val.noClip = false;
				val2.rb.simulated = true;
				val2.rb.velocity = Vector2.zero;
			}
		}
		lastNoclip = Plugin.Noclip.Value;
		if (flag && (Object)(object)val != (Object)null)
		{
			if (Plugin.FreeCamera.Value && !PlayerCamera.main.isFreecam)
			{
				PlayerCamera.main.isFreecam = true;
				val.freecamPos = Vector2.op_Implicit(((Component)PlayerCamera.main).transform.position);
			}
			else if (!Plugin.FreeCamera.Value && lastFreecam && PlayerCamera.main.isFreecam)
			{
				PlayerCamera.main.isFreecam = false;
			}
		}
		lastFreecam = Plugin.FreeCamera.Value;
		if (flag && !PauseHandler.paused && Time.timeScale > 0f)
		{
			float gameSpeed = Plugin.GameSpeed;
			if (gameSpeed != 1f)
			{
				if (Mathf.Approximately(Time.timeScale, 1f) || Mathf.Approximately(Time.timeScale, appliedSpeed))
				{
					Time.timeScale = gameSpeed;
				}
				appliedSpeed = gameSpeed;
			}
			else if (appliedSpeed != 1f)
			{
				if (Mathf.Approximately(Time.timeScale, appliedSpeed))
				{
					Time.timeScale = 1f;
				}
				appliedSpeed = 1f;
			}
		}
		Camera main = Camera.main;
		if ((Object)(object)zoomCam != (Object)null && (Object)(object)zoomCam != (Object)(object)main)
		{
			zoomCam = null;
		}
		if (flag && (Object)(object)main != (Object)null && Plugin.CameraZoom != 1f)
		{
			if ((Object)(object)zoomCam == (Object)null)
			{
				zoomCam = main;
				ref Behaviour reference = ref zoomPpc;
				Component component = ((Component)main).GetComponent("PixelPerfectCamera");
				reference = (Behaviour)(object)((component is Behaviour) ? component : null);
				zoomPpcWasOn = (Object)(object)zoomPpc != (Object)null && zoomPpc.enabled;
				if ((Object)(object)zoomPpc != (Object)null)
				{
					zoomPpc.enabled = false;
				}
				zoomBase = main.orthographicSize;
			}
			main.orthographicSize = zoomBase * Plugin.CameraZoom;
		}
		else if ((Object)(object)zoomCam != (Object)null)
		{
			zoomCam.orthographicSize = zoomBase;
			if ((Object)(object)zoomPpc != (Object)null)
			{
				zoomPpc.enabled = zoomPpcWasOn;
			}
			zoomCam = null;
		}
		if ((Object)(object)val2 != (Object)null && Plugin.ClickTeleport.Value && Input.GetMouseButtonDown(2))
		{
			Actions.TeleportToCursor();
			Stats.Hit("Teleports");
		}
		WorldGeneration world = WorldGeneration.world;
		if (!((Object)(object)val2 != (Object)null) || !((Object)(object)world != (Object)null) || !world.worldExists || !(Time.unscaledTime >= nextWorldSync))
		{
			return;
		}
		nextWorldSync = Time.unscaledTime + 0.5f;
		if (BonusTemp != null)
		{
			BonusTemp.SetValue(world, WorldGeneration.GetRunSettingFloat("temperatureoffset"));
		}
		WorldGeneration.globalDecayRate = WorldGeneration.GetRunSettingFloat("itemdecayrate");
		world.maxTimePerLayer = WorldGeneration.GetRunSettingFloat("timelimit") * 60f;
		if (Plugin.UnchippedChallenge.Value && !world.unchippedMode)
		{
			world.SetUnchipped(true);
			weSetUnchipped = true;
		}
		else if (!Plugin.UnchippedChallenge.Value && weSetUnchipped)
		{
			weSetUnchipped = false;
			if (world.unchippedMode && !WorldGeneration.GetRunSettingBool("unchipped"))
			{
				world.SetUnchipped(false);
			}
		}
	}

	private void Act(string msg)
	{
		if (!string.IsNullOrEmpty(msg))
		{
			Show(msg);
		}
	}

	private void Show(string msg)
	{
		toast = msg;
		toastUntil = Time.unscaledTime + 2f;
		Plugin.Log.LogInfo((object)msg);
		Feed.Mod(msg);
	}

	private void FindTrader()
	{
		//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_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		trader = null;
		traderDist = 0f;
		Body val = (((Object)(object)PlayerCamera.main != (Object)null) ? PlayerCamera.main.body : null);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		Vector2 val2 = Vector2.op_Implicit(((Component)val).transform.position);
		float num = 20f;
		TraderScript[] array = Object.FindObjectsOfType<TraderScript>();
		for (int i = 0; i < array.Length; i++)
		{
			float num2 = Vector2.Distance(val2, Vector2.op_Implicit(((Component)array[i]).transform.position));
			if (num2 <= num)
			{
				num = num2;
				trader = array[i];
			}
		}
		if ((Object)(object)trader != (Object)null)
		{
			traderDist = num;
		}
	}

	private void RefreshTraderUI()
	{
		PlayerCamera main = PlayerCamera.main;
		if (!((Object)(object)main == (Object)null) && !((Object)(object)trader == (Object)null))
		{
			TraderScript currentTrader = main.currentTrader;
			main.currentTrader = trader;
			try
			{
				main.UpdateTradeTexts();
				main.RefreshTraderInventories();
			}
			catch (Exception)
			{
			}
			main.currentTrader = currentTrader;
		}
	}

	private void RefreshInventory()
	{
		if (!((Object)(object)trader == (Object)null))
		{
			trader.GenerateInventory();
			RefreshTraderUI();
			Stats.Hit("Inventory refreshes");
			Feed.Mod("Refreshed " + TraderName(trader) + "'s inventory (" + trader.items.Count + " items)");
		}
	}

	private void CheatToggle(ConfigEntry<bool> entry, string label)
	{
		bool flag = GUILayout.Toggle(entry.Value, " " + label, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		if (flag != entry.Value)
		{
			entry.Value = flag;
			Show(label + ": " + (flag ? "ON" : "OFF"));
			if (entry == Plugin.FreeShopping)
			{
				RefreshTraderUI();
			}
		}
	}

	private void SetCredit(int amount, bool log)
	{
		if (!((Object)(object)trader == (Object)null))
		{
			if (amount < 0)
			{
				amount = 0;
			}
			int valueGiven = trader.valueGiven;
			trader.valueGiven = amount;
			RefreshTraderUI();
			if (log)
			{
				Stats.Hit("Credit edits");
				Feed.Mod("Trade credit " + valueGiven + " -> " + amount + " (" + TraderName(trader) + ")");
			}
		}
	}

	private static string TraderName(TraderScript t)
	{
		return ((Object)((Component)t).gameObject).name.Replace("(Clone)", "").Trim();
	}

	private static string OnOff(bool v)
	{
		if (!v)
		{
			return "<color=#ff6b6b>OFF</color>";
		}
		return "<color=#9cff8a>ON</color>";
	}

	private static string Header(string s)
	{
		return "<b><color=#7fd4ff>" + s + "</color></b>\n";
	}

	private static int Count<T>() where T : Object
	{
		return Object.FindObjectsOfType<T>().Length;
	}

	private string BuildSnapshot()
	{
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.Append(Header("ENGINE"));
		stringBuilder.Append("FPS ").Append(fpsSmoothed.ToString("0")).Append("  |  frame ")
			.Append((Time.unscaledDeltaTime * 1000f).ToString("0.0"))
			.Append(" ms")
			.Append("  |  timeScale ")
			.Append(Time.timeScale.ToString("0.##"))
			.Append('\n');
		StringBuilder stringBuilder2 = stringBuilder.Append("Scene: ");
		Scene activeScene = SceneManager.GetActiveScene();
		stringBuilder2.Append(((Scene)(ref activeScene)).name).Append("  |  Unity ").Append(Application.unityVersion)
			.Append('\n');
		stringBuilder.Append("Managed heap: ").Append(((float)GC.GetTotalMemory(forceFullCollection: false) / 1048576f).ToString("0.0")).Append(" MB")
			.Append("  |  frame #")
			.Append(Time.frameCount)
			.Append('\n');
		Rigidbody2D[] array = Object.FindObjectsOfType<Rigidbody2D>();
		int num = 0;
		for (int i = 0; i < array.Length; i++)
		{
			if (array[i].IsAwake())
			{
				num++;
			}
		}
		AudioSource[] array2 = Object.FindObjectsOfType<AudioSource>();
		int num2 = 0;
		for (int j = 0; j < array2.Length; j++)
		{
			if (array2[j].isPlaying)
			{
				num2++;
			}
		}
		stringBuilder.Append("GameObjects: ").Append(Count<Transform>()).Append("  |  Rigidbodies: ")
			.Append(array.Length)
			.Append(" (")
			.Append(num)
			.Append(" awake)")
			.Append("  |  Audio: ")
			.Append(num2)
			.Append(" playing\n\n");
		WorldGeneration world = WorldGeneration.world;
		stringBuilder.Append(Header("WORLD"));
		if ((Object)(object)world == (Object)null)
		{
			stringBuilder.Append("<color=#777777>No world loaded (menu)</color>\n\n");
		}
		else
		{
			string value = ((world.biomeTitles != null && world.biomeDepth >= 0 && world.biomeDepth < world.biomeTitles.Length) ? world.biomeTitles[world.biomeDepth] : "?");
			stringBuilder.Append("Layer ").Append(world.biomeDepth + 1).Append('/')
				.Append(world.amountOfLayers)
				.Append(" - ")
				.Append(value)
				.Append((world.endlessLoops > 0) ? ("  (loop " + world.endlessLoops + ")") : "")
				.Append('\n');
			stringBuilder.Append("Generating: ").Append(world.generatingWorld).Append("  |  since gen: ")
				.Append(world.timeSinceFinishedGeneration.ToString("0"))
				.Append("s")
				.Append("  |  on layer: ")
				.Append(world.layerTimeSpent.ToString("0"))
				.Append("s\n");
			stringBuilder.Append("Run time: ").Append(world.realTimeElapsed.ToString("0")).Append("s  |  World ")
				.Append(world.width)
				.Append('x')
				.Append(world.height)
				.Append(" blocks, ")
				.Append(Count<ChunkScript>())
				.Append(" chunks\n");
			stringBuilder.Append("Ambient temp: ").Append((world.ambientTemperature + world.temperatureOffset).ToString("0.0")).Append("C")
				.Append("  |  fog ")
				.Append(world.fogAmount.ToString("0.00"))
				.Append("  |  rain ")
				.Append(world.forceRain ? "forced" : "-")
				.Append("  |  fungus rain ")
				.Append(world.fungusRainIntensity.ToString("0.00"))
				.Append('\n');
			stringBuilder.Append("Earthquake: ").Append(world.earthquakeIntensity.ToString("0.00")).Append(" (t ")
				.Append(world.earthquakeTime.ToString("0.0"))
				.Append(", next ")
				.Append(world.earthquakeDelay.ToString("0"))
				.Append("s)")
				.Append("  |  cutscene: ")
				.Append(world.cutsceneActive)
				.Append('\n');
			stringBuilder.Append("Loot x").Append(world.lootRarityMultiplier.ToString("0.##")).Append("  |  traps x")
				.Append(world.trapRarityMultiplier.ToString("0.##"))
				.Append("  |  decay x")
				.Append(WorldGeneration.globalDecayRate.ToString("0.##"))
				.Append("  |  traveled ")
				.Append(world.totalTraveled)
				.Append("\n\n");
			stringBuilder.Append(Header("ENTITIES"));
			stringBuilder.Append("Items: ").Append(Count<Item>()).Append("  |  Buildings: ")
				.Append(Count<BuildingEntity>())
				.Append("  |  Mines: ")
				.Append(Count<MineScript>())
				.Append("  |  Corpses: ")
				.Append(Count<CorpseScript>())
				.Append('\n');
			stringBuilder.Append("Turrets: ").Append(Count<TurretScript>() + Count<CeilingTurret>()).Append("  |  Drones: ")
				.Append(Count<DroneScript>() + Count<LaserDroneScript>())
				.Append("  |  Guards: ")
				.Append(Count<GuardScript>())
				.Append("  |  Crystals: ")
				.Append(Count<CrystalEnemy>())
				.Append('\n');
			stringBuilder.Append("Spiders: ").Append(Count<SpiderHandler>()).Append("  |  Bloodsuckers: ")
				.Append(Count<BloodSuckerScript>())
				.Append("  |  Thornbacks: ")
				.Append(Count<ElderThornbackBehaviour>())
				.Append("  |  Xaloris: ")
				.Append(Count<XalorisScript>())
				.Append("\n\n");
		}
		if ((Object)(object)world != (Object)null && (Object)(object)PlayerCamera.main != (Object)null)
		{
			MoodWatch.Describe(stringBuilder, PlayerCamera.main.body);
		}
		stringBuilder.Append(Header("MOD"));
		stringBuilder.Append("No Fall Damage ").Append(OnOff(Plugin.NoFallDamage.Value)).Append("   God Mode ")
			.Append(OnOff(Plugin.GodMode.Value))
			.Append("   Infinite credit ")
			.Append(OnOff(infiniteCredit))
			.Append('\n');
		stringBuilder.Append("Vital restores: ").Append(restoresLastSecond).Append("/s  (")
			.Append(Stats.Restores)
			.Append(" total)\n");
		if (Stats.Order.Count == 0)
		{
			stringBuilder.Append("<color=#777777>Nothing intercepted yet</color>\n");
		}
		for (int k = 0; k < Stats.Order.Count; k++)
		{
			string text = Stats.Order[k];
			stringBuilder.Append(text).Append(": <b>").Append(Stats.Get(text))
				.Append("</b>");
			stringBuilder.Append((k % 2 == 1) ? "\n" : "   |   ");
		}
		if (Stats.Order.Count % 2 == 1)
		{
			stringBuilder.Append('\n');
		}
		return stringBuilder.ToString();
	}

	private void OnGUI()
	{
		//IL_0031: 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)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Expected O, but got Unknown
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Expected O, but got Unknown
		//IL_01f9: 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_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_0297: Expected O, but got Unknown
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d9: Expected O, but got Unknown
		//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_043f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0446: Expected O, but got Unknown
		//IL_0472: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0415: Expected O, but got Unknown
		//IL_0410: Unknown result type (might be due to invalid IL or missing references)
		//IL_0415: Unknown result type (might be due to invalid IL or missing references)
		GUI.depth = -1000;
		if (MultiplayerGuard.Detected)
		{
			if (mpPopupOpen)
			{
				GUI.color = new Color(0f, 0f, 0f, 0.75f);
				GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.whiteTexture);
				GUI.color = Color.white;
				float num = Mathf.Min(620f, (float)Screen.width - 40f);
				float num2 = 470f;
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((float)Screen.width - num) * 0.5f, ((float)Screen.height - num2) * 0.5f, num, num2);
				GUI.ModalWindow(3087, val, new WindowFunction(DrawMultiplayer), "CU Cheats - Multiplayer detected");
			}
			return;
		}
		if (Plugin.AnyCheatOn())
		{
			if (watermarkStyle == null)
			{
				watermarkStyle = new GUIStyle(GUI.skin.label);
				watermarkStyle.fontSize = 11;
				watermarkStyle.alignment = (TextAnchor)8;
				watermarkStyle.wordWrap = false;
			}
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor((float)(Screen.width - 210), (float)(Screen.height - 22), 200f, 18f);
			GUI.color = new Color(0f, 0f, 0f, 0.35f);
			GUI.Label(new Rect(((Rect)(ref val2)).x + 1f, ((Rect)(ref val2)).y + 1f, ((Rect)(ref val2)).width, ((Rect)(ref val2)).height), "cucheats enabled", watermarkStyle);
			GUI.color = new Color(1f, 1f, 1f, 0.45f);
			GUI.Label(val2, "cucheats enabled", watermarkStyle);
			GUI.color = Color.white;
		}
		if (!warningDismissed && !InGame())
		{
			GUI.color = new Color(0f, 0f, 0f, 0.75f);
			GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.whiteTexture);
			GUI.color = Color.white;
			float num3 = Mathf.Min(620f, (float)Screen.width - 40f);
			float num4 = 330f;
			Rect val3 = default(Rect);
			((Rect)(ref val3))..ctor(((float)Screen.width - num3) * 0.5f, ((float)Screen.height - num4) * 0.5f, num3, num4);
			GUI.ModalWindow(3086, val3, new WindowFunction(DrawWarning), "CU Cheats - Warning");
			return;
		}
		if (TrainerAd.Active(InGame()))
		{
			TrainerAd.Draw();
			return;
		}
		if (Plugin.ShowOverlay.Value)
		{
			window = GUI.Window(3084, window, new WindowFunction(DrawWindow), "CU Cheats - Debug  (F9 to hide, drag to move)");
		}
		if (menuOpen)
		{
			float num5 = Mathf.Min(768f, (float)Screen.width - 20f);
			float num6 = Mathf.Min((menuContentH > 0f) ? (menuContentH + 40f) : 380f, (float)Screen.height - 20f);
			((Rect)(ref menuWindow)).width = Mathf.Max(200f, num5);
			((Rect)(ref menuWindow)).height = Mathf.Max(160f, num6);
			((Rect)(ref menuWindow)).x = Mathf.Clamp(((Rect)(ref menuWindow)).x, 0f, Mathf.Max(0f, (float)Screen.width - ((Rect)(ref menuWindow)).width));
			((Rect)(ref menuWindow)).y = Mathf.Clamp(((Rect)(ref menuWindow)).y, 0f, Mathf.Max(0f, (float)Screen.height - ((Rect)(ref menuWindow)).height));
			menuWindow = GUI.Window(3085, menuWindow, new WindowFunction(DrawMenu), string.Concat("CU Cheats  (", Plugin.MenuKey.Value, " to hide)"));
		}
		if (toast != null && Time.unscaledTime <= toastUntil)
		{
			GUIStyle val4 = new GUIStyle(GUI.skin.label);
			val4.fontSize = 22;
			val4.fontStyle = (FontStyle)1;
			Rect val5 = default(Rect);
			((Rect)(ref val5))..ctor(20f, 20f, 600f, 40f);
			GUI.color = Color.black;
			GUI.Label(new Rect(((Rect)(ref val5)).x + 2f, ((Rect)(ref val5)).y + 2f, ((Rect)(ref val5)).width, ((Rect)(ref val5)).height), toast, val4);
			GUI.color = Color.white;
			GUI.Label(val5, toast, val4);
		}
	}

	private void DrawWindow(int id)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		if (textStyle == null)
		{
			textStyle = new GUIStyle(GUI.skin.label);
			textStyle.richText = true;
			textStyle.fontSize = 12;
			textStyle.wordWrap = true;
		}
		GUILayout.Label("<color=#aaaaaa><b>(cheat mod made by Experiment #10264)</b></color>", textStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Label(cached, textStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Label("<b><color=#7fd4ff>LIVE FEED</color></b>", textStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		if (GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }))
		{
			Feed.Clear();
		}
		GUILayout.EndHorizontal();
		feedScroll = GUILayout.BeginScrollView(feedScroll, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		StringBuilder stringBuilder = new StringBuilder();
		Feed.Render(stringBuilder, 60);
		GUILayout.Label(stringBuilder.ToString(), textStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.EndScrollView();
		GUI.DragWindow(new Rect(0f, 0f, 10000f, 22f));
	}

	private void DrawWarning(int id)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Expected O, but got Unknown
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Expected O, but got Unknown
		if (warnTitleStyle == null)
		{
			warnTitleStyle = new GUIStyle(GUI.skin.label);
			warnTitleStyle.richText = true;
			warnTitleStyle.wordWrap = true;
			warnTitleStyle.alignment = (TextAnchor)4;
			warnTitleStyle.fontSize = 22;
			warnTitleStyle.fontStyle = (FontStyle)1;
			warnBodyStyle = new GUIStyle(warnTitleStyle);
			warnBodyStyle.fontSize = 13;
			warnBodyStyle.fontStyle = (FontStyle)0;
			warnButtonStyle = new GUIStyle(GUI.skin.button);
			warnButtonStyle.fontSize = 14;
			warnButtonStyle.wordWrap = true;
		}
		GUILayout.Space(10f);
		GUILayout.Label("<color=#ff5050>I VERY HIGHLY SUGGEST YOU PLAY AND BEAT THE GAME WITHOUT MY CHEAT MOD FIRST!</color>", warnTitleStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Space(10f);
		GUILayout.Label("If you want to do that, close the game below. The folder with the mod will open so you can move or delete CUCheats.dll before playing.", warnBodyStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.FlexibleSpace();
		if (GUILayout.Button("Close the game and open the mod folder", warnButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(42f) }))
		{
			OpenModFolderAndQuit();
		}
		GUILayout.Space(6f);
		if (GUILayout.Button("I'm a Cheater Cheater Pumpkin Eater", warnButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(42f) }))
		{
			warningDismissed = true;
			Feed.Mod("Startup warning ignored");
		}
		GUILayout.Space(6f);
	}

	private void BlockGameUI(bool block)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Expected O, but got Unknown
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
		if (block && (Object)(object)clickBlocker == (Object)null)
		{
			clickBlocker = new GameObject("CUCheatsClickBlocker");
			Object.DontDestroyOnLoad((Object)(object)clickBlocker);
			Canvas val = clickBlocker.AddComponent<Canvas>();
			val.renderMode = (RenderMode)0;
			val.sortingOrder = 32767;
			clickBlocker.AddComponent<GraphicRaycaster>();
			GameObject val2 = new GameObject("Blocker");
			val2.transform.SetParent(clickBlocker.transform, false);
			Image val3 = val2.AddComponent<Image>();
			((Graphic)val3).color = new Color(0f, 0f, 0f, 0f);
			((Graphic)val3).raycastTarget = true;
			RectTransform rectTransform = ((Graphic)val3).rectTransform;
			rectTransform.anchorMin = Vector2.zero;
			rectTransform.anchorMax = Vector2.one;
			rectTransform.offsetMin = Vector2.zero;
			rectTransform.offsetMax = Vector2.zero;
		}
		else if (!block && (Object)(object)clickBlocker != (Object)null)
		{
			Object.Destroy((Object)(object)clickBlocker);
			clickBlocker = null;
		}
	}

	private void DrawMultiplayer(int id)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Expected O, but got Unknown
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Expected O, but got Unknown
		if (warnTitleStyle == null)
		{
			warnTitleStyle = new GUIStyle(GUI.skin.label);
			warnTitleStyle.richText = true;
			warnTitleStyle.wordWrap = true;
			warnTitleStyle.alignment = (TextAnchor)4;
			warnTitleStyle.fontSize = 22;
			warnTitleStyle.fontStyle = (FontStyle)1;
			warnBodyStyle = new GUIStyle(warnTitleStyle);
			warnBodyStyle.fontSize = 13;
			warnBodyStyle.fontStyle = (FontStyle)0;
			warnButtonStyle = new GUIStyle(GUI.skin.button);
			warnButtonStyle.fontSize = 14;
			warnButtonStyle.wordWrap = true;
		}
		GUILayout.Space(10f);
		GUILayout.Label("<color=#ff9a3c>MULTIPLAYER MOD DETECTED</color>", warnTitleStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Space(8f);
		GUILayout.Label("CU Cheats has turned itself off completely, so it doesn't ruin the fun for your friends. No cheats, menu or overlay will work this session.", warnBodyStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Space(6f);
		GUILayout.Label("<color=#aaaaaa>Found: " + string.Join(", ", MultiplayerGuard.Found.ToArray()) + "</color>", warnBodyStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Space(6f);
		GUILayout.Label("To use the cheats in single-player, switch Casualties Together off in its menu (Settings > General > Deactivate Multiplayer Mod), or remove the multiplayer mod.", warnBodyStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Space(8f);
		GUILayout.Label("<color=#ffd966><b>Not using a multiplayer mod?</b> Then this is a false alarm. Please send a bug report immediately on the CU Cheats Nexus page (Bugs tab), with the \"Found\" line above and your BepInEx\\LogOutput.log file.</color>", warnBodyStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.FlexibleSpace();
		if (GUILayout.Button("Report a false alarm (opens the Bugs page)", warnButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }))
		{
			Application.OpenURL("https://www.nexusmods.com/scavprototype/mods/874?tab=bugs");
		}
		GUILayout.Space(4f);
		if (GUILayout.Button("OK", warnButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(42f) }))
		{
			mpPopupOpen = false;
		}
		GUILayout.Space(6f);
	}

	private void Start()
	{
		if (GameBeaten())
		{
			warningDismissed = true;
			Plugin.Log.LogInfo((object)"Game already beaten on this PC - skipping the startup warning.");
			Feed.Mod("Game already beaten - startup warning skipped");
		}
	}

	internal static bool GameBeaten()
	{
		try
		{
			if (PlayerPrefs.GetInt("didescape", 0) == 1)
			{
				return true;
			}
			for (int i = 0; i < 10; i++)
			{
				if (PlayerPrefs.GetInt("wonchar" + i, 0) > 0)
				{
					return true;
				}
			}
		}
		catch (Exception)
		{
		}
		return false;
	}

	private static void OpenModFolderAndQuit()
	{
		string location = typeof(Plugin).Assembly.Location;
		try
		{
			if (!string.IsNullOrEmpty(location) && File.Exists(location))
			{
				Process.Start("explorer.exe", "/select,\"" + location + "\"");
			}
			else
			{
				Process.Start("explorer.exe", "\"" + Paths.PluginPath + "\"");
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("Could not open the mod folder: " + ex.Message));
		}
		Plugin.Log.LogInfo((object)"Closing the game from the startup warning.");
		Application.Quit();
	}

	private static bool InGame()
	{
		if ((Object)(object)PlayerCamera.main != (Object)null && (Object)(object)PlayerCamera.main.body != (Object)null)
		{
			return (Object)(object)WorldGeneration.world != (Object)null;
		}
		return false;
	}

	private void Section(string title)
	{
		GUILayout.Space(8f);
		GUILayout.Label("<b><color=#7fd4ff>" + title + "</color></b>", sectionStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
	}

	private void Note(string text)
	{
		GUILayout.Label("<color=#777777>   " + text + "</color>", textStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
	}

	private static string X(float v)
	{
		return " (x" + v.ToString("0.##") + ")";
	}

	private void DrawMenu(int id)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Expected O, but got Unknown
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Invalid comparison between Unknown and I4
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		if (textStyle == null)
		{
			textStyle = new GUIStyle(GUI.skin.label);
			textStyle.richText = true;
			textStyle.fontSize = 12;
			textStyle.wordWrap = true;
		}
		if (sectionStyle == null)
		{
			sectionStyle = new GUIStyle(textStyle);
			sectionStyle.fontSize = 13;
		}
		if (itemButtonStyle == null)
		{
			itemButtonStyle = new GUIStyle(GUI.skin.button);
			itemButtonStyle.richText = true;
			itemButtonStyle.alignment = (TextAnchor)3;
			itemButtonStyle.fontSize = 12;
		}
		GUILayout.BeginArea(new Rect(6f, 22f, ((Rect)(ref menuWindow)).width - 12f, ((Rect)(ref menuWindow)).height - 28f));
		int num = GUILayout.Toolbar(tab, TabNames, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(24f) });
		if (num != tab)
		{
			tab = num;
			menuScroll = Vector2.zero;
			menuContentH = 0f;
		}
		menuScroll = GUILayout.BeginScrollView(menuScroll, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILa