Please disclose if your mod was created primarily 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 Asocial Cartography v0.3.0
Plugins/VentureValheim.AsocialCartography.dll
Decompiled 3 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Splatform; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("VentureValheim.AsocialCartography")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("VentureValheim.AsocialCartography")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("697DC3A2-C8D7-4AED-9A2D-013509E7B1C9")] [assembly: AssemblyFileVersion("0.3.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.3.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace VentureValheim.AsocialCartography { [BepInPlugin("com.orianaventure.mod.AsocialCartography", "AsocialCartography", "0.3.0")] public class AsocialCartographyPlugin : BaseUnityPlugin { private const string ModName = "AsocialCartography"; private const string ModVersion = "0.3.0"; private const string Author = "com.orianaventure.mod"; private const string ModGUID = "com.orianaventure.mod.AsocialCartography"; private static string ConfigFileName = "com.orianaventure.mod.AsocialCartography.cfg"; private static string ConfigFileFullPath; private readonly Harmony HarmonyInstance = new Harmony("com.orianaventure.mod.AsocialCartography"); public static readonly ManualLogSource AsocialCartographyLogger; private static ConfigEntry<bool> CE_AddPins; private static ConfigEntry<bool> CE_ReceivePins; private static ConfigEntry<bool> CE_IgnoreBossPins; private static ConfigEntry<bool> CE_IgnoreHildirPins; private static ConfigEntry<float> CE_ReceivePinRadius; public static bool GetAddPins() { return CE_AddPins.Value; } public static bool GetIgnoreBossPins() { return CE_IgnoreBossPins.Value; } public static bool GetIgnoreHildirPins() { return CE_IgnoreHildirPins.Value; } public static bool GetReceivePins() { return CE_ReceivePins.Value; } public static float GetReceivePinRadius() { return CE_ReceivePinRadius.Value; } private void AddConfig<T>(string key, string section, string description, bool synced, T value, ref ConfigEntry<T> configEntry) { string extendedDescription = GetExtendedDescription(description, synced); configEntry = ((BaseUnityPlugin)this).Config.Bind<T>(section, key, value, extendedDescription); } public string GetExtendedDescription(string description, bool synchronizedSetting) { return description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"); } public void Awake() { AddConfig("AddPins", "General", "False to disable adding player-placed map pins when adding to a map table (boolean).", synced: false, value: false, ref CE_AddPins); AddConfig("ReceivePins", "General", "False to disable taking player-placed map pins when reading a map table (boolean).", synced: false, value: true, ref CE_ReceivePins); AddConfig("IgnoreBossPins", "General", "False to include boss map pins in the above configs (boolean).", synced: false, value: true, ref CE_IgnoreBossPins); AddConfig("IgnoreHildirPins", "General", "False to include hildir map pins in the above configs (boolean).", synced: false, value: true, ref CE_IgnoreHildirPins); AddConfig("ReceivePinRadius", "General", "Overlap radius that must be exceeded to receive a pin from the map table. Default in vanilla is 1 (float).", synced: false, 50f, ref CE_ReceivePinRadius); Assembly executingAssembly = Assembly.GetExecutingAssembly(); HarmonyInstance.PatchAll(executingAssembly); SetupWatcher(); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } private void SetupWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { if (!File.Exists(ConfigFileFullPath)) { return; } try { AsocialCartographyLogger.LogDebug((object)"Attempting to reload configuration..."); ((BaseUnityPlugin)this).Config.Reload(); } catch { AsocialCartographyLogger.LogError((object)("There was an issue loading " + ConfigFileName)); } } static AsocialCartographyPlugin() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName; AsocialCartographyLogger = Logger.CreateLogSource("AsocialCartography"); CE_AddPins = null; CE_ReceivePins = null; CE_IgnoreBossPins = null; CE_IgnoreHildirPins = null; CE_ReceivePinRadius = null; } } public class AsocialCartography { [HarmonyPatch(typeof(Minimap), "GetSharedMapData")] public static class Patch_Minimap_GetSharedMapData { private static void Prefix(Minimap __instance, byte[] oldMapData, out List<PinData> __state) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) __state = __instance.m_pins.ToList(); if (AsocialCartographyPlugin.GetAddPins()) { return; } __instance.m_pins = new List<PinData>(); for (int i = 0; i < __state.Count; i++) { if (AllowedPin(__state[i].m_type)) { __instance.m_pins.Add(__state[i]); } } } private static void Postfix(Minimap __instance, List<PinData> __state) { if (__state != null) { __instance.m_pins = __state; } } } [HarmonyPatch(typeof(Minimap), "AddSharedMapData")] public static class Patch_Minimap_AddSharedMapData { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: 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_0026: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown List<Label> labels; return new CodeMatcher(instructions, generator).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Minimap), "HavePinInRange", (Type[])null, (Type[])null), (string)null) }).ThrowIfInvalid("Could not patch Minimap.AddSharedMapData! (HavePinInRange not found)") .SetInstruction(Transpilers.EmitDelegate<Func<float>>((Func<float>)AsocialCartographyPlugin.GetReceivePinRadius)) .MatchStartForward((CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Minimap), "GetClosestPin", (Type[])null, (Type[])null), (string)null) }) .ThrowIfInvalid("Could not patch Minimap.AddSharedMapData! (GetClosestPin not found)") .SetInstruction(Transpilers.EmitDelegate<Func<float>>((Func<float>)AsocialCartographyPlugin.GetReceivePinRadius)) .MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Minimap), "AddPin", (Type[])null, (Type[])null), (string)null) }) .ThrowIfInvalid("Could not patch Minimap.AddSharedMapData! (AddPin not found)") .ExtractLabels(out labels) .SetInstruction(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(AsocialCartography), "AddPinReplacement", (Type[])null, (Type[])null))) .AddLabels((IEnumerable<Label>)labels) .InstructionEnumeration(); } } private static bool AllowedPin(PinType pin) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 if ((int)pin == 0 || (int)pin == 1 || (int)pin == 2 || (int)pin == 3 || (int)pin == 6) { return false; } if (!AsocialCartographyPlugin.GetIgnoreBossPins() && (int)pin == 9) { return false; } if (!AsocialCartographyPlugin.GetIgnoreHildirPins() && ((int)pin == 14 || (int)pin == 15 || (int)pin == 16)) { return false; } return true; } public PinData AddPinReplacement(Vector3 pos, PinType type, string name, bool save, bool isChecked, long ownerID, PlatformUserID author) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown if (AsocialCartographyPlugin.GetReceivePins() || AllowedPin(type)) { return Minimap.instance.AddPin(pos, type, name, save, isChecked, ownerID, author); } return new PinData(); } } public static class CodeMatcherExtensions { public static CodeMatcher ExtractLabels(this CodeMatcher matcher, out List<Label> labels) { Label[] array = new Label[matcher.Labels.Count]; matcher.Labels.CopyTo(array); matcher.Labels.Clear(); labels = array.ToList(); return matcher; } } }