Decompiled source of AutoPinezki v1.3.1

AutoPinezki.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Splatform;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AutoPinezki")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.3.1.0")]
[assembly: AssemblyInformationalVersion("1.3.1+3233ecd0f3995c9c10955d27f56380e6de789f02")]
[assembly: AssemblyProduct("AutoPinezki")]
[assembly: AssemblyTitle("AutoPinezki")]
[assembly: AssemblyVersion("1.3.1.0")]
[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 AutoPinezki
{
	public class Memory
	{
		private readonly List<(string key, float x, float z)> _marks = new List<(string, float, float)>();

		public int Count => _marks.Count;

		public bool IsNear(string key, float x, float z, float radius)
		{
			float num = radius * radius;
			foreach (var mark in _marks)
			{
				if (!(mark.key != key))
				{
					float num2 = mark.x - x;
					float num3 = mark.z - z;
					if (num2 * num2 + num3 * num3 < num)
					{
						return true;
					}
				}
			}
			return false;
		}

		public void Add(string key, float x, float z)
		{
			_marks.Add((key, x, z));
		}

		public static string Line(string key, float x, float z)
		{
			return key + ";" + x.ToString(CultureInfo.InvariantCulture) + ";" + z.ToString(CultureInfo.InvariantCulture);
		}

		public IEnumerable<string> ToLines()
		{
			return _marks.Select(((string key, float x, float z) m) => Line(m.key, m.x, m.z));
		}

		public static Memory FromLines(IEnumerable<string> lines)
		{
			Memory memory = new Memory();
			foreach (string line in lines)
			{
				string[] array = line.Split(';');
				if (array.Length == 3 && array[0].Length > 0 && float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2))
				{
					memory.Add(array[0], result, result2);
				}
			}
			return memory;
		}

		public List<KeyValuePair<string, int>> Stats()
		{
			return (from m in _marks
				group m by m.key into g
				select new KeyValuePair<string, int>(g.Key, g.Count()) into kv
				orderby kv.Value descending
				select kv).ToList();
		}
	}
	[BepInPlugin("bchn.autopinezki", "AutoPinezki", "1.3.1")]
	public class Plugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<KeyValuePair<string, Target>, KeyValuePair<Target, string>> <>9__30_0;

			public static Func<KeyValuePair<string, Target>, KeyValuePair<Target, string>> <>9__30_1;

			public static Func<KeyValuePair<Target, string>, Target> <>9__30_2;

			public static Func<KeyValuePair<Target, string>, string> <>9__30_3;

			public static Func<KeyValuePair<string, int>, string> <>9__32_1;

			public static ConsoleEvent <>9__32_0;

			public static Func<char, char> <>9__35_0;

			public static Predicate<KeyValuePair<ZNetView, Target>> <>9__36_0;

			public static Func<RaycastHit, float> <>9__38_0;

			internal KeyValuePair<Target, string> <Awake>b__30_0(KeyValuePair<string, Target> kv)
			{
				return new KeyValuePair<Target, string>(kv.Value, kv.Key);
			}

			internal KeyValuePair<Target, string> <Awake>b__30_1(KeyValuePair<string, Target> kv)
			{
				return new KeyValuePair<Target, string>(kv.Value, kv.Key + "*");
			}

			internal Target <Awake>b__30_2(KeyValuePair<Target, string> kv)
			{
				return kv.Key;
			}

			internal string <Awake>b__30_3(KeyValuePair<Target, string> kv)
			{
				return kv.Value;
			}

			internal void <OnInitTerminal>b__32_0(ConsoleEventArgs args)
			{
				if (I.mem == null)
				{
					args.Context.AddString("AutoPinezki: " + T("najpierw wejdź do świata.", "enter a world first."));
					return;
				}
				List<KeyValuePair<string, int>> list = I.mem.Stats();
				args.Context.AddString((list.Count == 0) ? ("AutoPinezki: " + T("jeszcze nic nie znalazłeś.", "nothing found yet.")) : ("AutoPinezki: " + string.Join(", ", list.Select((KeyValuePair<string, int> kv) => kv.Key + ": " + kv.Value))));
			}

			internal string <OnInitTerminal>b__32_1(KeyValuePair<string, int> kv)
			{
				return kv.Key + ": " + kv.Value;
			}

			internal char <Safe>b__35_0(char c)
			{
				if (!Path.GetInvalidFileNameChars().Contains(c))
				{
					return c;
				}
				return '_';
			}

			internal bool <Scan>b__36_0(KeyValuePair<ZNetView, Target> e)
			{
				return (Object)(object)e.Key == (Object)null;
			}

			internal float <MarkLookedAt>b__38_0(RaycastHit h)
			{
				return ((RaycastHit)(ref h)).distance;
			}
		}

		private static Plugin I;

		private ConfigEntry<float> Range;

		private ConfigEntry<float> GroupRadius;

		private ConfigEntry<bool> Messages;

		private ConfigEntry<bool> DebugLog;

		private ConfigEntry<bool> NotesOnF7;

		private ConfigEntry<float> NoteChance;

		private ConfigEntry<KeyCode> KeyToggle;

		private ConfigEntry<KeyCode> KeyMark;

		private readonly Dictionary<Cat, ConfigEntry<bool>> catEnabled = new Dictionary<Cat, ConfigEntry<bool>>();

		private readonly Dictionary<Target, ConfigEntry<bool>> targetEnabled = new Dictionary<Target, ConfigEntry<bool>>();

		private readonly Dictionary<Cat, ConfigEntry<PinType>> icons = new Dictionary<Cat, ConfigEntry<PinType>>();

		private static readonly List<KeyValuePair<ZNetView, Target>> Tracked = new List<KeyValuePair<ZNetView, Target>>();

		private static readonly FieldInfo LocationsField = AccessTools.Field(typeof(Location), "s_allLocations");

		private static readonly FieldInfo PinsField = AccessTools.Field(typeof(Minimap), "m_pins");

		private static readonly MethodInfo TakeInputMethod = AccessTools.Method(typeof(Player), "TakeInput", (Type[])null, (Type[])null);

		private Memory mem;

		private string memPath;

		private float nextTick;

		private bool auto = true;

		private readonly HashSet<string> debugSeen = new HashSet<string>();

		private readonly List<(ConfigurationManagerAttributes a, string secPl, string secEn, string namePl, string nameEn, string descPl, string descEn)> texts = new List<(ConfigurationManagerAttributes, string, string, string, string, string, string)>();

		private static readonly FieldInfo LocalizationInstance = AccessTools.Field(typeof(Localization), "m_instance");

		private static bool pl;

		private bool langKnown;

		private float nextLangCheck;

		private static readonly Dictionary<Cat, (string pl, string en)> CatNames = new Dictionary<Cat, (string, string)>
		{
			{
				Cat.Zbieractwo,
				("Zbieractwo", "Gathering")
			},
			{
				Cat.Rudy,
				("Rudy", "Ores")
			},
			{
				Cat.Lochy,
				("Lochy", "Dungeons")
			},
			{
				Cat.Inne,
				("Inne", "Other")
			}
		};

		private const string NoteSep = " - ";

		private ConfigEntry<T> Bind<T>(string secEn, string secPl, string key, string namePl, T value, string descEn, string descPl, AcceptableValueBase range = null)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes();
			texts.Add((configurationManagerAttributes, secPl, secEn, namePl, key, descPl, descEn));
			return ((BaseUnityPlugin)this).Config.Bind<T>(secEn, key, value, new ConfigDescription(descEn, range, new object[1] { configurationManagerAttributes }));
		}

		private void ApplyLanguage()
		{
			foreach (var text in texts)
			{
				text.a.Category = (pl ? text.secPl : text.secEn);
				text.a.DispName = (pl ? text.namePl : text.nameEn);
				text.a.Description = (pl ? text.descPl : text.descEn);
			}
		}

		private static string T(string polish, string english)
		{
			if (!pl)
			{
				return english;
			}
			return polish;
		}

		private void Awake()
		{
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			I = this;
			Range = Bind("General", "Ogólne", "Range", "Zasięg", 50f, "Detection range in meters.", "Zasięg wykrywania w metrach.");
			GroupRadius = Bind("General", "Ogólne", "Group radius", "Promień grupowania", 40f, "Don't place a second pin of the same kind closer than this (meters).", "Nie stawiaj drugiej pinezki tego samego typu bliżej niż tyle metrów.");
			Messages = Bind("General", "Ogólne", "Messages", "Komunikaty", value: true, "Show a message on screen when a pin is placed.", "Komunikat na ekranie przy nowej pinezce.");
			DebugLog = Bind("General", "Ogólne", "Debug", "Debug", value: false, "Log names of unknown nearby locations to BepInEx/LogOutput.log.", "Loguj nazwy nieznanych lokacji w zasięgu (BepInEx/LogOutput.log).");
			NoteChance = Bind("Notes", "Notatki", "Note chance", "Szansa notatki", 0.1f, "Chance (0-1) that an automatic pin gets a random note, e.g. \"miedz ruda - check later\".", "Szansa (0-1), że do automatycznej pinezki dojdzie losowa notatka, np. \"miedz ruda - check later\".", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f));
			NotesOnF7 = Bind("Notes", "Notatki", "Notes on mark key", "Notatki pod klawiszem oznacz", value: true, "Marking an unknown object places a random note instead of its in-game name.", "Oznaczenie obiektu spoza listy stawia losową notatkę zamiast nazwy z gry.");
			KeyToggle = Bind<KeyCode>("Keys", "Klawisze", "Toggle key", "Klawisz automatu", (KeyCode)289, "Turn automatic marking on/off.", "Włącz/wyłącz automatyczne oznaczanie.");
			KeyMark = Bind<KeyCode>("Keys", "Klawisze", "Mark key", "Klawisz oznacz", (KeyCode)288, "Mark the object you are aiming at (up to 100 m).", "Oznacz obiekt, w który celujesz (do 100 m).");
			foreach (KeyValuePair<Cat, PinType> item3 in new Dictionary<Cat, PinType>
			{
				{
					Cat.Zbieractwo,
					(PinType)3
				},
				{
					Cat.Rudy,
					(PinType)2
				},
				{
					Cat.Lochy,
					(PinType)6
				},
				{
					Cat.Inne,
					(PinType)0
				}
			})
			{
				var (namePl, key) = CatNames[item3.Key];
				catEnabled[item3.Key] = Bind("Categories", "Kategorie", key, namePl, value: true, "Mark this whole category.", "Oznaczaj całą kategorię.");
				icons[item3.Key] = Bind<PinType>("Icons", "Ikony", key, namePl, item3.Value, "Icon0=fire, Icon1=house, Icon2=hammer, Icon3=dot, Icon4=portal.", "Icon0=ognisko, Icon1=dom, Icon2=młotek, Icon3=kropka, Icon4=portal.");
			}
			foreach (IGrouping<Target, KeyValuePair<Target, string>> item4 in from kv in Targets.Prefabs.Select((KeyValuePair<string, Target> kv) => new KeyValuePair<Target, string>(kv.Value, kv.Key)).Concat(Targets.Locations.Select((KeyValuePair<string, Target> kv) => new KeyValuePair<Target, string>(kv.Value, kv.Key + "*")))
				group kv by kv.Key)
			{
				Target key2 = item4.Key;
				(string pl, string en) tuple2 = CatNames[key2.Cat];
				string item = tuple2.pl;
				string item2 = tuple2.en;
				string text = string.Join(", ", key2.Names);
				string text2 = string.Join(", ", item4.Select((KeyValuePair<Target, string> kv) => kv.Value));
				targetEnabled[key2] = Bind("Items: " + item2, "Rzeczy: " + item, key2.LabelEn, key2.Label, !key2.DefaultOff, "Pin names: " + text + ". Game objects: " + text2, "Na mapie np.: " + text + ". Obiekty w grze: " + text2);
			}
			ApplyLanguage();
			Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"AutoPinezki loaded");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ZNetView), "Awake")]
		private static void OnViewAwake(ZNetView __instance)
		{
			if (Targets.Prefabs.TryGetValue(Utils.GetPrefabName(((Component)__instance).gameObject), out var value))
			{
				Tracked.Add(new KeyValuePair<ZNetView, Target>(__instance, value));
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Terminal), "InitTerminal")]
		private static void OnInitTerminal()
		{
			//IL_0033: 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)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			object obj = <>c.<>9__32_0;
			if (obj == null)
			{
				ConsoleEvent val = delegate(ConsoleEventArgs args)
				{
					if (I.mem == null)
					{
						args.Context.AddString("AutoPinezki: " + T("najpierw wejdź do świata.", "enter a world first."));
					}
					else
					{
						List<KeyValuePair<string, int>> list = I.mem.Stats();
						args.Context.AddString((list.Count == 0) ? ("AutoPinezki: " + T("jeszcze nic nie znalazłeś.", "nothing found yet.")) : ("AutoPinezki: " + string.Join(", ", list.Select((KeyValuePair<string, int> kv) => kv.Key + ": " + kv.Value))));
					}
				};
				<>c.<>9__32_0 = val;
				obj = (object)val;
			}
			new ConsoleCommand("pinezki", "AutoPinezki stats", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
		}

		private void Update()
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			if (Time.unscaledTime >= nextLangCheck)
			{
				nextLangCheck = Time.unscaledTime + 2f;
				if (LocalizationInstance.GetValue(null) != null)
				{
					bool flag = Localization.instance.GetSelectedLanguage() == "Polish";
					if (!langKnown || flag != pl)
					{
						pl = flag;
						langKnown = true;
						ApplyLanguage();
					}
				}
			}
			Player localPlayer = Player.m_localPlayer;
			Minimap instance = Minimap.instance;
			if ((Object)(object)localPlayer == (Object)null || (Object)(object)instance == (Object)null || (Object)(object)ZNet.instance == (Object)null)
			{
				return;
			}
			EnsureMemory(localPlayer);
			if ((bool)TakeInputMethod.Invoke(localPlayer, null))
			{
				if (ZInput.GetKeyDown(KeyToggle.Value, true))
				{
					auto = !auto;
					Say(T("Automat pinezek: ", "Auto pins: ") + (auto ? T("WŁ", "ON") : T("WYŁ", "OFF")));
				}
				if (ZInput.GetKeyDown(KeyMark.Value, true))
				{
					MarkLookedAt(localPlayer, instance);
				}
			}
			if (!(Time.time < nextTick))
			{
				nextTick = Time.time + 2f;
				Scan(localPlayer, instance);
			}
		}

		private void EnsureMemory(Player player)
		{
			string text = Path.Combine(Paths.ConfigPath, "AutoPinezki");
			string text2 = Path.Combine(text, Safe(ZNet.instance.GetWorldName()) + "_" + Safe(player.GetPlayerName()) + ".txt");
			if (!(text2 == memPath))
			{
				Directory.CreateDirectory(text);
				memPath = text2;
				mem = (File.Exists(text2) ? Memory.FromLines(File.ReadAllLines(text2)) : new Memory());
				((BaseUnityPlugin)this).Logger.LogInfo((object)("AutoPinezki: pamięć " + text2 + " (" + mem.Count + " wpisów)"));
			}
		}

		private static string Safe(string s)
		{
			return new string((s ?? "").Select((char c) => (!Path.GetInvalidFileNameChars().Contains(c)) ? c : '_').ToArray());
		}

		private void Scan(Player player, Minimap map)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: 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_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)player).transform.position;
			float value = Range.Value;
			Dictionary<PinData, bool> dictionary = new Dictionary<PinData, bool>();
			Tracked.RemoveAll((KeyValuePair<ZNetView, Target> e) => (Object)(object)e.Key == (Object)null);
			foreach (KeyValuePair<ZNetView, Target> item in Tracked)
			{
				Vector3 position2 = ((Component)item.Key).transform.position;
				if (Utils.DistanceXZ(position2, position) > value)
				{
					continue;
				}
				Target value2 = item.Value;
				Pickable val = ((value2.Cat == Cat.Zbieractwo) ? ((Component)item.Key).GetComponent<Pickable>() : null);
				if ((Object)(object)val != (Object)null)
				{
					if (val.m_respawnTimeMinutes <= 0f)
					{
						continue;
					}
					PinData val2 = FindPin(map, value2, position2);
					if (val2 != null && targetEnabled[value2].Value)
					{
						dictionary.TryGetValue(val2, out var value3);
						dictionary[val2] = value3 || !val.GetPicked();
					}
				}
				if (auto)
				{
					TryMark(map, value2, position2);
				}
			}
			if (catEnabled[Cat.Zbieractwo].Value)
			{
				foreach (KeyValuePair<PinData, bool> item2 in dictionary)
				{
					item2.Key.m_checked = !item2.Value;
				}
			}
			if (!(LocationsField.GetValue(null) is List<Location> list))
			{
				return;
			}
			foreach (Location item3 in list)
			{
				if ((Object)(object)item3 == (Object)null)
				{
					continue;
				}
				Vector3 position3 = ((Component)item3).transform.position;
				if (Utils.DistanceXZ(position3, position) > value)
				{
					continue;
				}
				string prefabName = Utils.GetPrefabName(((Component)item3).gameObject);
				Target target = Targets.FindLocation(prefabName);
				if (target == null)
				{
					if (DebugLog.Value && debugSeen.Add(prefabName))
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)("AutoPinezki debug: nieznana lokacja " + prefabName));
					}
				}
				else if (auto)
				{
					TryMark(map, target, position3);
				}
			}
		}

		private void TryMark(Minimap map, Target t, Vector3 pos)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			if (!catEnabled[t.Cat].Value || !targetEnabled[t].Value || mem.IsNear(t.Key, pos.x, pos.z, GroupRadius.Value))
			{
				return;
			}
			Remember(t.Key, pos);
			if (FindPin(map, t, pos) == null)
			{
				string text = Pick(t.Names);
				if (Random.value < NoteChance.Value)
				{
					text = text + " - " + Pick(Targets.NotesFor(t));
				}
				AddPin(map, text, icons[t.Cat].Value, pos);
			}
		}

		private void MarkLookedAt(Player player, Minimap map)
		{
			//IL_0016: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			GameCamera instance = GameCamera.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			foreach (RaycastHit item in from h in Physics.RaycastAll(((Component)instance).transform.position, ((Component)instance).transform.forward, 100f, -1, (QueryTriggerInteraction)1)
				orderby ((RaycastHit)(ref h)).distance
				select h)
			{
				RaycastHit current = item;
				if ((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent<Player>() == (Object)(object)player)
				{
					continue;
				}
				ZNetView componentInParent = ((Component)((RaycastHit)(ref current)).collider).GetComponentInParent<ZNetView>();
				if ((Object)(object)componentInParent != (Object)null && Targets.Prefabs.TryGetValue(Utils.GetPrefabName(((Component)componentInParent).gameObject), out var value))
				{
					MarkManual(map, value.Key, value.Names, icons[value.Cat].Value, ((Component)componentInParent).transform.position);
					return;
				}
				Hoverable componentInParent2 = ((Component)((RaycastHit)(ref current)).collider).GetComponentInParent<Hoverable>();
				string text = ((componentInParent2 != null) ? Localization.instance.Localize(componentInParent2.GetHoverName()) : null);
				if (string.IsNullOrEmpty(text) && (Object)(object)componentInParent != (Object)null)
				{
					text = Utils.GetPrefabName(((Component)componentInParent).gameObject);
				}
				if (string.IsNullOrEmpty(text))
				{
					break;
				}
				Vector3 pos = (((Object)(object)componentInParent != (Object)null) ? ((Component)componentInParent).transform.position : ((RaycastHit)(ref current)).point);
				MarkManual(map, text, NotesOnF7.Value ? Targets.Notes : new string[1] { text }, (PinType)3, pos);
				return;
			}
			Say(T("Nic tu nie ma do oznaczenia", "Nothing here to mark"));
		}

		private void MarkManual(Minimap map, string key, string[] names, PinType icon, Vector3 pos)
		{
			//IL_0007: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_007a: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			if (mem.IsNear(key, pos.x, pos.z, 2f) && FindPin(map, names, pos) != null)
			{
				Say(T("Już oznaczone: ", "Already marked: ") + key);
				return;
			}
			if (!mem.IsNear(key, pos.x, pos.z, 2f))
			{
				Remember(key, pos);
			}
			AddPin(map, Pick(names), icon, pos);
		}

		private static string Pick(string[] arr)
		{
			return arr[Random.Range(0, arr.Length)];
		}

		private void AddPin(Minimap map, string name, PinType icon, Vector3 pos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			map.AddPin(pos, icon, name, true, false, 0L, default(PlatformUserID));
			if (Messages.Value)
			{
				Say(T("Znalazłeś: ", "Found: ") + name + "!");
			}
		}

		private void Remember(string key, Vector3 pos)
		{
			//IL_0007: 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_001f: 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)
			mem.Add(key, pos.x, pos.z);
			File.AppendAllText(memPath, Memory.Line(key, pos.x, pos.z) + "\n");
		}

		private PinData FindPin(Minimap map, Target t, Vector3 pos)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return FindPin(map, t.Names.Append(t.Key).ToArray(), pos);
		}

		private PinData FindPin(Minimap map, string[] names, Vector3 pos)
		{
			//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)
			List<PinData> source = (List<PinData>)PinsField.GetValue(map);
			float r = GroupRadius.Value;
			return ((IEnumerable<PinData>)source).FirstOrDefault((Func<PinData, bool>)((PinData p) => p.m_save && Utils.DistanceXZ(p.m_pos, pos) < r && names.Any((string n) => p.m_name == n || p.m_name.StartsWith(n + " - "))));
		}

		private static void Say(string text)
		{
			if ((Object)(object)MessageHud.instance != (Object)null)
			{
				MessageHud.instance.ShowMessage((MessageType)1, text, 0, (Sprite)null, false, true);
			}
		}
	}
	internal sealed class ConfigurationManagerAttributes
	{
		public string Category;

		public string DispName;

		public string Description;
	}
	public enum Cat
	{
		Zbieractwo,
		Rudy,
		Lochy,
		Inne
	}
	public class Target
	{
		public readonly string Key;

		public readonly string Label;

		public readonly string LabelEn;

		public readonly Cat Cat;

		public readonly string[] Names;

		public bool DefaultOff;

		public string[] Notes = new string[0];

		public Target(Cat cat, string key, string label, string labelEn, params string[] names)
		{
			Cat = cat;
			Key = key;
			Label = label;
			LabelEn = labelEn;
			Names = names;
		}
	}
	public static class Targets
	{
		public static readonly Dictionary<string, Target> Prefabs;

		public static readonly List<KeyValuePair<string, Target>> Locations;

		private static readonly string[] GenericNotes;

		private static readonly Dictionary<Cat, string[]> CatNotes;

		public static readonly string[] Notes;

		private static void P(Target t, params string[] prefabs)
		{
			foreach (string key in prefabs)
			{
				Prefabs[key] = t;
			}
		}

		private static void L(Target t, params string[] prefixes)
		{
			foreach (string key in prefixes)
			{
				Locations.Add(new KeyValuePair<string, Target>(key, t));
			}
		}

		public static string[] NotesFor(Target t)
		{
			return GenericNotes.Concat(CatNotes[t.Cat]).Concat(t.Notes).ToArray();
		}

		public static Target FindLocation(string name)
		{
			foreach (KeyValuePair<string, Target> location in Locations)
			{
				if (name.StartsWith(location.Key))
				{
					return location.Value;
				}
			}
			return null;
		}

		static Targets()
		{
			Prefabs = new Dictionary<string, Target>();
			Locations = new List<KeyValuePair<string, Target>>();
			GenericNotes = new string[10] { "go tu", "tu go", "come tutaj", "wracamy later", "back later", "return here", "check this", "check later", "todo", "wip" };
			CatNotes = new Dictionary<Cat, string[]>
			{
				{
					Cat.Zbieractwo,
					new string[2] { "free loot", "darmowy loot" }
				},
				{
					Cat.Rudy,
					new string[0]
				},
				{
					Cat.Lochy,
					new string[14]
					{
						"check cave", "loot tutaj", "loot tam", "need loot", "maybe loot", "todo explore", "todo loot", "bad idea", "zly pomysl", "dont go",
						"dont go tutaj", "nie isc", "fixme", "bug"
					}
				},
				{
					Cat.Inne,
					new string[3] { "unknown location", "todo explore", "maybe loot" }
				}
			};
			Notes = new string[41]
			{
				"go tu", "tu go", "come tutaj", "wracamy later", "back later", "return here", "check this", "check cave", "check later", "loot tutaj",
				"loot tam", "free loot", "darmowy loot", "need iron", "need silver", "need loot", "duzo iron", "duzo srebra", "big iron", "big silver",
				"bad idea", "zly pomysl", "dont go", "dont go tutaj", "nie isc", "maybe boss", "maybe loot", "probably silver", "probably iron", "unknown",
				"unknown location", "todo", "todo boss", "todo explore", "todo loot", "wip", "wip baza", "fixme", "fixme troll", "bug",
				"bug jaskinia"
			};
			P(new Target(Cat.Zbieractwo, "grzyp", "Grzyby", "Mushrooms", "grzyp")
			{
				DefaultOff = true
			}, "Pickable_Mushroom");
			P(new Target(Cat.Zbieractwo, "zułty grzyp", "Żółte grzyby", "Yellow mushrooms", "zułty grzyp")
			{
				DefaultOff = true
			}, "Pickable_Mushroom_yellow");
			P(new Target(Cat.Zbieractwo, "niebieski grzyp", "Niebieskie grzyby", "Blue mushrooms", "niebieski grzyp")
			{
				DefaultOff = true
			}, "Pickable_Mushroom_blue");
			P(new Target(Cat.Zbieractwo, "malinki", "Maliny", "Raspberries", "maliny"), "RaspberryBush");
			P(new Target(Cat.Zbieractwo, "boruwki", "Borówki", "Blueberries", "borowki"), "BlueberryBush");
			P(new Target(Cat.Zbieractwo, "morozki", "Moroszki", "Cloudberries", "morozki"), "CloudberryBush");
			P(new Target(Cat.Zbieractwo, "linkgoberki", "Borówki brusznice", "Lingonberries", "linkgoberki", "brusznica czy cos"), "LingonberryBush");
			P(new Target(Cat.Zbieractwo, "ostek", "Oset", "Thistle", "ostek"), "Pickable_Thistle");
			P(new Target(Cat.Zbieractwo, "marhewka", "Dzika marchew", "Carrot seeds", "marchewka"), "Pickable_SeedCarrot");
			P(new Target(Cat.Zbieractwo, "rzepka", "Dzika rzepa", "Turnip seeds", "rzepa"), "Pickable_SeedTurnip");
			P(new Target(Cat.Zbieractwo, "cebulka", "Dzika cebula", "Onion seeds", "cebulka"), "Pickable_SeedOnion", "OnionSeeds");
			P(new Target(Cat.Zbieractwo, "jarmusz", "Dziki jarmuż", "Kale seeds", "jarmuz"), "Pickable_SeedKale");
			P(new Target(Cat.Zbieractwo, "len dziki", "Dziki len", "Flax", "len"), "Pickable_Flax_Wild");
			P(new Target(Cat.Zbieractwo, "jenczmień", "Dziki jęczmień", "Barley", "jenczmien"), "Pickable_Barley_Wild");
			P(new Target(Cat.Zbieractwo, "jotun pafy", "Jotun Puffs", "Jotun Puffs", "jotun pafy", "pufy jotuna"), "Pickable_Mushroom_JotunPuffs");
			P(new Target(Cat.Zbieractwo, "magekapelusz", "Magecap", "Magecap", "magekapelusz", "czapka maga"), "Pickable_Mushroom_Magecap");
			P(new Target(Cat.Zbieractwo, "dymek", "Smoke Puff", "Smoke Puff", "dymek", "smołk pufek"), "Pickable_SmokePuff");
			P(new Target(Cat.Zbieractwo, "paprotka", "Paprocie (Fiddlehead)", "Fiddlehead", "paprotka"), "Pickable_Fiddlehead");
			P(new Target(Cat.Zbieractwo, "winogronka", "Vineberry", "Vineberries", "winogronka"), "VineAsh");
			P(new Target(Cat.Zbieractwo, "jajo sempa", "Jaja voltur", "Volture eggs", "jajo sempa", "jajko ptaszora"), "Pickable_VoltureEgg");
			P(new Target(Cat.Zbieractwo, "galaretka krulewska", "Royal Jelly", "Royal Jelly", "galaretka krolewska"), "Pickable_RoyalJelly");
			P(new Target(Cat.Zbieractwo, "jajo smoka", "Smocze jaja", "Dragon eggs", "jajo smoka"), "Pickable_DragonEgg");
			P(new Target(Cat.Zbieractwo, "ul dziki", "Dzikie ule", "Wild beehives", "ul"), "Beehive");
			P(new Target(Cat.Rudy, "copper", "Miedź", "Copper", "miedz", "miedz ruda", "copper miedz", "copper ruda"), "rock4_copper", "MineRock_Copper");
			P(new Target(Cat.Rudy, "tin cyna", "Cyna", "Tin", "tin cyna", "tin ruda"), "MineRock_Tin", "Pickable_Tin");
			P(new Target(Cat.Rudy, "silwer", "Srebro", "Silver", "srebro", "silver srebro", "silver ruda", "silwer ruda")
			{
				Notes = new string[4] { "need silver", "duzo srebra", "big silver", "probably silver" }
			}, "silvervein", "rock3_silver");
			P(new Target(Cat.Rudy, "ajron w błocie", "Żelazo (złom w błocie)", "Iron (muddy scrap piles)", "zelazo", "iron zelazo", "iron ruda", "iron bagno", "ajron w błocie")
			{
				Notes = new string[4] { "need iron", "duzo iron", "big iron", "probably iron" }
			}, "mudpile", "mudpile2", "Pickable_BogIronOre", "MineRock_Iron");
			P(new Target(Cat.Rudy, "obsydjan", "Obsydian", "Obsidian", "obsydian", "obsydjan"), "MineRock_Obsidian", "Pickable_Obsidian");
			P(new Target(Cat.Rudy, "meteoryt", "Meteoryty", "Meteorites", "meteoryt", "meteor kamien", "kamien z nieba"), "MineRock_Meteorite", "Pickable_Meteorite");
			P(new Target(Cat.Rudy, "flametal", "Flametal", "Flametal", "flametal", "flametal ruda"), "FlametalRockstand", "LeviathanLava");
			P(new Target(Cat.Rudy, "czacha giganta", "Szczątki gigantów", "Giant remains", "czacha giganta", "gigantyczne kości"), "giant_skull", "giant_ribs", "giant_brain");
			P(new Target(Cat.Rudy, "złoto gold", "Złoto", "Gold", "zloto", "gold zloto", "gold ruda"), "goldvein");
			P(new Target(Cat.Rudy, "siarka", "Siarka", "Sulfur", "siarka", "sulfur siarka"), "Pickable_SulfurRock");
			P(new Target(Cat.Rudy, "smoła tar", "Smoła", "Tar", "smola", "tar smoła"), "Pickable_Tar", "Pickable_TarBig");
			P(new Target(Cat.Rudy, "kryształ", "Kryształy", "Crystals", "krysztal", "crystal krysztal", "crystal jaskinia"), "Pickable_MountainCaveCrystal");
			L(new Target(Cat.Lochy, "dung bagno", "Zatopiona krypta (Sunken Crypt)", "Sunken Crypt", "dung bagno"), "SunkenCrypt");
			L(new Target(Cat.Lochy, "dung krypta", "Krypta (Burial Chamber)", "Burial Chamber", "dung krypta"), "Crypt");
			L(new Target(Cat.Lochy, "dung zimny", "Lodowa jaskinia (Frost Cave)", "Frost Cave", "dung zimny", "frost jaskinia", "frost cave", "zimna jaskinia", "jaskinia", "jaskina")
			{
				Notes = new string[1] { "bug jaskinia" }
			}, "MountainCave");
			L(new Target(Cat.Lochy, "dung dwergi", "Zainfekowana kopalnia (Infested Mine)", "Infested Mine", "dung dwergi", "infested kopalnia", "infested mine", "kopalnia robalow", "dvergr kopalnia", "dvergr mine"), "Mistlands_DvergrTownEntrance");
			L(new Target(Cat.Lochy, "trol jaskinia", "Jaskinia trolla", "Troll Cave", "trol jaskinia", "troll jaskinia", "troll cave")
			{
				Notes = new string[2] { "fixme troll", "bug jaskinia" }
			}, "TrollCave");
			L(new Target(Cat.Lochy, "spalony zamek", "Zwęglona forteca (Charred Fortress)", "Charred Fortress", "charred zamek", "charred fortress"), "CharredFortress");
			L(new Target(Cat.Lochy, "śmierdząca dziura", "Gnijąca dziura (Putrid Hole)", "Putrid Hole", "smierdzaca dziura", "putrid dziura", "putrid hole", "dziura smrodu"), "MorgenHole");
			L(new Target(Cat.Inne, "boss tu", "Ołtarze bossów", "Boss altars", "boss tu", "boss tutaj", "tu boss", "boss altar", "boss oltarz", "boss ołtarz", "boss spawn", "boss location", "boss chyba", "boss napewno", "duzy boss", "big boss")
			{
				Notes = new string[2] { "maybe boss", "todo boss" }
			}, "Eikthyrnir", "GDKing", "Bonemass", "Dragonqueen", "GoblinKing", "Mistlands_DvergrBossEntrance", "FaderLocation");
			L(new Target(Cat.Inne, "sklepik haldora", "Haldor (kupiec)", "Haldor (trader)", "haldor sklep", "haldor shop", "haldor sklepik", "haldora"), "Vendor_BlackForest");
			L(new Target(Cat.Inne, "hildirka", "Hildir (kupiec)", "Hildir (trader)", "hildr oboz", "hildir oboz", "hildir camp"), "Hildir_camp");
			L(new Target(Cat.Inne, "wiedzma", "Wiedźma z bagien", "Bog Witch", "witch wiedzma", "witch wiedźma", "witch camp", "witch oboz", "wiedzma camp"), "BogWitch_Camp");
			L(new Target(Cat.Inne, "kamień z runamy", "Kamienie runiczne", "Runestones", "kamień z runamy", "runy jakieś"), "Runestone_");
			L(new Target(Cat.Inne, "obuz goblinuw", "Obozy goblinów (fulingów)", "Fuling camps", "oboz goblinow", "goblin oboz", "goblin camp", "goblin obuz", "fuling oboz", "fuling camp"), "GoblinCamp");
			L(new Target(Cat.Inne, "obuz grejdwarfuw", "Obozy greydwarfów", "Greydwarf camps", "oboz grejdwarfow", "greydwarf oboz", "greydwarf camp"), "Greydwarf_camp");
			L(new Target(Cat.Inne, "gniazdo smoka", "Gniazda smoków", "Drake nests", "gniazdo smoka", "drake gniazdo", "drake nest", "dragon gniazdo"), "DrakeNest");
			L(new Target(Cat.Inne, "wrak", "Wraki", "Shipwrecks", "wrak", "ship wrak", "shipwreck"), "ShipWreck");
		}
	}
}