Decompiled source of Techtonica Console Commands v0.1.0

plugins/Techtonica-Console-Commands/console_commands.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PropStreaming;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("console_commands")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1+6a378760d8c82e3fc03f67b7219e54a1046a096a")]
[assembly: AssemblyProduct("Techtonica Console Commands")]
[assembly: AssemblyTitle("console_commands")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ConsoleCommands
{
	[HarmonyPatch]
	public class AccumulatorPatch
	{
		public static int AccumulatorsAffected;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(AccumulatorInstance), "SimUpdate")]
		private static void Postfix(ref AccumulatorInstance __instance)
		{
			if (ConsoleCommands.bShouldFillAccumulators)
			{
				if (AccumulatorsAffected < MachineManager.instance.GetMachineList((MachineTypeEnum)24).GetCurrentArrayCount())
				{
					__instance.storedEnergy = ((AccumulatorInstance)(ref __instance)).maxCapacity;
					AccumulatorsAffected++;
				}
				else if (AccumulatorsAffected >= MachineManager.instance.GetMachineList((MachineTypeEnum)24).GetCurrentArrayCount())
				{
					ConsoleCommands.bShouldFillAccumulators = false;
					AccumulatorsAffected = 0;
				}
			}
		}
	}
	[BepInPlugin("nl.lunar.modding", "Techtonica Console Commands", "0.0.1")]
	[BepInProcess("Techtonica.exe")]
	public class ConsoleCommands : BaseUnityPlugin
	{
		private struct CommandKeyBindData
		{
			public KeyCode key;

			public MethodInfo command;

			public List<string> args;
		}

		public static ManualLogSource Logger;

		private string InputText;

		public List<string> InputHistory = new List<string>();

		public List<string> OutputHistory = new List<string>();

		public bool bIsEnabled;

		public const int MaxTotalHistory = 20;

		public static bool bHasScanOverride;

		public static float ScanOverrideMultiplier;

		public static ResourceGateInstance DoorToOpen;

		public static bool bShouldInstaMine;

		public static bool bShouldFillAccumulators;

		public bool bIsNoclipping;

		private List<CommandKeyBindData> Bindings = new List<CommandKeyBindData>();

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony.CreateAndPatchAll(typeof(OpenSesamePatch), (string)null);
			Harmony.CreateAndPatchAll(typeof(ScannerPatch), (string)null);
			Harmony.CreateAndPatchAll(typeof(InstaMolePatch), (string)null);
			Harmony.CreateAndPatchAll(typeof(AccumulatorPatch), (string)null);
			Logger.LogInfo((object)"Thanks for downloading and using Techtonica Console Commands!\nThe mod has just finished initializing.");
			Logger.LogWarning((object)"The mod is still in development, bugs and issues may occur.");
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
		}

		private void OnGUI()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (bIsEnabled)
			{
				GUI.SetNextControlName("Console");
				Input.eatKeyPressOnTextFieldFocus = false;
				GUI.skin.textField.fontSize = 20;
				InputText = GUI.TextField(new Rect(0f, (float)(Screen.height - 30), (float)Screen.width, 30f), InputText);
			}
		}

		private void Update()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Player.instance == (Object)null))
			{
				if (bIsNoclipping)
				{
					((Component)Player.instance).transform.position = ((Component)Player.instance.cam).transform.position;
				}
				if (Bindings.Count > 0 && !bIsEnabled)
				{
					HandleKeyBinds();
				}
				if (Input.GetKeyDown((KeyCode)47))
				{
					ToggleConsole();
				}
				if (bIsEnabled && Input.GetKeyDown((KeyCode)13) && InputText != "")
				{
					HandleCommand(InputText);
					UpdateHistory(InputText, bIsOutput: false);
					InputText = "";
				}
			}
		}

		private void HandleKeyBinds()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < Bindings.Count; i++)
			{
				if (Input.GetKeyDown(Bindings[i].key))
				{
					if (Bindings[i].args != null)
					{
						MethodInfo command = Bindings[i].command;
						object[] parameters = Enumerable.ToArray(Bindings[i].args);
						command.Invoke(this, parameters);
					}
					else
					{
						Bindings[i].command.Invoke(this, null);
					}
				}
			}
		}

		private void ToggleConsole()
		{
			bIsEnabled = !bIsEnabled;
			InputHandler.instance.uiInputBlocked = bIsEnabled;
		}

		public void UpdateHistory(string TextToAdd, bool bIsOutput)
		{
			if (!bIsOutput)
			{
				if (InputHistory.Count <= 10)
				{
					InputHistory.Add(TextToAdd);
					return;
				}
				InputHistory.RemoveAt(0);
				InputHistory.Add(TextToAdd);
			}
			else if (OutputHistory.Count <= 10)
			{
				OutputHistory.Add(TextToAdd);
			}
			else
			{
				OutputHistory.RemoveAt(0);
				OutputHistory.Add(TextToAdd);
			}
		}

		public void HandleCommand(string UserInput)
		{
			string name = UserInput.ToLower().Split(' ')[0];
			List<string> list = UserInput.Split(' ').ToList();
			list.RemoveAt(0);
			MethodInfo method = ((object)this).GetType().GetMethod(name);
			if (method != null)
			{
				object[] parameters = list.ToArray();
				method.Invoke(this, parameters);
			}
			else
			{
				DetermineAndLogError(method, UserInput, list);
			}
		}

		private void DetermineAndLogError(MethodInfo theMethod, string UserInput, List<string> args)
		{
			if (theMethod == null)
			{
				LogCommandError("Command '" + UserInput.Split(' ')[0] + "' doesn't exist! Are you sure you typed it correctly?", bShouldAppearInHistory: true);
			}
			else if (args.Count != theMethod.GetParameters().Length)
			{
				LogCommandError("Missing or obsolete arguments! Expected " + theMethod.GetParameters().Length + " arguments, got " + args.Count + ".", bShouldAppearInHistory: true);
			}
			else
			{
				LogCommandError("We don't exactly know what went wrong with your command! Please check for mistakes and try again.", bShouldAppearInHistory: true);
			}
		}

		private void LogCommandError(string StringToLog, bool bShouldAppearInHistory)
		{
			Logger.LogError((object)StringToLog);
			if (bShouldAppearInHistory)
			{
				UpdateHistory(StringToLog, bIsOutput: true);
			}
		}

		private void LogCommandOutput(string StringToLog, bool bShouldAppearInHistory)
		{
			Logger.LogInfo((object)StringToLog);
			if (bShouldAppearInHistory)
			{
				UpdateHistory(StringToLog, bIsOutput: true);
			}
		}

		public void give(string item, string amount)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			List<ResourceInfo> resources = GameDefines.instance.resources;
			if (!int.TryParse(amount, out var result))
			{
				LogCommandError("The amount you provided, '" + amount + "', doesn't seem to be a number! Are you sure you typed it correctly?", bShouldAppearInHistory: true);
				return;
			}
			ResourceInfo val = new ResourceInfo();
			for (int i = 0; i < resources.Count; i++)
			{
				if (item.ToLower() == resources[i].displayName.ToLower().Replace(" ", ""))
				{
					((InventoryWrapper)Player.instance.inventory).AddResources(resources[i], result);
					val = resources[i];
					break;
				}
				if (i == resources.Count - 1)
				{
					LogCommandError("The item ('" + item + "') you provided doesn't seem to be correct! Try another name.", bShouldAppearInHistory: true);
					return;
				}
			}
			LogCommandOutput(amount + " of " + val.displayName + " has been given to player.", bShouldAppearInHistory: true);
		}

		public void echo(string logstring, string logtype)
		{
			switch (logtype.ToLower())
			{
			case "info":
				Logger.LogInfo((object)logstring);
				break;
			case "warning":
				Logger.LogWarning((object)logstring);
				break;
			case "error":
				Logger.LogError((object)logstring);
				break;
			case "fatal":
				Logger.LogFatal((object)logstring);
				break;
			case "message":
				Logger.LogMessage((object)logstring);
				break;
			default:
				LogCommandError("Unrecognized log type! Choose from: info, warning, error, fatal, or message", bShouldAppearInHistory: true);
				break;
			}
			LogCommandOutput("Logged '" + logstring + "'.", bShouldAppearInHistory: true);
		}

		public string GetHistory()
		{
			string text = "";
			for (int i = 0; i < OutputHistory.Count + InputHistory.Count; i++)
			{
				if (i % 2 == 1)
				{
					text = text + "\n" + OutputHistory[i / 2];
				}
				else if (i % 2 == 0)
				{
					text = text + "\n" + InputHistory[i / 2];
				}
			}
			return text;
		}

		public void setplayerparams(string paramtype, string value)
		{
			if (!float.TryParse(value, out var result))
			{
				LogCommandError("Unrecognized value '" + value + "'! Are you sure you typed it correctly?", bShouldAppearInHistory: true);
				return;
			}
			switch (paramtype.ToLower())
			{
			case "maxrunspeed":
				PlayerFirstPersonController.instance.maxRunSpeed = result;
				break;
			case "maxwalkspeed":
				PlayerFirstPersonController.instance.maxWalkSpeed = result;
				break;
			case "maxflyspeed":
				PlayerFirstPersonController.instance.maxFlySpeed = result;
				break;
			case "jumpspeed":
				PlayerFirstPersonController.instance.jumpSpeed = result;
				break;
			case "scanspeed":
				bHasScanOverride = true;
				ScanOverrideMultiplier = 1f / result;
				break;
			case "gravity":
				PlayerFirstPersonController.instance.gravity = result;
				break;
			case "maxflyheight":
				Player.instance.equipment.hoverPack._stiltHeight = result;
				break;
			case "railrunnerspeed":
				Player.instance.equipment.railRunner._hookSpeed = result;
				break;
			default:
				LogCommandError("Unrecognized type '" + paramtype + "'! Are you sure you typed it correctly?\nPossible options are: maxrunspeed, maxwalkspeed, maxflyspeed, maxjumpvelocity, scanspeed, gravity, maxjumpheight", bShouldAppearInHistory: true);
				return;
			}
			LogCommandOutput("Player param '" + paramtype + "' set with value '" + value + "'. ", bShouldAppearInHistory: true);
		}

		public void weightless()
		{
			Player.instance.cheats.disableEncumbrance = !Player.instance.cheats.disableEncumbrance;
			if (Player.instance.cheats.disableEncumbrance)
			{
				LogCommandOutput("Enabled weightlessness.", bShouldAppearInHistory: true);
			}
			else
			{
				LogCommandOutput("Disabled weightlessness.", bShouldAppearInHistory: true);
			}
		}

		public void echolocation()
		{
			//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)
			Vector3 position = ((Component)PlayerFirstPersonController.instance).transform.position;
			echo(((object)(Vector3)(ref position)).ToString(), "info");
		}

		public void tp(string X, string Y, string Z)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			if ((float.TryParse(X, out var result) || X == "~") && (float.TryParse(Y, out var result2) || Y == "~") && (float.TryParse(Z, out var result3) || Z == "~"))
			{
				if (X == "~")
				{
					result = ((Component)PlayerFirstPersonController.instance).transform.position.x;
				}
				else if (Y == "~")
				{
					result2 = ((Component)PlayerFirstPersonController.instance).transform.position.y;
				}
				else if (Z == "~")
				{
					result3 = ((Component)PlayerFirstPersonController.instance).transform.position.z;
				}
				((Component)PlayerFirstPersonController.instance).transform.position = new Vector3(result, result2, result3);
				LogCommandOutput("Teleported player to " + X + ", " + Y + ", " + Z + ".", bShouldAppearInHistory: true);
			}
			else
			{
				LogCommandError("Your three vector components dont seem to be valid! ('" + X + "', '" + Y + "', '" + Z + "')", bShouldAppearInHistory: true);
			}
		}

		public void warp(string Location)
		{
			switch (Location.ToLower())
			{
			case "victor":
				tp("138,00", "12,30", "-116,00");
				break;
			case "lima":
				tp("85,00", "-2,84", "-330,00");
				break;
			case "xray":
				tp("-307,57", "92,95", "20,11");
				break;
			case "freight":
				tp("-153,08", "36,30", "188,50");
				break;
			case "waterfall":
				tp("-265,88", "-17,85", "-131,33");
				break;
			default:
				LogCommandError("Your warp, '" + Location + "', doesn't seem to exist! Check info.txt for all possible warps.", bShouldAppearInHistory: true);
				return;
			}
			LogCommandOutput("Teleported to " + Location + ".", bShouldAppearInHistory: true);
		}

		public void unlock(string name, string DrawPower)
		{
			if (!bool.TryParse(DrawPower, out var result))
			{
				LogCommandError("The bool you provided, '" + DrawPower + "', doesn't seem to be valid!", bShouldAppearInHistory: true);
				return;
			}
			if (name.ToLower() == "all")
			{
				UnlockAll(result);
			}
			List<Unlock> unlocks = GameDefines.instance.unlocks;
			for (int i = 0; i < unlocks.Count; i++)
			{
				if (LocsUtility.TranslateStringFromHash(unlocks[i].displayNameHash, (string)null) == null)
				{
					continue;
				}
				if (name.ToLower() == LocsUtility.TranslateStringFromHash(unlocks[i].displayNameHash, (string)null).ToLower().Replace(" ", ""))
				{
					ResearchTechNoReq(((UniqueIdScriptableObject)unlocks[i]).uniqueId, result);
					if (!result)
					{
						LogCommandOutput("Unlocked tech " + unlocks[i].displayName + " without drawing power.", bShouldAppearInHistory: true);
					}
					else
					{
						LogCommandOutput("Unlocked tech " + unlocks[i].displayName + ".", bShouldAppearInHistory: true);
					}
					break;
				}
				if (i == unlocks.Count - 1)
				{
					LogCommandError("The name ('" + name + "') you provided doesn't seem to be correct! Try another name.", bShouldAppearInHistory: true);
				}
			}
		}

		private void UnlockAll(bool DrawPower)
		{
			List<Unlock> unlocks = GameDefines.instance.unlocks;
			for (int i = 0; i < unlocks.Count; i++)
			{
				ResearchTechNoReq(((UniqueIdScriptableObject)unlocks[i]).uniqueId, DrawPower);
			}
			LogCommandOutput("Unlocked all tech!", bShouldAppearInHistory: true);
		}

		private void ResearchTechNoReq(int unlockId, bool b)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0020: Expected O, but got Unknown
			UnlockTechAction val = new UnlockTechAction
			{
				info = new UnlockTechInfo
				{
					unlockID = unlockId,
					drawPower = b
				}
			};
			NetworkMessageRelay.instance.SendNetworkAction((NetworkAction)(object)val);
		}

		public void opensesame()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			if (!GetClosestDoor(8f, out var id, out var rgi))
			{
				LogCommandError("You're not looking at a door!", bShouldAppearInHistory: true);
				return;
			}
			DoorToOpen = rgi;
			AddRequiredResources(rgi);
			OpenDoor(id, rgi);
			((ResourceGateInstance)(ref rgi)).ProcessUpgrade();
			rgi.interactionState = 2;
			LogCommandOutput("Opened door " + rgi.myConfig.displayName + ".", bShouldAppearInHistory: true);
		}

		private bool GetClosestDoor(float MaxDist, out uint id, out ResourceGateInstance rgi)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			MachineInstanceList<ResourceGateInstance, ResourceGateDefinition> machineList = MachineManager.instance.GetMachineList<ResourceGateInstance, ResourceGateDefinition>((MachineTypeEnum)28);
			float num = float.MaxValue;
			ResourceGateInstance val = machineList.myArray[0];
			ResourceGateInstance[] myArray = machineList.myArray;
			for (int i = 0; i < myArray.Length; i++)
			{
				ResourceGateInstance val2 = myArray[i];
				GridInfo gridInfo = val2.gridInfo;
				Vector3 center = ((GridInfo)(ref gridInfo)).Center;
				float num2 = FHG_Utils.Distance(center, ((Component)Player.instance.cam).transform.position);
				if (num2 < num)
				{
					Logger.LogInfo((object)$" Found closer door {((GenericMachineInstanceRef)(ref val2.gridInfo.myRef)).instanceId} is {num2} away.");
					num = num2;
					val = val2;
				}
				else
				{
					Logger.LogInfo((object)$" Found further door {((GenericMachineInstanceRef)(ref val2.gridInfo.myRef)).instanceId} is {num2} away.");
				}
			}
			rgi = val;
			id = ((GenericMachineInstanceRef)(ref val.gridInfo.myRef)).instanceId;
			if (num > MaxDist)
			{
				return false;
			}
			return true;
		}

		private void OpenDoor(uint id, ResourceGateInstance rgi)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_003c: Expected O, but got Unknown
			if (((ResourceGateInstance)(ref rgi)).CheckForRequiredResources())
			{
				CompleteResourceGateAction val = new CompleteResourceGateAction
				{
					info = new CompleteResourceGateInfo
					{
						machineId = ((GenericMachineInstanceRef)(ref rgi.gridInfo.myRef)).instanceId,
						unlockLevel = 1
					}
				};
				NetworkMessageRelay.instance.SendNetworkAction((NetworkAction)(object)val);
				((FMODAudioSource)(ref Player.instance.audio.productionTerminalTierUpgrade)).PlayRandomClip(true);
			}
			else
			{
				((FMODAudioSource)(ref Player.instance.audio.error)).PlayRandomClip(true);
			}
		}

		private void AddRequiredResources(ResourceGateInstance rgi)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			int num = default(int);
			for (int i = 0; i < rgi.resourcesRequired.Length; i++)
			{
				((Inventory)(ref ((ResourceGateInstance)(ref rgi)).GetInputInventory())).AddResourcesToSlot(((UniqueIdScriptableObject)rgi.resourcesRequired[i].resType).uniqueId, i, ref num, rgi.resourcesRequired[i].quantity, true);
			}
		}

		public void instamole()
		{
			bShouldInstaMine = !bShouldInstaMine;
			if (bShouldInstaMine)
			{
				LogCommandOutput("Enabled instamine.", bShouldAppearInHistory: true);
			}
			else
			{
				LogCommandOutput("Disabled instamine.", bShouldAppearInHistory: true);
			}
		}

		public void gamespeed(string value)
		{
			if (!float.TryParse(value, out var result))
			{
				LogCommandError("The float parameter you provided, '" + value + "', doesn't seem to be valid!", bShouldAppearInHistory: true);
				return;
			}
			Player.instance.cheats.simSpeed = result;
			LogCommandOutput("Correctly set game simulation speed to " + value + "!", bShouldAppearInHistory: true);
		}

		public void cammode(string value)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			if (!ParseCamMode(value, out var fcm))
			{
				LogCommandError("The camera mode you inputted, '" + value + "', doesn't seem to be valid!", bShouldAppearInHistory: true);
				return;
			}
			Player.instance.cheats.freeCameraMode = fcm;
			LogCommandOutput("New camera mode set: " + value + ".", bShouldAppearInHistory: true);
		}

		public bool ParseCamMode(string value, out FreeCameraMode fcm)
		{
			switch (value.ToLower())
			{
			case "normal":
				fcm = (FreeCameraMode)0;
				return true;
			case "free":
				fcm = (FreeCameraMode)1;
				return true;
			case "scriptedanimation":
				fcm = (FreeCameraMode)2;
				return true;
			default:
				fcm = (FreeCameraMode)0;
				return false;
			}
		}

		public void fillaccumulators()
		{
			bShouldFillAccumulators = true;
		}

		public void camtp()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if ((int)Player.instance.cheats.freeCameraMode == 1)
			{
				((Component)Player.instance).transform.position = ((Component)Player.instance.cam).transform.position;
				LogCommandOutput("Succesfully teleported to the freecam position!", bShouldAppearInHistory: true);
			}
			else
			{
				LogCommandError("You're not in free camera mode!", bShouldAppearInHistory: true);
			}
		}

		public void noclip()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (!bIsNoclipping)
			{
				Player.instance.cheats.freeCameraMode = (FreeCameraMode)1;
				bIsNoclipping = true;
				LogCommandOutput("Noclip has been enabled!", bShouldAppearInHistory: true);
			}
			else
			{
				Player.instance.cheats.freeCameraMode = (FreeCameraMode)0;
				bIsNoclipping = false;
				LogCommandOutput("Noclip has been disabled!", bShouldAppearInHistory: true);
			}
		}

		public void bind(string key, string command)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			if (Enum.IsDefined(typeof(KeyCode), key))
			{
				CommandKeyBindData item = default(CommandKeyBindData);
				List<string> list = null;
				KeyCode keybind = (KeyCode)Enum.Parse(typeof(KeyCode), key);
				string text;
				if (command.Contains("{") || command.Contains("}"))
				{
					text = command.Substring(0, command.IndexOf('{'));
					list = command.Substring(command.IndexOf('{'), command.IndexOf('}') - command.IndexOf('{')).Replace(",", " ").Replace("}", "")
						.Replace("{", "")
						.Split(" ")
						.ToList();
					Debug.Log((object)list[0]);
				}
				else
				{
					text = command;
				}
				if (((object)this).GetType().GetMethod(text) == null)
				{
					LogCommandError("The command you inputted, " + text + ", doesn't exist!", bShouldAppearInHistory: true);
				}
				else if (Bindings.Find((CommandKeyBindData BindingData) => BindingData.key == keybind).command == null)
				{
					item.key = keybind;
					item.command = ((object)this).GetType().GetMethod(text.ToLower());
					if (command.Contains("{") || command.Contains("}"))
					{
						item.args = list;
					}
					Bindings.Add(item);
					LogCommandOutput("Bound " + key + " to '" + command + "'!", bShouldAppearInHistory: true);
				}
				else
				{
					LogCommandError("This key has already been bound to another command! Use 'unbind' to unbind keys!", bShouldAppearInHistory: true);
				}
			}
			else
			{
				LogCommandError("The key you provided, '" + key + "', isn't valid!", bShouldAppearInHistory: true);
			}
		}

		public void unbind(string key)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			if (!Enum.IsDefined(typeof(KeyCode), key))
			{
				LogCommandError("The key you provided, '" + key + "', isn't valid!", bShouldAppearInHistory: true);
				return;
			}
			KeyCode keybind = (KeyCode)Enum.Parse(typeof(KeyCode), key);
			if (Bindings.Find((CommandKeyBindData BindingData) => BindingData.key == keybind).command != null)
			{
				Bindings.Remove(Bindings.Find((CommandKeyBindData BindingData) => BindingData.key == keybind));
				LogCommandOutput("Key '" + ((object)(KeyCode)(ref keybind)).ToString() + "' has been unbound!", bShouldAppearInHistory: true);
			}
			else
			{
				LogCommandError("That key isn't bound to anything!", bShouldAppearInHistory: true);
			}
		}

		public void setsize(string value, string bSyncParams)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			if (!float.TryParse(value, out var result))
			{
				LogCommandError("The float you provided isn't valid!", bShouldAppearInHistory: true);
				return;
			}
			if (result <= 0f)
			{
				LogCommandError("To prevent game-breaking bugs, scales below 0 are not accepted.", bShouldAppearInHistory: true);
				return;
			}
			if (!bool.TryParse(bSyncParams, out var result2))
			{
				LogCommandError("The bool you provided isn't valid!", bShouldAppearInHistory: true);
				return;
			}
			((Component)Player.instance).transform.localScale = new Vector3(result, result, result);
			((Component)Player.instance.cam).transform.localScale = new Vector3(result, result, result);
			if (result2)
			{
				ScalePlayerParamsToNewSize(result);
			}
			LogCommandOutput("Set scale to " + result + "!", bShouldAppearInHistory: true);
		}

		private void ScalePlayerParamsToNewSize(float newsize)
		{
			PlayerFirstPersonController.instance.maxWalkSpeed = 5f * newsize;
			PlayerFirstPersonController.instance.maxRunSpeed = 8f * newsize;
			PlayerFirstPersonController.instance.peakMinHeight = 1f * newsize;
			PlayerFirstPersonController.instance.peakMaxHeight = 2f * newsize;
			PlayerFirstPersonController.instance.inAirDuration = 2f * newsize;
			PlayerFirstPersonController.instance.gravity = 20f * newsize;
			PlayerFirstPersonController.instance.maxFallSpeed = -15f * newsize;
			Player.instance.equipment.hoverPack._stiltHeight = 3f * newsize;
			Player.instance.equipment.hoverPack._raiseSpeed = 5f * newsize;
		}

		public void clear(string item, string amount)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ResourceInfo val = new ResourceInfo();
			for (int i = 0; i < GameDefines.instance.resources.Count; i++)
			{
				if (GameDefines.instance.resources[i].displayName.Replace(" ", "").ToLower() == item.ToLower())
				{
					val = GameDefines.instance.resources[i];
					break;
				}
				if (i == GameDefines.instance.resources.Count - 1)
				{
					LogCommandError("The item you provided doesn't seem to exist!", bShouldAppearInHistory: true);
				}
			}
			if (int.TryParse(amount, out var result))
			{
				((InventoryWrapper)Player.instance.inventory).TryRemoveResources(val, result);
				LogCommandOutput("Removed " + result + " of " + val.displayName + " from player's inventory.", bShouldAppearInHistory: true);
			}
			else if (amount.ToLower() == "all")
			{
				((InventoryWrapper)Player.instance.inventory).TryRemoveResources(val, ((InventoryWrapper)Player.instance.inventory).GetResourceCount(((UniqueIdScriptableObject)val).uniqueId, false));
				LogCommandOutput("Removed all of " + val.displayName + " from player's inventory.", bShouldAppearInHistory: true);
			}
			else
			{
				LogCommandError("The amount you provided doesn't seem to be valid!", bShouldAppearInHistory: true);
			}
		}

		public void setmoledimensions(string valuex, string valuey, string valuez)
		{
			if (int.TryParse(valuex, out var result) && int.TryParse(valuey, out var result2) && int.TryParse(valuez, out var result3))
			{
				TerrainManipulator val = Player.instance.equipment.GetAllEquipment<TerrainManipulator>()[0];
				((Vector3Int)(ref ((TerrainManipulatorMode)val.tunnelMode)._currentDimensions)).x = result;
				((Vector3Int)(ref ((TerrainManipulatorMode)val.tunnelMode)._currentDimensions)).y = result2;
				((Vector3Int)(ref ((TerrainManipulatorMode)val.tunnelMode)._currentDimensions)).z = result3;
				((Vector3Int)(ref ((TerrainManipulatorMode)val.flattenMode)._currentDimensions)).x = result;
				((Vector3Int)(ref ((TerrainManipulatorMode)val.flattenMode)._currentDimensions)).y = result2;
				((Vector3Int)(ref ((TerrainManipulatorMode)val.flattenMode)._currentDimensions)).z = result3;
				LogCommandOutput("Set dimension to " + result + ", " + result2 + ", " + result3 + "!", bShouldAppearInHistory: true);
			}
			else
			{
				LogCommandError("The integer you provided does not seem to be valid!", bShouldAppearInHistory: true);
			}
		}
	}
	internal class InstaMolePatch
	{
		[HarmonyPatch(typeof(TerrainManipulator), "OnUpdate")]
		[HarmonyPostfix]
		public static void Postfix(ref TerrainManipulator __instance)
		{
			if (ConsoleCommands.bShouldInstaMine)
			{
				__instance.currentManipulatorMode.basePerVoxelActionDuration = 0.0001f;
				__instance._isOverheated = false;
				__instance.currentSlowDownSpeed = 2f;
			}
		}
	}
	internal class OpenSesamePatch
	{
		[HarmonyPatch(typeof(ResourceGateInstance), "CheckForRequiredResources")]
		[HarmonyPrefix]
		public static void setDoorToFree(ref ResourceGateInstance __instance)
		{
			Debug.Log((object)"Are youuuuu the one im looking foooor? :musical_notes:");
			if (__instance.commonInfo.instanceId != ConsoleCommands.DoorToOpen.commonInfo.instanceId)
			{
				Debug.Log((object)"I'm noooot the door you're looking fooooor");
				return;
			}
			for (int i = 0; i < __instance.resourcesRequired.Length; i++)
			{
				__instance.resourcesRequired[i].quantity = 0;
			}
		}
	}
	[HarmonyPatch]
	public class ScannerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(Scanner), "Scan")]
		private static void ScanPatch(ref InstanceLookup lookup, ref ScannableData scanData, ref bool isScanning)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			if (scanData.IsAlreadyScanned(lookup) || !isScanning)
			{
				return;
			}
			PropState val = default(PropState);
			PropManager.instance.GetPropState(ref lookup, ref val);
			if (ConsoleCommands.bHasScanOverride)
			{
				float num = scanData.GetScanDuration() * ConsoleCommands.ScanOverrideMultiplier;
				if (PropManager.instance.UpdatePropScanProgress(ref lookup, (val.scanProgress * num + Time.deltaTime) / num))
				{
					scanData.CompleteScan(lookup);
				}
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "console_commands";

		public const string PLUGIN_NAME = "Techtonica Console Commands";

		public const string PLUGIN_VERSION = "0.0.1";
	}
}