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 MarkerCommand v1.2.1
plugins/MarkerCommand.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using HarmonyLib; using Microsoft.CodeAnalysis; using Splatform; using UnityEngine; [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("MarkerCommand")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Console command for adding map markers at coordinates or your current position.")] [assembly: AssemblyFileVersion("1.2.1.0")] [assembly: AssemblyInformationalVersion("1.2.1+377a6b599957b42b0513f4c594197d22bcc306fd")] [assembly: AssemblyProduct("MarkerCommand")] [assembly: AssemblyTitle("MarkerCommand")] [assembly: AssemblyVersion("1.2.1.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 MarkerCommand { internal static class Hints { public const string ServerDevcommandsGuid = "server_devcommands"; public static bool Register() { Type type = AccessTools.TypeByName("ServerDevcommands.AutoComplete"); if (type == null) { return false; } MethodInfo methodInfo = AccessTools.Method(type, "Register", new Type[2] { typeof(string), typeof(Func<int, int, string[], List<string>>) }, (Type[])null); if (methodInfo != null) { Func<int, int, string[], List<string>> func = (int index, int subIndex, string[] args) => GetHint(index, args); methodInfo.Invoke(null, new object[2] { "marker", func }); return true; } MethodInfo methodInfo2 = AccessTools.Method(type, "Register", new Type[2] { typeof(string), typeof(Func<int, int, List<string>>) }, (Type[])null); if (methodInfo2 != null) { Func<int, int, List<string>> func2 = (int index, int subIndex) => GetHint(index, Array.Empty<string>()); methodInfo2.Invoke(null, new object[2] { "marker", func2 }); return true; } return false; } private static List<string> Hint(string text) { return new List<string> { "?" + text }; } private static List<string> GetHint(int index, string[] args) { bool flag = args.Length >= 1 && args[0].Equals("me", StringComparison.OrdinalIgnoreCase); int num = (flag ? 1 : 2); switch (index) { case 0: return Hint("X | world east-west coordinate, or <color=yellow>me</color> for your current position"); case 1: if (!flag) { return Hint("Z | world north-south coordinate"); } break; } if (index == num) { return Hint("Name | optional label, \"quote\" it if it has spaces (or skip straight to an icon)"); } return Marker.AvailableIcons.Select(Marker.IconName).ToList(); } } internal struct Token { public string Text; public bool Quoted; } internal static class Marker { public const string Command = "marker"; public const PinType DefaultIcon = (PinType)3; private static readonly Dictionary<PinType, string> Aliases = new Dictionary<PinType, string> { { (PinType)0, "fire" }, { (PinType)1, "house" }, { (PinType)2, "hammer" }, { (PinType)3, "dot" }, { (PinType)6, "rune" } }; public static IEnumerable<PinType> AllIcons => ((PinType[])Enum.GetValues(typeof(PinType))).Where((PinType t) => (int)t != 8); public static IEnumerable<PinType> AvailableIcons { get { if (!Object.op_Implicit((Object)(object)Minimap.instance)) { return AllIcons; } return AllIcons.Where(HasSprite); } } public static List<Token> Tokenize(string input) { List<Token> list = new List<Token>(); int num = 0; while (num < input.Length) { if (input[num] == ' ') { num++; } else if (input[num] == '"') { int num2 = input.IndexOf('"', num + 1); if (num2 < 0) { num2 = input.Length; } list.Add(new Token { Text = input.Substring(num + 1, num2 - num - 1), Quoted = true }); num = num2 + 1; } else { int num3 = input.IndexOf(' ', num); if (num3 < 0) { num3 = input.Length; } list.Add(new Token { Text = input.Substring(num, num3 - num), Quoted = false }); num = num3; } } return list; } public static bool IsMe(Token token) { if (!token.Quoted) { return token.Text.Equals("me", StringComparison.OrdinalIgnoreCase); } return false; } public static bool HasSprite(PinType type) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return Minimap.instance.m_icons.Any((SpriteData s) => s.m_name == type && (Object)(object)s.m_icon != (Object)null); } private unsafe static string EnumName(PinType type) { return ((object)(*(PinType*)(&type))/*cast due to .constrained prefix*/).ToString().ToLowerInvariant(); } public static string IconName(PinType type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!Aliases.TryGetValue(type, out var value)) { return EnumName(type); } return value; } public static bool TryParseIcon(Token token, out PinType icon) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected I4, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) icon = (PinType)3; if (token.Quoted) { return false; } string text = token.Text.ToLowerInvariant(); foreach (PinType allIcon in AllIcons) { if (IconName(allIcon) == text || EnumName(allIcon) == text) { icon = (PinType)(int)allIcon; return true; } } return false; } private static bool TryParseFloat(Token token, out float value) { return float.TryParse(token.Text, NumberStyles.Float, CultureInfo.InvariantCulture, out value); } public static void Run(ConsoleEventArgs args) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: 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_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Minimap.instance)) { Terminal context = args.Context; if (context != null) { context.AddString("Map is not available (join a world first)."); } return; } List<Token> list = Tokenize(args.ArgsAll ?? ""); Vector3 position = default(Vector3); int count; if (list.Count >= 1 && IsMe(list[0])) { if (!Object.op_Implicit((Object)(object)Player.m_localPlayer)) { Terminal context2 = args.Context; if (context2 != null) { context2.AddString("No local player."); } return; } position = ((Component)Player.m_localPlayer).transform.position; count = 1; } else { if (list.Count < 2 || !TryParseFloat(list[0], out var value) || !TryParseFloat(list[1], out var value2)) { Terminal context3 = args.Context; if (context3 != null) { context3.AddString("Usage: marker <x> <z> [name] [icon] or marker me [name] [icon]"); } return; } ((Vector3)(ref position))..ctor(value, 0f, value2); count = 2; } List<Token> list2 = list.Skip(count).ToList(); PinType icon = (PinType)3; if (list2.Count > 0 && TryParseIcon(list2[list2.Count - 1], out icon)) { list2.RemoveAt(list2.Count - 1); if (!HasSprite(icon)) { Terminal context4 = args.Context; if (context4 != null) { context4.AddString("Icon '" + IconName(icon) + "' has no sprite. Available: " + string.Join(", ", AvailableIcons.Select(IconName))); } return; } } string text = string.Join(" ", list2.Select((Token t) => t.Text)); Minimap.instance.AddPin(position, icon, text, true, false, 0L, default(PlatformUserID)); Terminal context5 = args.Context; if (context5 != null) { context5.AddString($"Added {IconName(icon)} marker '{text}' at ({position.x:F0}, {position.z:F0})"); } } } [BepInPlugin("s992.MarkerCommand", "MarkerCommand", "1.2.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private void Awake() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) new Harmony("s992.MarkerCommand").PatchAll(); if (Chainloader.PluginInfos.ContainsKey("server_devcommands")) { try { if (Hints.Register()) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Registered parameter hints with Server Devcommands"); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Server Devcommands has no compatible AutoComplete.Register; hints disabled"); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not register parameter hints: " + ex.Message)); } } ((BaseUnityPlugin)this).Logger.LogInfo((object)"MarkerCommand 1.2.1 loaded"); } } [HarmonyPatch(typeof(Terminal), "InitTerminal")] internal static class RegisterCommand { [CompilerGenerated] private static class <>O { public static ConsoleEvent <0>__Run; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleOptionsFetcher <>9__0_0; internal List<string> <Postfix>b__0_0() { return new List<string> { "me" }; } } private static void Postfix() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_004d: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown object obj = <>O.<0>__Run; if (obj == null) { ConsoleEvent val = Marker.Run; <>O.<0>__Run = val; obj = (object)val; } object obj2 = <>c.<>9__0_0; if (obj2 == null) { ConsoleOptionsFetcher val2 = () => new List<string> { "me" }; <>c.<>9__0_0 = val2; obj2 = (object)val2; } new ConsoleCommand("marker", "<x> <z> [name] [icon] | me [name] [icon] - adds a map marker at world coordinates or your position", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)obj2, false, false, false); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "s992.MarkerCommand"; public const string PLUGIN_NAME = "MarkerCommand"; public const string PLUGIN_VERSION = "1.2.1"; } }