using 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.4")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.4.0")]
namespace NoMapTools
{
[BepInPlugin("MidnightsFX.NoMapTools", "NoMapTools", "0.0.4")]
[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.4";
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
{
internal class TrackedParticle
{
public GameObject go { get; set; }
public Vector3 vel { get; set; }
}
[HarmonyPatch(typeof(Vegvisir))]
private static class Patch_Vegvisir_Interact
{
[HarmonyPatch("Interact")]
private static bool Prefix(Vegvisir __instance, Humanoid character, ref bool __result)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
Player val = (Player)character;
if ((Object)(object)((Component)val).GetComponent<NoMapLocationTracker>() == (Object)null)
{
LocationInstance val2 = default(LocationInstance);
ZoneSystem.instance.FindClosestLocation(__instance.m_locations.First().m_locationName, ((Component)val).transform.position, ref val2);
NoMapLocationTracker noMapLocationTracker = ((Component)val).gameObject.AddComponent<NoMapLocationTracker>();
Logger.LogDebug($"Tracking {__instance.m_locations.First().m_locationName} at {val2}");
noMapLocationTracker.Setup(ValConfig.VegvisirTrackerDuration.Value, val2.m_position);
((Character)val).Message((MessageType)2, "You are briefly tracking " + __instance.m_locations.First().m_pinName, 0, (Sprite)null);
}
__result = false;
return false;
}
}
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<int> VegvisirTrackerDuration;
public static ConfigEntry<float> VegvisirTrackerSpeed;
public static ConfigEntry<float> VegvisirTrackerPingFrequency;
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);
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);
}
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);
}
}
}
}