using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
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.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LimitCartographyPins")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LimitCartographyPins")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4499087c-1bc3-4748-807e-1b520d880d3b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace LimitCartographyPins
{
[BepInPlugin("Weiler.LimitCartographyPins", "LimitCartographyPins", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
internal const string ModName = "LimitCartographyPins";
internal const string ModVersion = "1.1.0";
internal const string Author = "Weiler";
private const string ModGUID = "Weiler.LimitCartographyPins";
private readonly Harmony _harmony = new Harmony("Weiler.LimitCartographyPins");
public static readonly ManualLogSource ItemManagerModTemplateLogger = Logger.CreateLogSource("LimitCartographyPins");
public void Awake()
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
_harmony.PatchAll(executingAssembly);
}
}
}
namespace LimitCartographyPins.Properties
{
[CompilerGenerated]
[GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.3.0.0")]
internal sealed class Settings : ApplicationSettingsBase
{
private static Settings defaultInstance = (Settings)(object)SettingsBase.Synchronized((SettingsBase)(object)new Settings());
public static Settings Default => defaultInstance;
}
}
namespace LimitCartographyPins.Patches
{
[HarmonyPatch(typeof(MapTable))]
public class MapTable_Patches
{
private static bool allowRead = true;
[HarmonyPrefix]
[HarmonyPatch("OnWrite")]
private static void OnWrite_PrefixPatch()
{
allowRead = false;
}
[HarmonyPostfix]
[HarmonyPatch("OnWrite")]
private static void OnWrite_PostfixPatch()
{
allowRead = true;
}
[HarmonyPrefix]
[HarmonyPatch("OnRead", new Type[]
{
typeof(Switch),
typeof(Humanoid),
typeof(ItemData),
typeof(bool)
})]
private static bool OnRead_PrefixPatch()
{
return allowRead;
}
}
[HarmonyPatch(typeof(Minimap))]
internal class Minimap_Patches
{
[HarmonyPatch(typeof(Minimap))]
[HarmonyPatch("AddSharedMapData")]
public class AddSharedMapDataPatch
{
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Expected O, but got Unknown
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
for (int i = 0; i < list.Count; i++)
{
if (list[i].opcode == OpCodes.Stfld && list[i + 1].opcode == OpCodes.Br && list[i + 2].opcode == OpCodes.Ldloc_S && list[i + 3].opcode == OpCodes.Ldloc_S && list[i + 4].opcode == OpCodes.Beq)
{
list[i + 4] = new CodeInstruction(OpCodes.Pop, (object)null);
list.Insert(i + 5, new CodeInstruction(OpCodes.Pop, (object)null));
list.Insert(i + 6, new CodeInstruction(OpCodes.Nop, (object)null));
break;
}
}
return list;
}
}
private static bool allowRemovePin = true;
public static bool writePinDataOnce = false;
[HarmonyPrefix]
[HarmonyPatch("AddSharedMapData")]
private static void AddSharedMapData_PrefixPatch()
{
allowRemovePin = false;
}
[HarmonyPostfix]
[HarmonyPatch("AddSharedMapData")]
private static void AddSharedMapData_PostfixPatch(Minimap __instance)
{
allowRemovePin = true;
foreach (PinData pin in __instance.m_pins)
{
if (pin.m_shouldDelete)
{
pin.m_shouldDelete = false;
}
}
}
[HarmonyPrefix]
[HarmonyPatch("RemovePin", new Type[] { typeof(PinData) })]
private static bool RemovePin_PrefixPatch()
{
return allowRemovePin;
}
[HarmonyPrefix]
[HarmonyPatch("GetSharedMapData")]
private static bool GetSharedMapData_PrefixPatch(Minimap __instance, byte[] oldMapData, ref byte[] __result)
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Expected O, but got Unknown
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Expected O, but got Unknown
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Invalid comparison between Unknown and I4
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_036b: Unknown result type (might be due to invalid IL or missing references)
//IL_037a: Unknown result type (might be due to invalid IL or missing references)
//IL_0384: Expected I4, but got Unknown
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_024e: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
List<bool> list = new List<bool>();
ZPackage val = null;
int num = 0;
if (oldMapData != null)
{
val = new ZPackage(oldMapData);
num = val.ReadInt();
int num2 = val.ReadInt();
for (int i = 0; i < num2; i++)
{
list.Add(val.ReadBool());
}
}
ZPackage val2 = new ZPackage();
val2.Write(3);
val2.Write(__instance.m_explored.Length);
for (int j = 0; j < __instance.m_explored.Length; j++)
{
bool flag = __instance.m_explored[j] || __instance.m_exploredOthers[j];
if (list.Count > j)
{
flag |= list[j];
}
val2.Write(flag);
}
List<PinData> list2 = new List<PinData>();
if (val != null)
{
int num3 = val.ReadInt();
for (int k = 0; k < num3; k++)
{
PinData val3 = new PinData();
val3.m_ownerID = val.ReadLong();
val3.m_name = val.ReadString();
val3.m_pos = val.ReadVector3();
val3.m_type = (PinType)val.ReadInt();
val3.m_checked = val.ReadBool();
val3.m_author = ((num >= 3) ? val.ReadString() : "");
val3.m_save = true;
list2.Add(val3);
}
}
foreach (PinData pin in __instance.m_pins)
{
if (!pin.m_save || (int)pin.m_type == 4 || (IsPlayerPin(pin.m_type) && !writePinDataOnce))
{
continue;
}
bool flag2 = false;
if (IsPlayerPin(pin.m_type))
{
flag2 = true;
}
PinData val4 = null;
foreach (PinData item in list2)
{
if (item.m_save && Utils.DistanceXZ(pin.m_pos, item.m_pos) < 1f)
{
bool flag3 = false;
if (IsPlayerPin(item.m_type))
{
flag3 = true;
}
if ((flag2 && flag3) || pin.m_type == item.m_type)
{
val4 = item;
break;
}
}
}
if (val4 == null)
{
list2.Add(pin);
}
}
long playerID = Player.m_localPlayer.GetPlayerID();
string networkUserId = PrivilegeManager.GetNetworkUserId();
val2.Write(list2.Count);
foreach (PinData item2 in list2)
{
long num4 = ((item2.m_ownerID != 0L) ? item2.m_ownerID : playerID);
string text = ((string.IsNullOrEmpty(item2.m_author) && num4 == playerID) ? networkUserId : item2.m_author);
val2.Write(num4);
val2.Write(item2.m_name);
val2.Write(item2.m_pos);
val2.Write((int)item2.m_type);
val2.Write(item2.m_checked);
val2.Write(text);
}
writePinDataOnce = false;
__result = val2.GetArray();
return false;
}
public static bool IsPlayerPin(PinType pinType)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Invalid comparison between Unknown and I4
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Invalid comparison between Unknown and I4
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Invalid comparison between Unknown and I4
return (int)pinType == 0 || (int)pinType == 1 || (int)pinType == 2 || (int)pinType == 3 || (int)pinType == 6;
}
}
[HarmonyPatch(typeof(Terminal))]
internal class Terminal_Patches
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static ConsoleEvent <>9__0_0;
public static ConsoleEvent <>9__0_1;
public static ConsoleEvent <>9__0_2;
public static ConsoleEvent <>9__0_3;
internal void <InitTerminal_Patch>b__0_0(ConsoleEventArgs args)
{
RemoveMyPins(args.Context, args.Args);
}
internal void <InitTerminal_Patch>b__0_1(ConsoleEventArgs args)
{
RemoveOthersPins(args.Context, args.Args);
}
internal void <InitTerminal_Patch>b__0_2(ConsoleEventArgs args)
{
RemoveAllPins(args.Context, args.Args);
}
internal void <InitTerminal_Patch>b__0_3(ConsoleEventArgs args)
{
WritePinData(args.Context, args.Args);
}
}
[HarmonyPostfix]
[HarmonyPatch("InitTerminal")]
private static void InitTerminal_Patch()
{
//IL_0033: 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
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
//IL_00a3: 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)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Expected O, but got Unknown
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Expected O, but got Unknown
object obj = <>c.<>9__0_0;
if (obj == null)
{
ConsoleEvent val = delegate(ConsoleEventArgs args)
{
RemoveMyPins(args.Context, args.Args);
};
<>c.<>9__0_0 = val;
obj = (object)val;
}
new ConsoleCommand("removemypins", "Removes all personal pins from map", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
object obj2 = <>c.<>9__0_1;
if (obj2 == null)
{
ConsoleEvent val2 = delegate(ConsoleEventArgs args)
{
RemoveOthersPins(args.Context, args.Args);
};
<>c.<>9__0_1 = val2;
obj2 = (object)val2;
}
new ConsoleCommand("removeotherspins", "Removes all pins from others from map", (ConsoleEvent)obj2, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
object obj3 = <>c.<>9__0_2;
if (obj3 == null)
{
ConsoleEvent val3 = delegate(ConsoleEventArgs args)
{
RemoveAllPins(args.Context, args.Args);
};
<>c.<>9__0_2 = val3;
obj3 = (object)val3;
}
new ConsoleCommand("removeallpins", "Removes allpins from map", (ConsoleEvent)obj3, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
object obj4 = <>c.<>9__0_3;
if (obj4 == null)
{
ConsoleEvent val4 = delegate(ConsoleEventArgs args)
{
WritePinData(args.Context, args.Args);
};
<>c.<>9__0_3 = val4;
obj4 = (object)val4;
}
new ConsoleCommand("writepindata", "writepindata", (ConsoleEvent)obj4, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
}
public static void RemoveMyPins(Terminal context, string[] args)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Player.m_localPlayer == (Object)null)
{
return;
}
List<PinData> list = new List<PinData>();
foreach (PinData pin in Minimap.m_instance.m_pins)
{
if (Minimap_Patches.IsPlayerPin(pin.m_type) && pin.m_ownerID == 0)
{
list.Add(pin);
}
}
int num = 0;
foreach (PinData item in list)
{
Minimap.m_instance.m_pins.Remove(item);
num++;
}
context.AddString($"{num} pins deleted");
}
public static void RemoveOthersPins(Terminal context, string[] args)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Player.m_localPlayer == (Object)null)
{
return;
}
List<PinData> list = new List<PinData>();
foreach (PinData pin in Minimap.m_instance.m_pins)
{
if (Minimap_Patches.IsPlayerPin(pin.m_type) && pin.m_ownerID != 0)
{
list.Add(pin);
}
}
int num = 0;
foreach (PinData item in list)
{
Minimap.m_instance.m_pins.Remove(item);
num++;
}
context.AddString($"{num} pins deleted");
}
public static void RemoveAllPins(Terminal context, string[] args)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Player.m_localPlayer == (Object)null)
{
return;
}
List<PinData> list = new List<PinData>();
foreach (PinData pin in Minimap.m_instance.m_pins)
{
if (Minimap_Patches.IsPlayerPin(pin.m_type))
{
list.Add(pin);
}
}
int num = 0;
foreach (PinData item in list)
{
Minimap.m_instance.m_pins.Remove(item);
num++;
}
context.AddString($"{num} pins deleted");
}
public static void WritePinData(Terminal context, string[] args)
{
if (!((Object)(object)Player.m_localPlayer == (Object)null))
{
Minimap_Patches.writePinDataOnce = true;
context.AddString("Pins will be written once on interact with cartography table");
}
}
}
}