Decompiled source of MoreCommands v1.0.0

moreCommands.dll

Decompiled 10 hours ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Photon.Pun;
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(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("moreCommands")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+8f41a9c25f0e8021aded727f76dc64312c882efa")]
[assembly: AssemblyProduct("moreCommands")]
[assembly: AssemblyTitle("moreCommands")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.yourdomain.moreCommands", "moreCommands", "1.0.5")]
public class Class1 : BaseUnityPlugin
{
	[HarmonyPatch(typeof(SteamManager), "Awake")]
	public class SteamManager_Awake_Postfix
	{
		private static void Postfix(SteamManager __instance)
		{
			AccessTools.Field(typeof(SteamManager), "developerMode").SetValue(__instance, true);
			Debug.Log((object)"DEVELOPER MODE: True");
		}
	}

	public static class HarmonyExtensions
	{
		[HarmonyPatch(typeof(SemiFunc), "Command")]
		public static class SemiFunc_Command_Patch
		{
			private static bool Prefix(string _command)
			{
				//IL_03af: Unknown result type (might be due to invalid IL or missing references)
				//IL_03be: Unknown result type (might be due to invalid IL or missing references)
				//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0485: Unknown result type (might be due to invalid IL or missing references)
				//IL_0487: Unknown result type (might be due to invalid IL or missing references)
				//IL_0465: Unknown result type (might be due to invalid IL or missing references)
				//IL_0467: Unknown result type (might be due to invalid IL or missing references)
				if (_command.ToLower().StartsWith("/sethealth"))
				{
					string[] array = _command.Split(new char[1] { ' ' });
					if (array.Length < 2)
					{
						Debug.Log((object)"Usage: /sethealth [value]");
						return false;
					}
					if (!int.TryParse(array[1], out var result))
					{
						Debug.Log((object)("Invalid health value: " + array[1]));
						return false;
					}
					PlayerAvatar instance = PlayerAvatar.instance;
					if ((Object)(object)instance == (Object)null)
					{
						Debug.Log((object)"Local player not found");
						return false;
					}
					PlayerHealth component = ((Component)instance).GetComponent<PlayerHealth>();
					if ((Object)(object)component == (Object)null)
					{
						Debug.Log((object)"PlayerHealth component not found on local player");
						return false;
					}
					AccessTools.Field(typeof(PlayerHealth), "health").SetValue(component, result);
					AccessTools.Field(typeof(PlayerHealth), "maxHealth").SetValue(component, result);
					StatsManager.instance.SetPlayerHealth(SemiFunc.PlayerGetSteamID(instance), result, false);
					Debug.Log((object)("Player health set to: " + result));
					return false;
				}
				if (_command.ToLower().StartsWith("/god"))
				{
					PlayerAvatar instance2 = PlayerAvatar.instance;
					if ((Object)(object)instance2 == (Object)null)
					{
						Debug.Log((object)"Local player not found");
						return false;
					}
					PlayerHealth component2 = ((Component)instance2).GetComponent<PlayerHealth>();
					if ((Object)(object)component2 == (Object)null)
					{
						Debug.Log((object)"PlayerHealth component not found on local player");
						return false;
					}
					string[] array2 = _command.Split(new char[1] { ' ' });
					bool flag;
					if (array2.Length >= 2)
					{
						if (array2[1].ToLower() == "on")
						{
							flag = true;
						}
						else
						{
							if (!(array2[1].ToLower() == "off"))
							{
								Debug.Log((object)"Usage: /god [on/off]");
								return false;
							}
							flag = false;
						}
					}
					else
					{
						FieldInfo fieldInfo = AccessTools.Field(typeof(PlayerHealth), "godMode");
						bool flag2 = (bool)fieldInfo.GetValue(component2);
						flag = !flag2;
					}
					AccessTools.Field(typeof(PlayerHealth), "godMode").SetValue(component2, flag);
					Debug.Log((object)("God mode set to: " + flag));
					return false;
				}
				if (_command.ToLower().StartsWith("/respawnall"))
				{
					if ((Object)(object)LevelGenerator.Instance == (Object)null)
					{
						Debug.Log((object)"LevelGenerator instance not found");
						return false;
					}
					foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
					{
						if ((bool)AccessTools.Field(typeof(PlayerAvatar), "deadSet").GetValue(player))
						{
							player.Revive(false);
						}
					}
					LevelGenerator.Instance.PlayerSpawn();
					Debug.Log((object)"All players respawned and revived");
					return false;
				}
				if (_command.ToLower().StartsWith("/money"))
				{
					if ((Object)(object)PlayerAvatar.instance == (Object)null)
					{
						Debug.Log((object)"PlayerAvatar instance not found");
						return false;
					}
					Vector3 val = ((Component)PlayerAvatar.instance).transform.position + ((Component)PlayerAvatar.instance).transform.forward * 1f;
					if ((Object)(object)ValuableDirector.instance == (Object)null)
					{
						Debug.Log((object)"ValuableDirector instance not found");
						return false;
					}
					FieldInfo fieldInfo2 = AccessTools.Field(typeof(ValuableDirector), "tinyValuables");
					List<GameObject> list = (List<GameObject>)fieldInfo2.GetValue(ValuableDirector.instance);
					if (list.Count == 0)
					{
						Debug.Log((object)"No tiny valuables available");
						return false;
					}
					GameObject val2 = list[0];
					if (GameManager.instance.gameMode == 0)
					{
						Object.Instantiate<GameObject>(val2, val, Quaternion.identity);
					}
					else
					{
						PhotonNetwork.InstantiateRoomObject("Valuables/01 Tiny/" + ((Object)val2).name, val, Quaternion.identity, (byte)0, (object[])null);
					}
					Debug.Log((object)"Money valuable spawned 1f away from player");
					return false;
				}
				if (_command.ToLower().StartsWith("/cameras"))
				{
					Camera[] source = Object.FindObjectsOfType<Camera>();
					string text = string.Join(", ", source.Select((Camera cam) => ((Object)((Component)cam).gameObject).name).ToArray());
					Debug.Log((object)("Cameras: " + text));
					return false;
				}
				return true;
			}
		}
	}

	private const string modGUID = "x002.moreCommands";

	private const string modName = "moreCommands";

	private const string modVersion = "1.0.5";

	public static Class1 instance;

	private readonly Harmony harmony = new Harmony("x002.moreCommands");

	private void Awake()
	{
		instance = this;
		harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"moreCommands is loaded!");
	}
}