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 NoMapTools v0.0.5
plugins/NoMapTools.dll
Decompiled 2 months agousing System; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using NoMapTools.common; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("NoMapTools")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("NoMapTools")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("0.0.5")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.5.0")] namespace NoMapTools { [BepInPlugin("MidnightsFX.NoMapTools", "NoMapTools", "0.0.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] internal class NoMapTools : BaseUnityPlugin { public const string PluginGUID = "MidnightsFX.NoMapTools"; public const string PluginName = "NoMapTools"; public const string PluginVersion = "0.0.5"; public static AssetBundle EmbeddedResourceBundle; public ValConfig cfg; public static ManualLogSource Log; public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization(); public void Awake() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; cfg = new ValConfig(((BaseUnityPlugin)this).Config); EmbeddedResourceBundle = AssetUtils.LoadAssetBundleFromResources("NoMapTools.assets.nomap", typeof(NoMapTools).Assembly); Assembly executingAssembly = Assembly.GetExecutingAssembly(); new Harmony("MidnightsFX.NoMapTools").PatchAll(executingAssembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Whats a map?"); } } } namespace NoMapTools.modules { internal static class CartographyTable { [HarmonyPatch(typeof(MapTable))] private static class CartographyTableRequiresLargerBase { private static readonly int pieceMask = LayerMask.GetMask(new string[1] { "piece" }); private static float update_timer = 0f; private static float current_update_time = 0f; private static int nearby_pieces = 0; [HarmonyPatch("GetReadHoverText")] [HarmonyPrefix] private static bool GetHoverReadText(MapTable __instance, ref string __result) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (!CheckPieceRequirement(((Component)__instance).gameObject.transform.position)) { __result = Localization.instance.Localize(__instance.m_name + $"\n[<color=yellow><b>$KEY_Use</b></color>] More nearby structures required ({nearby_pieces}/{ValConfig.CartographyTableRequiredPieces.Value})"); return false; } return true; } [HarmonyPatch("GetWriteHoverText")] [HarmonyPrefix] private static bool GetHoverWriteText(MapTable __instance, ref string __result) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (!CheckPieceRequirement(((Component)__instance).gameObject.transform.position)) { __result = Localization.instance.Localize(__instance.m_name + $"\n[<color=yellow><b>$KEY_Use</b></color>] More nearby structures required ({nearby_pieces}/{ValConfig.CartographyTableRequiredPieces.Value})"); return false; } return true; } [HarmonyPatch("OnRead", new Type[] { typeof(Switch), typeof(Humanoid), typeof(ItemData) })] [HarmonyPrefix] private static bool Onread(MapTable __instance, ref bool __result) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (!CheckPieceRequirement(((Component)__instance).gameObject.transform.position)) { __result = false; return false; } return true; } [HarmonyPatch("OnWrite", new Type[] { typeof(Switch), typeof(Humanoid), typeof(ItemData) })] [HarmonyPrefix] private static bool OnWrite(MapTable __instance, ref bool __result) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (!CheckPieceRequirement(((Component)__instance).gameObject.transform.position)) { __result = false; return false; } return true; } private static bool CheckPieceRequirement(Vector3 position) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) current_update_time += Time.fixedDeltaTime; if (update_timer <= current_update_time) { update_timer = current_update_time + 10f; nearby_pieces = Physics.OverlapSphere(position, ValConfig.CartographyTablePieceRequirementDistance.Value, pieceMask).Length; } return nearby_pieces > ValConfig.CartographyTableRequiredPieces.Value; } } } internal static class VegvisirFucntionality { [HarmonyPatch] private static class Patch_Vegvisir_Interact { private static float InteractTimer = 0f; private static string TargetLocation = ""; private static string DisplayName = ""; [HarmonyPrefix] [HarmonyPatch(typeof(Vegvisir), "Interact")] private static void VegInteract(Vegvisir __instance) { InteractTimer = Time.realtimeSinceStartup; TargetLocation = __instance.m_locations.First().m_locationName; DisplayName = __instance.m_locations.First().m_pinName; } [HarmonyPrefix] [HarmonyPatch(typeof(Minimap), "DiscoverLocation")] private static bool PrefixMapPin() { if (!ValConfig.VegvisirGivesMapIcon.Value && InteractTimer < Time.realtimeSinceStartup + ValConfig.VegvisirNetworkWaitDuration.Value) { return true; } return false; } [HarmonyPostfix] [HarmonyPatch(typeof(Game), "RPC_DiscoverLocationResponse")] private static void PrefixLocationTrack(Vector3 pos) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Player.m_localPlayer == (Object)null) && InteractTimer < Time.realtimeSinceStartup + ValConfig.VegvisirNetworkWaitDuration.Value && (Object)(object)((Component)Player.m_localPlayer).GetComponent<NoMapLocationTracker>() == (Object)null) { NoMapLocationTracker noMapLocationTracker = ((Component)Player.m_localPlayer).gameObject.AddComponent<NoMapLocationTracker>(); Logger.LogDebug($"Tracking {TargetLocation} at {pos}"); noMapLocationTracker.Setup(ValConfig.VegvisirTrackerDuration.Value, pos); ((Character)Player.m_localPlayer).Message((MessageType)2, "You are briefly tracking " + DisplayName, 0, (Sprite)null); } } } public class NoMapLocationTracker : MonoBehaviour { private float timeRemaining; private float nextParticleSpawnTimer; private Vector3 targetPosition = Vector3.zero; private bool setup; private GameObject sfxfinder; private GameObject vfxfinder; internal void LoadTrackingEffects() { sfxfinder = PrefabManager.Instance.GetPrefab("sfx_WishbonePing_far"); vfxfinder = NoMapTools.EmbeddedResourceBundle.LoadAsset<GameObject>("assets/assets/vfx_location_ping.prefab"); } public void Setup(int time, Vector3 targetlocation) { //IL_000b: 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_001a: 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_0025: Unknown result type (might be due to invalid IL or missing references) LoadTrackingEffects(); float groundHeight = ZoneSystem.instance.GetGroundHeight(targetlocation); targetPosition = new Vector3(targetlocation.x, groundHeight, targetlocation.z); timeRemaining = (float)time + Time.realtimeSinceStartup; setup = true; } public void Update() { //IL_001b: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) if (!setup) { return; } if (nextParticleSpawnTimer < Time.realtimeSinceStartup) { Vector3 val = default(Vector3); val.x = ((Component)Player.m_localPlayer).transform.position.x; val.z = ((Component)Player.m_localPlayer).transform.position.z; val.y = ((Component)Player.m_localPlayer).transform.position.y + 1f; Vector3 val2 = val; if ((Object)(object)sfxfinder != (Object)null) { Object.Instantiate<GameObject>(sfxfinder, val2, Quaternion.identity); } GameObject val3 = Object.Instantiate<GameObject>(vfxfinder, val2, Quaternion.identity); val = targetPosition - val3.transform.position; Vector3 val4 = ((Vector3)(ref val)).normalized * ValConfig.VegvisirTrackerSpeed.Value; val3.GetComponent<Rigidbody>().AddForce(val4, (ForceMode)2); nextParticleSpawnTimer = Time.realtimeSinceStartup + 5f; } if (timeRemaining < Time.realtimeSinceStartup) { Object.Destroy((Object)(object)this); } } } } } namespace NoMapTools.common { internal class ValConfig { public static ConfigFile cfg; public static ConfigEntry<bool> EnableDebugMode; public static ConfigEntry<float> CartographyTablePieceRequirementDistance; public static ConfigEntry<int> CartographyTableRequiredPieces; public static ConfigEntry<bool> VegvisirGivesMapIcon; public static ConfigEntry<int> VegvisirTrackerDuration; public static ConfigEntry<float> VegvisirTrackerSpeed; public static ConfigEntry<float> VegvisirTrackerPingFrequency; public static ConfigEntry<float> VegvisirNetworkWaitDuration; public ValConfig(ConfigFile cf) { cfg = cf; cfg.SaveOnConfigSet = true; CreateConfigValues(cf); Logger.setDebugLogging(EnableDebugMode.Value); SetupMainFileWatcher(); } private void CreateConfigValues(ConfigFile Config) { //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_002c: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown EnableDebugMode = Config.Bind<bool>("Client config", "EnableDebugMode", false, new ConfigDescription("Enables Debug logging.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdvanced = true } })); EnableDebugMode.SettingChanged += Logger.enableDebugLogging; CartographyTablePieceRequirementDistance = BindServerConfig("CartographyTable", "CartographyTablePieceRequirementDistance", 100f, "The distance that the cartography table will check around itself for pieces.", advanced: false, 10f, 300f); CartographyTableRequiredPieces = BindServerConfig("CartographyTable", "CartographyTableRequiredPieces", 2000, "The number of pieces that a cartography table needs around it to activate", advanced: false, 0, 6000); VegvisirGivesMapIcon = BindServerConfig("Vegvisir", "VegvisirGivesMapIcon", value: false, "If enabled, interacting with a vegvisir will give its map location."); VegvisirTrackerDuration = BindServerConfig("Vegvisir", "VegvisirTrackerDuration", 120, "Duration in seconds of the status effect which tracks a boss location.", advanced: false, 10, 600); VegvisirTrackerSpeed = BindServerConfig("Vegvisir", "VegvisirTrackerSpeed", 10f, "Speed at which the tracker moves towards its target. To fast or too slow makes this hard for the player to follow.", advanced: true, 1f, 50f); VegvisirTrackerPingFrequency = BindServerConfig("Vegvisir", "VegvisirTrackerPingFrequency", 5f, "The frequency at which new pings are emitted tracking the destination", advanced: true, 1f, 60f); VegvisirNetworkWaitDuration = BindServerConfig("Vegvisir", "VegvisirNetworkWaitDuration", 30f, "How long to wait for the server to provide the target location.", advanced: true, 5f, 120f); } internal static void SetupMainFileWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(); fileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite; fileSystemWatcher.Path = Path.GetDirectoryName(cfg.ConfigFilePath); fileSystemWatcher.Filter = "MidnightsFX.NoMapTools.cfg"; fileSystemWatcher.Changed += OnConfigFileChanged; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private static void OnConfigFileChanged(object sender, FileSystemEventArgs e) { if (ZNet.instance.IsServer()) { Logger.LogInfo("Configuration file has been changed, reloading settings."); cfg.Reload(); } } public static ConfigEntry<float[]> BindServerConfig(string catagory, string key, float[] value, string description, bool advanced = false, float valmin = 0f, float valmax = 150f) { //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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown return cfg.Bind<float[]>(catagory, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(valmin, valmax), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry<bool> BindServerConfig(string catagory, string key, bool value, string description, AcceptableValueBase acceptableValues = null, bool advanced = false) { //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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown return cfg.Bind<bool>(catagory, key, value, new ConfigDescription(description, acceptableValues, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry<int> BindServerConfig(string catagory, string key, int value, string description, bool advanced = false, int valmin = 0, int valmax = 150) { //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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown return cfg.Bind<int>(catagory, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<int>(valmin, valmax), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry<float> BindServerConfig(string catagory, string key, float value, string description, bool advanced = false, float valmin = 0f, float valmax = 150f) { //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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown return cfg.Bind<float>(catagory, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(valmin, valmax), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } public static ConfigEntry<string> BindServerConfig(string catagory, string key, string value, string description, AcceptableValueList<string> acceptableValues = null, bool advanced = false) { //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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown return cfg.Bind<string>(catagory, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)acceptableValues, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, IsAdvanced = advanced } })); } } internal class Logger { public static LogLevel Level = (LogLevel)16; public static void enableDebugLogging(object sender, EventArgs e) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (ValConfig.EnableDebugMode.Value) { Level = (LogLevel)32; } else { Level = (LogLevel)16; } } public static void setDebugLogging(bool state) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (state) { Level = (LogLevel)32; } else { Level = (LogLevel)16; } } public static void LogDebug(string message) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)Level >= 32) { NoMapTools.Log.LogInfo((object)message); } } public static void LogInfo(string message) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)Level >= 16) { NoMapTools.Log.LogInfo((object)message); } } public static void LogWarning(string message) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)Level >= 4) { NoMapTools.Log.LogWarning((object)message); } } public static void LogError(string message) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)Level >= 2) { NoMapTools.Log.LogError((object)message); } } } }