Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of GeneralPurposeCommands v1.3.0
GeneralPurposeCommands.dll
Decompiled a year agousing System; using System.Collections; 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 GeneralPurposeCommands.Patches; using GeneralPurposeCommands.Utilities; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using TMPro; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("GeneralPurposeCommands")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: AssemblyInformationalVersion("1.3.0+cc2e155a3ebb5b9af24ff59d833a27515495997f")] [assembly: AssemblyProduct("General Purpose Commands")] [assembly: AssemblyTitle("GeneralPurposeCommands")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.0.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 GeneralPurposeCommands { [BepInPlugin("GeneralPurposeCommands", "General Purpose Commands", "1.3.0")] public class Plugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("GeneralPurposeCommands"); private static Plugin Instance; public static ManualLogSource Logger; public void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"General Purpose Commands is loaded!"); harmony.PatchAll(typeof(Plugin)); harmony.PatchAll(typeof(Commands)); harmony.PatchAll(typeof(MessageSystem)); harmony.PatchAll(typeof(ChatControl)); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "GeneralPurposeCommands"; public const string PLUGIN_NAME = "General Purpose Commands"; public const string PLUGIN_VERSION = "1.3.0"; } } namespace GeneralPurposeCommands.Utilities { public class Result<T> { public bool IsOk { get; set; } public T Value { get; set; } public string ErrorMessage { get; set; } public Result(T value) { IsOk = true; Value = value; } public Result(string errorMessage) { IsOk = false; ErrorMessage = errorMessage; } public static Result<T> Ok(T value) { return new Result<T>(value); } public static Result<T> Err(string errorMessage) { return new Result<T>(errorMessage); } public void Match(Action<Result<T>> Ok, Action<Result<T>> Err) { if (IsOk) { Ok(this); } else { Err(this); } } } } namespace GeneralPurposeCommands.Patches { [HarmonyPatch(typeof(ChatManager))] internal class ChatControl { public static InputAction Ctrl = new InputAction("Ctrl", (InputActionType)1, "<Keyboard>/ctrl", (string)null, (string)null, (string)null); public static InputAction V = new InputAction("V", (InputActionType)1, "<Keyboard>/v", (string)null, (string)null, (string)null); [HarmonyPatch("Awake")] [HarmonyPostfix] public static void Awake() { Ctrl.Enable(); V.Enable(); } [HarmonyPatch("StateActive")] [HarmonyPostfix] public static void StateActive() { //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (Ctrl.IsPressed() && V.WasPressedThisFrame()) { string text = (string)typeof(ChatManager).GetField("chatMessage", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(ChatManager.instance); typeof(ChatManager).GetField("chatMessage", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(ChatManager.instance, text + GUIUtility.systemCopyBuffer); ((TMP_Text)ChatManager.instance.chatText).text = text + GUIUtility.systemCopyBuffer; ((SemiUI)ChatUI.instance).SemiUITextFlashColor(Color.cyan, 0.2f); ((SemiUI)ChatUI.instance).SemiUISpringShakeY(2f, 5f, 0.2f); MenuManager.instance.MenuEffectClick((MenuClickEffectType)4, (MenuPage)null, 1f, 0.2f, true); } } } [HarmonyPatch(typeof(SemiFunc))] [HarmonyPatch("Command")] public class Commands : MonoBehaviour { [HarmonyPostfix] public static void Additional_Command(string _command) { string[] array = _command.Trim().Split(" "); string text = array[0].ToLower(); string[] args = ((array.Length >= 2) ? new Span<string>(array, 1, array.Length - 1).ToArray() : Array.Empty<string>()); Result<string> result2 = text switch { "addmoney" => AddMoney(args), "listitems" => ListItems(), "spawnitem" => SpawnItem(args), _ => Result<string>.Err("NO_COMMAND_CALLED"), }; try { result2.Match(delegate(Result<string> result) { MessageSystem.Instance.SendMessage(result.Value); }, delegate(Result<string> err) { if (!err.ErrorMessage.Equals("NO_COMMAND_CALLED")) { MessageSystem.Instance.SendMessage(err.ErrorMessage); } }); } catch (Exception ex) { Debug.LogError((object)ex); } } public static Result<string> AddMoney(string[] args) { if (args.Length == 0) { string text = "Amount is missing."; Plugin.Logger.LogError((object)text); return Result<string>.Err(text); } if (!int.TryParse(args[0], out var result)) { string text2 = "Amount must be an integer type number."; Plugin.Logger.LogError((object)text2); return Result<string>.Err(text2); } SemiFunc.StatSetRunCurrency(SemiFunc.StatGetRunCurrency() + result); string text3 = $"New Total: {SemiFunc.StatGetRunCurrency()}"; Plugin.Logger.LogInfo((object)text3); return Result<string>.Ok(text3); } private static Result<string> ListItems() { string text = "Items:\n"; foreach (Item value in StatsManager.instance.itemDictionary.Values) { text = text + value.itemName + "\n"; } text += "\nValuables:\n"; string[] array = new string[7] { "01 Tiny", "02 Small", "03 Medium", "04 Big", "05 Wide", "06 Tall", "07 Very Tall" }; GameObject[] array2; foreach (string text2 in array) { array2 = Resources.LoadAll<GameObject>("Valuables/" + text2); foreach (GameObject val in array2) { text = text + ((Object)val).name.Replace("Valuable ", string.Empty) + "\n"; } } text += "\nRemoved Items:\n"; array2 = Resources.LoadAll<GameObject>("Items/Removed Items"); foreach (GameObject val2 in array2) { text = text + ((Object)val2).name + "\n"; } Debug.Log((object)text); return Result<string>.Ok("Check Logs"); } private static Result<string> SpawnItem(string[] args) { //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: 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_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) int result = 1; string text = ""; if (args.Length != 0) { if (int.TryParse(args[^1], out result)) { text = args[..^1].Aggregate((string x, string y) => x + " " + y); } else { text = args.Aggregate((string x, string y) => x + " " + y); result = 1; } } if (string.IsNullOrEmpty(text)) { Debug.LogWarning((object)"Item name is empty!"); return Result<string>.Err("nuh uh"); } text = text.Trim(); Item val = null; foreach (Item value in StatsManager.instance.itemDictionary.Values) { if (string.Equals(value.itemAssetName, text, StringComparison.OrdinalIgnoreCase) || string.Equals(value.itemName.Trim(), text, StringComparison.OrdinalIgnoreCase)) { val = value; break; } } Transform transform = ((Component)Camera.main).transform; Vector3 val2 = transform.position + transform.forward * 2f; Quaternion identity = Quaternion.identity; if ((Object)(object)val != (Object)null) { if ((Object)(object)val.prefab == (Object)null) { Debug.LogWarning((object)("Item prefab is null for: " + text)); return Result<string>.Err("nuh uh"); } GameObject obj = Resources.Load<GameObject>("Valuables/" + ((Object)val.prefab).name); string text2 = (((Object)(object)obj != (Object)null) ? "Valuables/" : "Items/"); Debug.Log((object)(((Object)(object)obj != (Object)null) ? ("Found valuable prefab in Resources/Valuables. Using '" + text2 + "'.") : ("Valuable prefab not found in Resources/Valuables; using '" + text2 + "' folder."))); if (SemiFunc.IsMultiplayer()) { for (int i = 0; i < result; i++) { InstantiateRoomObject(text2 + ((Object)val.prefab).name, val2 + transform.up * (float)i * 0.2f, identity, 0); } } else { GameObject val3 = Resources.Load<GameObject>(text2 + ((Object)val.prefab).name); if ((Object)(object)val3 != (Object)null) { for (int j = 0; j < result; j++) { Object.Instantiate<GameObject>(val3, val2 + transform.up * (float)j * 0.2f, identity); } } else { Debug.LogWarning((object)("Prefab not found for singleplayer spawn: " + text2 + ((Object)val.prefab).name)); } } string itemName = val.itemName; Debug.Log((object)("Spawned item: " + itemName + " at " + ((object)(Vector3)(ref val2)).ToString())); return Result<string>.Ok("yippee"); } Debug.Log((object)"Item not found in StatsManager; searching Resources subfolders for a valuable prefab."); if ((Object)(object)TryLoadValuablePrefab(text, out var foundPath) != (Object)null) { if (SemiFunc.IsMultiplayer()) { for (int k = 0; k < result; k++) { InstantiateRoomObject(foundPath, val2 + transform.up * (float)k * 0.2f, identity, 0); } } else { GameObject val4 = Resources.Load<GameObject>(foundPath); if ((Object)(object)val4 != (Object)null) { for (int l = 0; l < result; l++) { Object.Instantiate<GameObject>(val4, val2 + transform.up * (float)l * 0.2f, identity); } } else { Debug.LogWarning((object)("Prefab not found for singleplayer spawn: " + foundPath)); } } Debug.Log((object)("Spawned valuable from path: " + foundPath + " at " + ((object)(Vector3)(ref val2)).ToString())); return Result<string>.Ok("yippee"); } Debug.LogWarning((object)("No item or valuable found with name: " + text)); return Result<string>.Err("nuh uh"); } private static GameObject TryLoadValuablePrefab(string searchName, out string foundPath) { foundPath = ""; string[] array = new string[7] { "01 Tiny", "02 Small", "03 Medium", "04 Big", "05 Wide", "06 Tall", "07 Very Tall" }; foreach (string text in array) { string text2 = "Valuables/" + text + "/"; GameObject[] array2 = Resources.LoadAll<GameObject>("Valuables/" + text); foreach (GameObject val in array2) { if (string.Equals(((Object)val).name.Replace("Valuable ", string.Empty), searchName, StringComparison.OrdinalIgnoreCase)) { foundPath = text2 + ((Object)val).name; return val; } } } string text3 = "Items/Removed Items/" + searchName; GameObject val2 = Resources.Load<GameObject>(text3); if ((Object)(object)val2 != (Object)null) { foundPath = text3; return val2; } return null; } public static GameObject InstantiateRoomObject(string prefabName, Vector3 position, Quaternion rotation, byte group = 0, object[] data = null) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown if (PhotonNetwork.CurrentRoom == null) { Debug.LogError((object)"Can not Instantiate before the client joined/created a room."); return null; } try { return (GameObject)GetMethod(typeof(PhotonNetwork), "NetworkInstantiate", typeof(InstantiateParameters)).Invoke(null, new object[3] { (object)new InstantiateParameters(prefabName, position, rotation, group, data, (byte)0, (int[])null, PhotonNetwork.LocalPlayer, PhotonNetwork.ServerTimestamp), true, false }); } catch (Exception ex) { Debug.LogError((object)ex); return null; } } public static MethodInfo GetMethod(Type type, string name, Type uniqueParamType) { return (from x in type.GetRuntimeMethods() where x.Name.Equals(name) select x into r let p = r.GetParameters() where p.Any((ParameterInfo o) => uniqueParamType.IsAssignableFrom(o.ParameterType)) select r).ToList()[0]; } } [HarmonyPatch(typeof(PlayerAvatar))] [HarmonyPatch("Awake")] internal class MessageSystem : MonoBehaviour { [CompilerGenerated] private sealed class <SendMessageCoroutine>d__3 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string message; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SendMessageCoroutine>d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(2f); <>1__state = 1; return true; case 1: <>1__state = -1; PlayerAvatar.instance.ChatMessageSend(message, false); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static MessageSystem Instance; [HarmonyPostfix] public static void Postfix() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Instance == (Object)null) { Instance = new GameObject("MessageSystem").AddComponent<MessageSystem>(); } else { Object.Destroy((Object)(object)((Component)Instance).gameObject); } } public void SendMessage(string message) { ((MonoBehaviour)this).StartCoroutine(SendMessageCoroutine(message)); } [IteratorStateMachine(typeof(<SendMessageCoroutine>d__3))] public static IEnumerator SendMessageCoroutine(string message) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SendMessageCoroutine>d__3(0) { message = message }; } } }