using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Reflection;
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.0.4")]
public class Plugin : BaseUnityPlugin
{
internal const string ModName = "LimitCartographyPins";
internal const string ModVersion = "1.0.4";
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(Minimap))]
internal class Minimap_Patches
{
public static bool WritePinDataOnce = false;
private static List<PinData> pins = new List<PinData>();
[HarmonyPrefix]
[HarmonyPatch("GetSharedMapData")]
private static void GetSharedMapData_PrefixPatch(ref List<PinData> ___m_pins, byte[] oldMapData)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Invalid comparison between Unknown and I4
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Invalid comparison between Unknown and I4
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Invalid comparison between Unknown and I4
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Invalid comparison between Unknown and I4
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Invalid comparison between Unknown and I4
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Invalid comparison between Unknown and I4
//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
List<PinData> list = new List<PinData>();
if (oldMapData != null)
{
ZPackage val = new ZPackage(oldMapData);
int num = val.ReadInt();
List<bool> list2 = Minimap.instance.ReadExploredArray(val, num);
if (list2 == null)
{
}
if (num >= 2)
{
long playerID = Player.m_localPlayer.GetPlayerID();
int num2 = val.ReadInt();
for (int i = 0; i < num2; i++)
{
PinData val2 = new PinData();
long ownerID = val.ReadLong();
string name = val.ReadString();
Vector3 pos = val.ReadVector3();
PinType type = (PinType)val.ReadInt();
bool @checked = val.ReadBool();
string author = ((num >= 3) ? val.ReadString() : "");
val2.m_ownerID = ownerID;
val2.m_author = author;
val2.m_name = name;
val2.m_pos = pos;
val2.m_type = type;
val2.m_checked = @checked;
val2.m_save = true;
if (!HavePinInRange(list, val2.m_pos, 1f))
{
list.Add(val2);
}
}
}
}
pins.Clear();
foreach (PinData ___m_pin in ___m_pins)
{
pins.Add(___m_pin);
}
Debug.Log((object)$"WritePinDataOnce? {WritePinDataOnce}");
List<PinData> list3 = new List<PinData>();
foreach (PinData ___m_pin2 in ___m_pins)
{
if ((int)___m_pin2.m_type == 9 || (int)___m_pin2.m_type == 8)
{
list3.Add(___m_pin2);
}
if (WritePinDataOnce && ((int)___m_pin2.m_type == 0 || (int)___m_pin2.m_type == 1 || (int)___m_pin2.m_type == 2 || (int)___m_pin2.m_type == 3 || (int)___m_pin2.m_type == 6))
{
list3.Add(___m_pin2);
}
}
___m_pins.Clear();
foreach (PinData item in list)
{
if (!HavePinInRange(___m_pins, item.m_pos, 1f))
{
___m_pins.Add(item);
}
}
foreach (PinData item2 in list3)
{
if (!HavePinInRange(___m_pins, item2.m_pos, 1f))
{
___m_pins.Add(item2);
}
}
}
[HarmonyPostfix]
[HarmonyPatch("GetSharedMapData")]
private static void GetSharedMapData_PostfixPatch(ref List<PinData> ___m_pins)
{
___m_pins.Clear();
foreach (PinData pin in pins)
{
___m_pins.Add(pin);
}
pins.Clear();
if (WritePinDataOnce)
{
WritePinDataOnce = false;
}
}
private static bool HavePinInRange(List<PinData> referencePins, Vector3 pos, float radius)
{
//IL_001c: 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)
foreach (PinData referencePin in referencePins)
{
if (referencePin.m_save && Utils.DistanceXZ(pos, referencePin.m_pos) < radius)
{
return true;
}
}
return false;
}
}
[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_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Invalid comparison between Unknown and I4
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Invalid comparison between Unknown and I4
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Invalid comparison between Unknown and I4
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Invalid comparison between Unknown and I4
if ((Object)(object)Player.m_localPlayer == (Object)null)
{
return;
}
int count = Minimap.m_instance.m_pins.Count;
List<PinData> list = new List<PinData>();
foreach (PinData pin in Minimap.m_instance.m_pins)
{
if (((int)pin.m_type != 0 && (int)pin.m_type != 1 && (int)pin.m_type != 2 && (int)pin.m_type != 3 && (int)pin.m_type != 6) || pin.m_ownerID != 0)
{
list.Add(pin);
}
}
Minimap.m_instance.m_pins.Clear();
foreach (PinData item in list)
{
Minimap.m_instance.m_pins.Add(item);
}
count -= list.Count;
context.AddString($"{count} pins deleted");
}
public static void RemoveOthersPins(Terminal context, string[] args)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Invalid comparison between Unknown and I4
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Invalid comparison between Unknown and I4
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Invalid comparison between Unknown and I4
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Invalid comparison between Unknown and I4
if ((Object)(object)Player.m_localPlayer == (Object)null)
{
return;
}
int count = Minimap.m_instance.m_pins.Count;
List<PinData> list = new List<PinData>();
foreach (PinData pin in Minimap.m_instance.m_pins)
{
if (((int)pin.m_type != 0 && (int)pin.m_type != 1 && (int)pin.m_type != 2 && (int)pin.m_type != 3 && (int)pin.m_type != 6) || pin.m_ownerID == 0)
{
list.Add(pin);
}
}
Minimap.m_instance.m_pins.Clear();
foreach (PinData item in list)
{
Minimap.m_instance.m_pins.Add(item);
}
count -= list.Count;
context.AddString($"{count} pins deleted");
}
public static void RemoveAllPins(Terminal context, string[] args)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Invalid comparison between Unknown and I4
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Invalid comparison between Unknown and I4
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Invalid comparison between Unknown and I4
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Invalid comparison between Unknown and I4
if ((Object)(object)Player.m_localPlayer == (Object)null)
{
return;
}
int count = Minimap.m_instance.m_pins.Count;
List<PinData> list = new List<PinData>();
foreach (PinData pin in Minimap.m_instance.m_pins)
{
if ((int)pin.m_type != 0 && (int)pin.m_type != 1 && (int)pin.m_type != 2 && (int)pin.m_type != 3 && (int)pin.m_type != 6)
{
list.Add(pin);
}
}
Minimap.m_instance.m_pins.Clear();
foreach (PinData item in list)
{
Minimap.m_instance.m_pins.Add(item);
}
count -= list.Count;
context.AddString($"{count} 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");
}
}
}
}