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 AdminNoDiscovery v1.0.4
AdminNoDiscovery.dll
Decompiled 2 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [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 AdminNoDiscovery { [BepInPlugin("captain.AdminNoDiscovery", "Admin No Discovery", "1.0.4")] public class Plugin : BaseUnityPlugin { public static Plugin Instance { get; private set; } public static ManualLogSource Log { get; private set; } private void Awake() { Instance = this; Log = ((BaseUnityPlugin)this).Logger; Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); Commands.Register(); ((MonoBehaviour)this).InvokeRepeating("Tick", 3f, 2f); } private void Tick() { DebugReport.Tick(); RevealTracker.Tick(); } public void ResendIcons() { if ((Object)(object)ZoneSystem.instance != (Object)null && (Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { ZoneSystem.instance.SendLocationIcons(0L); } } } internal static class Commands { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__1_0; internal void <Register>b__1_0(ConsoleEventArgs args) { if ((Object)(object)ZNet.instance == (Object)null || (Object)(object)ZoneSystem.instance == (Object)null) { args.Context.AddString("[AdminNoDiscovery] 월드에 접속한 상태에서만 실행할 수 있습니다"); } else if (ZNet.instance.IsServer()) { int num = RevealTracker.ResetAll(); args.Context.AddString("[AdminNoDiscovery] 공개 기록 " + num + "개 초기화"); } else if (ZRoutedRpc.instance == null || ZNet.instance.GetServerPeer() == null) { args.Context.AddString("[AdminNoDiscovery] 서버에 연결되어 있지 않습니다"); } else { ZRoutedRpc.instance.InvokeRoutedRPC("AND_Reset", new object[0]); Plugin.Log.LogInfo((object)"[RESET] 서버로 요청 전송"); args.Context.AddString("[AdminNoDiscovery] 서버에 초기화를 요청했습니다 (관리자만 처리됨)"); } } } public const string ResetRpc = "AND_Reset"; public static void Register() { //IL_0034: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown object obj = <>c.<>9__1_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { if ((Object)(object)ZNet.instance == (Object)null || (Object)(object)ZoneSystem.instance == (Object)null) { args.Context.AddString("[AdminNoDiscovery] 월드에 접속한 상태에서만 실행할 수 있습니다"); } else if (ZNet.instance.IsServer()) { int num = RevealTracker.ResetAll(); args.Context.AddString("[AdminNoDiscovery] 공개 기록 " + num + "개 초기화"); } else if (ZRoutedRpc.instance == null || ZNet.instance.GetServerPeer() == null) { args.Context.AddString("[AdminNoDiscovery] 서버에 연결되어 있지 않습니다"); } else { ZRoutedRpc.instance.InvokeRoutedRPC("AND_Reset", new object[0]); Plugin.Log.LogInfo((object)"[RESET] 서버로 요청 전송"); args.Context.AddString("[AdminNoDiscovery] 서버에 초기화를 요청했습니다 (관리자만 처리됨)"); } }; <>c.<>9__1_0 = val; obj = (object)val; } new ConsoleCommand("andreset", "AdminNoDiscovery: reset revealed vendor/forge map pins (admin only)", (ConsoleEvent)obj, true, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } public static void RegisterRpc() { ZRoutedRpc.instance.Register("AND_Reset", (Action<long>)OnResetRequest); } private static void OnResetRequest(long sender) { Plugin.Log.LogInfo((object)("[RESET] 요청 수신 sender=" + sender)); if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer()) { ZNetPeer peer = ZNet.instance.GetPeer(sender); if (peer == null || peer.m_socket == null) { Plugin.Log.LogWarning((object)("[RESET] 피어를 찾지 못해 무시: sender=" + sender)); return; } if (!ZNet.instance.IsAdmin(peer.m_socket.GetHostName())) { Plugin.Log.LogWarning((object)("[RESET] 관리자가 아닌 요청 무시: " + peer.m_playerName)); return; } int num = RevealTracker.ResetAll(); Plugin.Log.LogInfo((object)("[RESET] " + peer.m_playerName + " 요청으로 공개 기록 " + num + "개 초기화")); } } } internal static class DebugReport { public const string RpcName = "AND_DebugState"; private static readonly Dictionary<long, bool> ByPeer = new Dictionary<long, bool>(); private static bool? _lastSent; private static ZRoutedRpc _lastRpc; public static void Register() { ZRoutedRpc.instance.Register<bool>("AND_DebugState", (Action<long, bool>)OnReport); _lastSent = null; } private static void OnReport(long sender, bool debugOn) { if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { ByPeer[sender] = debugOn; } } public static bool IsDebugging(long peerUid) { bool value; return !ByPeer.TryGetValue(peerUid, out value) || value; } public static void Tick() { if ((Object)(object)ZNet.instance == (Object)null || ZRoutedRpc.instance == null) { return; } if (ZNet.instance.IsServer()) { Prune(); } else if (ZNet.instance.GetServerPeer() != null) { bool debugMode = Player.m_debugMode; if (_lastSent != debugMode || _lastRpc != ZRoutedRpc.instance) { ZRoutedRpc.instance.InvokeRoutedRPC("AND_DebugState", new object[1] { debugMode }); _lastSent = debugMode; _lastRpc = ZRoutedRpc.instance; } } } private static void Prune() { if (ByPeer.Count == 0) { return; } HashSet<long> hashSet = new HashSet<long>(); foreach (ZNetPeer connectedPeer in ZNet.instance.GetConnectedPeers()) { hashSet.Add(connectedPeer.m_uid); } List<long> list = null; foreach (long key in ByPeer.Keys) { if (!hashSet.Contains(key)) { if (list == null) { list = new List<long>(); } list.Add(key); } } if (list == null) { return; } foreach (long item in list) { ByPeer.Remove(item); } } } [HarmonyPatch(typeof(ZoneSystem), "GetLocationIcons")] internal static class ZoneSystem_GetLocationIcons_Patch { private static readonly Dictionary<string, string> candidateState = new Dictionary<string, string>(); private static string lastSummary = null; private static void Postfix(ZoneSystem __instance, Dictionary<Vector3, string> icons) { //IL_0048: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } Dictionary<string, int> dictionary = new Dictionary<string, int>(); int count = icons.Count; foreach (LocationInstance location in __instance.GetLocationList()) { if (Targets.IsTarget(location)) { LogCandidate(location); if (location.m_placed && !RevealTracker.IsRevealed(location.m_position)) { icons.Remove(location.m_position); string key = location.m_location.m_prefab.Name + "/" + location.m_location.m_group; dictionary.TryGetValue(key, out var value); dictionary[key] = value + 1; } } } LogRemoved(dictionary, count); } private static void LogCandidate(LocationInstance loc) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_009a: Unknown result type (might be due to invalid IL or missing references) string text = Targets.KeyFor(loc.m_position); string text2 = "placed=" + loc.m_placed + " revealed=" + RevealTracker.IsRevealed(loc.m_position); if (!candidateState.TryGetValue(text, out var value) || !(value == text2)) { candidateState[text] = text2; Plugin.Log.LogInfo((object)("[ICONS] 대상 " + loc.m_location.m_prefab.Name + "/" + loc.m_location.m_group + " " + text + " " + text2)); } } private static void LogRemoved(Dictionary<string, int> removed, int total) { List<string> list = new List<string>(); foreach (KeyValuePair<string, int> item in removed) { list.Add(item.Key + "=" + item.Value); } list.Sort(); string text = string.Join(", ", list.ToArray()) + " (전송 전 총 " + total + "개)"; if (!(text == lastSummary)) { lastSummary = text; Plugin.Log.LogInfo((object)("[ICONS] 숨긴 핀: " + text)); } } } [HarmonyPatch(typeof(Game), "Start")] internal static class Game_Start_Patch { private static void Postfix() { DebugReport.Register(); Commands.RegisterRpc(); Plugin.Log.LogInfo((object)("[RPC] 등록 완료 server=" + ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()))); } } [HarmonyPatch(typeof(Trader), "DiscoverItems")] internal static class Trader_DiscoverItems_Patch { private static bool Prefix(Player player) { return !((Object)(object)player != (Object)null) || !((Object)(object)player == (Object)(object)Player.m_localPlayer) || !Player.m_debugMode; } } internal static class RevealTracker { private static readonly HashSet<string> Pending = new HashSet<string>(); public static bool IsRevealed(Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) string text = Targets.KeyFor(pos); return Pending.Contains(text) || ZoneSystem.instance.GetGlobalKey(text); } public unsafe static void Tick() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance == (Object)null || (Object)(object)ZoneSystem.instance == (Object)null || !ZNet.instance.IsServer()) { return; } List<Vector3> watcherPositions = GetWatcherPositions(); if (watcherPositions.Count == 0) { return; } bool flag = false; foreach (LocationInstance location in ZoneSystem.instance.GetLocationList()) { if (!location.m_placed || !Targets.IsTarget(location) || IsRevealed(location.m_position)) { continue; } foreach (Vector3 item in watcherPositions) { if (!InZoneLoadArea(item, location.m_position)) { continue; } string text = Targets.KeyFor(location.m_position); Pending.Add(text); ZoneSystem.instance.SetGlobalKey(text); ManualLogSource log = Plugin.Log; string[] obj = new string[8] { "[REVEAL] ", location.m_location.m_prefab.Name, " ", text, " group=", location.m_location.m_group, " watcher=", null }; Vector3 val = item; obj[7] = ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString(); log.LogInfo((object)string.Concat(obj)); flag = true; break; } } if (flag) { ZoneSystem.instance.SendLocationIcons(0L); } } private static bool InZoneLoadArea(Vector3 playerPos, Vector3 locPos) { //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) //IL_000d: 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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_004e: Unknown result type (might be due to invalid IL or missing references) ZoneSystem instance = ZoneSystem.instance; Vector2s zone = ZoneSystem.GetZone(playerPos); Vector2s zone2 = ZoneSystem.GetZone(locPos); int nearSimulationDistance = ((SimulationDistance)(ref instance.m_simulationDistance)).NearSimulationDistance; if (((SimulationDistance)(ref instance.m_simulationDistance)).IsClassic) { return Math.Abs(zone.x - zone2.x) <= nearSimulationDistance && Math.Abs(zone.y - zone2.y) <= nearSimulationDistance; } return instance.ZonesWithinRadius(zone, zone2, nearSimulationDistance, false); } private static List<Vector3> GetWatcherPositions() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(); foreach (ZNetPeer connectedPeer in ZNet.instance.GetConnectedPeers()) { if (connectedPeer.m_socket != null && (!ZNet.instance.IsAdmin(connectedPeer.m_socket.GetHostName()) || !DebugReport.IsDebugging(connectedPeer.m_uid))) { list.Add(connectedPeer.m_refPos); } } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && !Player.m_debugMode) { list.Add(((Component)localPlayer).transform.position); } return list; } public static int ResetAll() { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) int num = 0; foreach (string globalKey in ZoneSystem.instance.GetGlobalKeys()) { if (globalKey.StartsWith("andrev_")) { int num2 = globalKey.IndexOf(' '); string text = ((num2 > 0) ? globalKey.Substring(0, num2) : globalKey); ZoneSystem.instance.RemoveGlobalKey(text); num++; } } Pending.Clear(); foreach (LocationInstance location in ZoneSystem.instance.GetLocationList()) { if (Targets.IsTarget(location)) { Plugin.Log.LogInfo((object)("[RESET] 대상 " + location.m_location.m_prefab.Name + "/" + location.m_location.m_group + " " + Targets.KeyFor(location.m_position) + " placed=" + location.m_placed)); } } ((MonoBehaviour)Plugin.Instance).Invoke("ResendIcons", 0.5f); return num; } } internal static class Targets { public const string KeyPrefix = "andrev_"; private static readonly HashSet<string> Prefabs = new HashSet<string> { "Vendor_BlackForest", "Hildir_camp", "BogWitch_Camp" }; private const string ForgePrefab = "MountainCave02"; private const string ForgeGroup = "AncientUpgradeStation"; public static bool IsTarget(LocationInstance loc) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (loc.m_location != null) { _ = loc.m_location.m_prefab; if (0 == 0) { string name = loc.m_location.m_prefab.Name; if (Prefabs.Contains(name)) { return true; } return name == "MountainCave02" && loc.m_location.m_group == "AncientUpgradeStation"; } } return false; } public static string KeyFor(Vector3 pos) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) return "andrev_" + Mathf.RoundToInt(pos.x) + "_" + Mathf.RoundToInt(pos.z); } } }