Decompiled source of ValSeeker v1.0.0

plugins/ValSeeker.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Rendering;
using Valheim.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("ValSeeker")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ValSeeker")]
[assembly: AssemblyTitle("ValSeeker")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ValSeeker;

internal static class RodAssets
{
	private static readonly Color WoodDark = new Color(0.3f, 0.2f, 0.11f);

	private static readonly Color WoodLight = new Color(0.64f, 0.48f, 0.3f);

	private static readonly Color Leather = new Color(0.24f, 0.15f, 0.09f);

	private static readonly Color Bronze = new Color(0.74f, 0.52f, 0.25f);

	private static readonly Color BronzeDark = new Color(0.36f, 0.23f, 0.1f);

	public static readonly Color IdleGlow = new Color(1f, 0.8f, 0.42f);

	public const float ShaftRadius = 0.018f;

	public const float TipRadius = 0.048f;

	public static Mesh ShaftMesh { get; private set; }

	public static Mesh TipMesh { get; private set; }

	public static Material ShaftMaterial { get; private set; }

	public static Material TipMaterial { get; private set; }

	public static Sprite Icon { get; private set; }

	public static float Length { get; private set; }

	public static void BuildIcon()
	{
		Icon = CreateSprite("valseeker_icon", 128, RenderIcon(128));
	}

	public static void Build(Material woodDonor, Material glowDonor, float length)
	{
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		Length = length;
		ShaftMesh = CreateShaft(length, 24);
		TipMesh = CreateSphere(0.048f, 20, 14);
		ShaftMaterial = CreateMaterial("valseeker_shaft", woodDonor, CreateTexture("valseeker_wood", 256, RenderShaftTexture(256)));
		SetFloat(ShaftMaterial, "_Metallic", 0f);
		SetFloat(ShaftMaterial, "_Glossiness", 0.2f);
		TipMaterial = (Material)((!((Object)(object)glowDonor != (Object)null)) ? ((object)CreateMaterial("valseeker_tip", woodDonor, null)) : ((object)new Material(glowDonor)));
		if ((Object)(object)TipMaterial != (Object)null)
		{
			((Object)TipMaterial).name = "valseeker_tip";
			TipMaterial.EnableKeyword("_EMISSION");
		}
	}

	private static Mesh CreateShaft(float length, int segments)
	{
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: 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_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: 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_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Unknown result type (might be due to invalid IL or missing references)
		//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_0235: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Expected O, but got Unknown
		int num = segments + 1;
		Vector3[] array = (Vector3[])(object)new Vector3[num * 7 + 2];
		Vector3[] array2 = (Vector3[])(object)new Vector3[array.Length];
		Vector2[] array3 = (Vector2[])(object)new Vector2[array.Length];
		Vector3 val = default(Vector3);
		for (int i = 0; i <= 6; i++)
		{
			float num2 = (float)i / 6f;
			float num3 = Mathf.Lerp(0.018f, 0.013499999f, num2);
			for (int j = 0; j <= segments; j++)
			{
				float num4 = (float)j / (float)segments;
				float num5 = (float)Math.PI * 2f * num4;
				((Vector3)(ref val))..ctor(Mathf.Cos(num5), 0f, Mathf.Sin(num5));
				int num6 = i * num + j;
				array[num6] = val * num3 + Vector3.up * (num2 * length);
				array2[num6] = val;
				array3[num6] = new Vector2(num4, num2);
			}
		}
		int num7 = num * 7;
		int num8 = num7 + 1;
		array[num7] = Vector3.zero;
		array2[num7] = Vector3.down;
		array3[num7] = new Vector2(0.5f, 0f);
		array[num8] = Vector3.up * length;
		array2[num8] = Vector3.up;
		array3[num8] = new Vector2(0.5f, 1f);
		List<int> list = new List<int>();
		for (int k = 0; k < 6; k++)
		{
			for (int l = 0; l < segments; l++)
			{
				int num9 = k * num + l;
				int num10 = num9 + num;
				list.Add(num9);
				list.Add(num9 + 1);
				list.Add(num10);
				list.Add(num9 + 1);
				list.Add(num10 + 1);
				list.Add(num10);
			}
		}
		for (int m = 0; m < segments; m++)
		{
			list.Add(num7);
			list.Add(m + 1);
			list.Add(m);
			int num11 = 6 * num + m;
			list.Add(num8);
			list.Add(num11);
			list.Add(num11 + 1);
		}
		Mesh val2 = new Mesh
		{
			name = "valseeker_shaft",
			vertices = array,
			normals = array2,
			uv = array3,
			triangles = list.ToArray()
		};
		val2.RecalculateBounds();
		val2.RecalculateTangents();
		return val2;
	}

	private static Mesh CreateSphere(float radius, int longitude, int latitude)
	{
		//IL_008b: 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_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: 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_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Expected O, but got Unknown
		int num = longitude + 1;
		int num2 = num * (latitude + 1);
		Vector3[] array = (Vector3[])(object)new Vector3[num2];
		Vector3[] array2 = (Vector3[])(object)new Vector3[num2];
		Vector2[] array3 = (Vector2[])(object)new Vector2[num2];
		Vector3 val = default(Vector3);
		for (int i = 0; i <= latitude; i++)
		{
			float num3 = (float)i / (float)latitude;
			float num4 = (float)Math.PI * (num3 - 0.5f);
			float num5 = Mathf.Cos(num4);
			for (int j = 0; j <= longitude; j++)
			{
				float num6 = (float)j / (float)longitude;
				float num7 = (float)Math.PI * 2f * num6;
				((Vector3)(ref val))..ctor(Mathf.Cos(num7) * num5, Mathf.Sin(num4), Mathf.Sin(num7) * num5);
				int num8 = i * num + j;
				array[num8] = val * radius;
				array2[num8] = val;
				array3[num8] = new Vector2(num6, num3);
			}
		}
		int[] array4 = new int[longitude * latitude * 6];
		int num9 = 0;
		for (int k = 0; k < latitude; k++)
		{
			for (int l = 0; l < longitude; l++)
			{
				int num10 = k * num + l;
				int num11 = num10 + num;
				array4[num9++] = num10;
				array4[num9++] = num11;
				array4[num9++] = num10 + 1;
				array4[num9++] = num10 + 1;
				array4[num9++] = num11;
				array4[num9++] = num11 + 1;
			}
		}
		Mesh val2 = new Mesh
		{
			name = "valseeker_tip",
			vertices = array,
			normals = array2,
			uv = array3,
			triangles = array4
		};
		val2.RecalculateBounds();
		val2.RecalculateTangents();
		return val2;
	}

	internal static Color[] RenderShaftTexture(int size)
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: 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_00a8: 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_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: 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_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		Color[] array = (Color[])(object)new Color[size * size];
		for (int i = 0; i < size; i++)
		{
			float num = ((float)i + 0.5f) / (float)size;
			for (int j = 0; j < size; j++)
			{
				float num2 = ((float)j + 0.5f) / (float)size;
				Color val;
				if (num < 0.22f)
				{
					float num3 = Frac(num * 40f + num2);
					float num4 = Mathf.Min(num3, 1f - num3);
					val = Leather * (0.75f + 0.35f * TileNoise(num2 * 12f, num * 80f, 12, 80));
					val *= Mathf.Lerp(0.55f, 1f, Mathf.Clamp01(num4 / 0.12f));
				}
				else if (num > 0.9f && num < 0.96f)
				{
					float num5 = Mathf.Min(num - 0.9f, 0.96f - num);
					val = Color.Lerp(BronzeDark, Bronze, Mathf.Clamp01(num5 / 0.012f)) * (0.88f + 0.24f * TileNoise(num2 * 16f, num * 64f, 16, 64));
				}
				else
				{
					float num6 = TileNoise(num2 * 6f, num * 48f, 6, 48);
					float num7 = TileNoise(num2 * 24f, num * 160f, 24, 160);
					val = Color.Lerp(WoodDark, WoodLight, Mathf.Clamp01(0.25f + 0.55f * num6 + 0.2f * num7));
					if (num < 0.25f)
					{
						val *= 0.7f;
					}
				}
				val.a = 1f;
				array[i * size + j] = val;
			}
		}
		return array;
	}

	internal static Color[] RenderIcon(int size)
	{
		//IL_0022: 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_0029: 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_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: 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_00c2: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: 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_0187: Unknown result type (might be due to invalid IL or missing references)
		Vector2 val = default(Vector2);
		((Vector2)(ref val))..ctor(0.2f, 0.14f);
		Vector2 val2 = default(Vector2);
		((Vector2)(ref val2))..ctor(0.72f, 0.74f);
		Vector2 val3 = val2 - val;
		Vector2 normalized = ((Vector2)(ref val3)).normalized;
		Color outline = default(Color);
		((Color)(ref outline))..ctor(0.03f, 0.03f, 0.04f);
		Color[] array = (Color[])(object)new Color[size * size];
		for (int i = 0; i < size; i++)
		{
			for (int j = 0; j < size; j++)
			{
				float num = 0f;
				float num2 = 0f;
				float num3 = 0f;
				float num4 = 0f;
				for (int k = 0; k < 3; k++)
				{
					for (int l = 0; l < 3; l++)
					{
						Color val4 = IconSample(new Vector2(((float)j + ((float)l + 0.5f) / 3f) / (float)size, ((float)i + ((float)k + 0.5f) / 3f) / (float)size), val, val2, normalized, 0.028f, 0.085f, IdleGlow, outline);
						num += val4.r * val4.a;
						num2 += val4.g * val4.a;
						num3 += val4.b * val4.a;
						num4 += val4.a;
					}
				}
				array[i * size + j] = ((num4 > 0.0001f) ? new Color(num / num4, num2 / num4, num3 / num4, num4 / 9f) : new Color(0f, 0f, 0f, 0f));
			}
		}
		return array;
	}

	private static Color IconSample(Vector2 p, Vector2 grip, Vector2 tip, Vector2 axis, float shaftHalf, float tipRadius, Color glow, Color outline)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//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_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_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: 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_002e: 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_0070: 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_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: 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_00be: 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_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: 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)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		float num = Vector2.Dot(p - grip, axis);
		float num2 = Vector2.Dot(p - grip, new Vector2(0f - axis.y, axis.x));
		float num3 = Vector2.Distance(grip, tip) - tipRadius * 0.6f;
		float num4 = num / num3;
		float num5 = Mathf.Max(Mathf.Abs(num2) - shaftHalf * (1f - 0.25f * Mathf.Clamp01(num4)), Mathf.Max(0f - num, num - num3));
		float num6 = Vector2.Distance(p, tip) - tipRadius;
		if (num6 <= 0f)
		{
			float num7 = 1f + num6 / tipRadius;
			Color val = Color.Lerp(glow * 0.9f, Color.white, Mathf.Clamp01((num7 - 0.45f) / 0.55f));
			val = Color.Lerp(val, outline, Mathf.Clamp01((0.12f - num7) / 0.12f) * 0.9f);
			val.a = 1f;
			return val;
		}
		if (num5 <= 0f)
		{
			Color val2 = ((num4 < 0.22f) ? (Leather * (0.8f + 0.3f * Frac(num4 * 30f))) : ((!(num4 > 0.86f)) ? Color.Lerp(WoodDark, WoodLight, 0.35f + 0.5f * TileNoise(num4 * 30f, num2 * 200f, 30, 200)) : Bronze));
			float num8 = Mathf.Clamp01(Mathf.Abs(num2) / shaftHalf);
			val2 *= 1.15f - 0.55f * num8 * num8;
			val2 = Color.Lerp(val2, outline, Mathf.Clamp01((num8 - 0.85f) / 0.15f) * 0.85f);
			val2.a = 1f;
			return val2;
		}
		float num9 = Mathf.Clamp01(1f - num6 / (tipRadius * 1.4f));
		if (!(num9 > 0f))
		{
			return new Color(0f, 0f, 0f, 0f);
		}
		return new Color(glow.r, glow.g, glow.b, num9 * num9 * 0.7f);
	}

	internal static Color[] RenderOrb(int size, Color color)
	{
		//IL_0012: 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_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: 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_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: 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)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		float num = (float)size * 0.34f;
		float num2 = (float)size * 0.5f;
		Color val = color * 0.35f;
		Color val2 = default(Color);
		((Color)(ref val2))..ctor(0.03f, 0.03f, 0.04f);
		Vector3 val3 = new Vector3(-0.4f, 0.55f, -0.73f);
		Vector3 normalized = ((Vector3)(ref val3)).normalized;
		Color[] array = (Color[])(object)new Color[size * size];
		Color val4 = default(Color);
		for (int i = 0; i < size; i++)
		{
			for (int j = 0; j < size; j++)
			{
				float num3 = 0f;
				float num4 = 0f;
				float num5 = 0f;
				float num6 = 0f;
				for (int k = 0; k < 3; k++)
				{
					for (int l = 0; l < 3; l++)
					{
						float num7 = ((float)j + ((float)l + 0.5f) / 3f - num2) / num;
						float num8 = ((float)i + ((float)k + 0.5f) / 3f - num2) / num;
						float num9 = Mathf.Sqrt(num7 * num7 + num8 * num8);
						if (num9 <= 1f)
						{
							float num10 = Mathf.Sqrt(1f - num9 * num9);
							float num11 = Mathf.Clamp01(num7 * normalized.x + num8 * normalized.y - num10 * normalized.z);
							val4 = Color.Lerp(val, color, 0.3f + 0.7f * num11);
							Vector2 val5 = new Vector2(num7 + 0.35f, num8 - 0.4f);
							float num12 = Mathf.Clamp01(1f - ((Vector2)(ref val5)).magnitude / 0.35f);
							val4 = Color.Lerp(val4, Color.white, num12 * num12 * 0.7f);
							val4 = Color.Lerp(val4, val2, Mathf.Clamp01((num9 - 0.84f) / 0.16f) * 0.9f);
							val4.a = 1f;
						}
						else
						{
							float num13 = Mathf.Clamp01(1f - (num9 - 1f) / 0.4f);
							((Color)(ref val4))..ctor(color.r, color.g, color.b, num13 * num13 * 0.5f);
						}
						num3 += val4.r * val4.a;
						num4 += val4.g * val4.a;
						num5 += val4.b * val4.a;
						num6 += val4.a;
					}
				}
				array[i * size + j] = ((num6 > 0.0001f) ? new Color(num3 / num6, num4 / num6, num5 / num6, num6 / 9f) : new Color(0f, 0f, 0f, 0f));
			}
		}
		return array;
	}

	private static float Frac(float value)
	{
		return value - Mathf.Floor(value);
	}

	private static float Hash(int x, int y, int seed)
	{
		int num = x * 374761393 + y * 668265263 + seed * 1274126177;
		int num2 = (num ^ (num >>> 13)) * 1274126177;
		return (float)(uint)((num2 ^ (num2 >>> 16)) & 0xFFFFFF) / 16777215f;
	}

	private static float TileNoise(float x, float y, int periodX, int periodY)
	{
		int num = Mathf.FloorToInt(x);
		int num2 = Mathf.FloorToInt(y);
		float num3 = x - (float)num;
		float num4 = y - (float)num2;
		num3 = num3 * num3 * (3f - 2f * num3);
		num4 = num4 * num4 * (3f - 2f * num4);
		int x2 = Wrap(num, periodX);
		int x3 = Wrap(num + 1, periodX);
		int y2 = Wrap(num2, periodY);
		int y3 = Wrap(num2 + 1, periodY);
		float num5 = Mathf.Lerp(Hash(x2, y2, 7), Hash(x3, y2, 7), num3);
		float num6 = Mathf.Lerp(Hash(x2, y3, 7), Hash(x3, y3, 7), num3);
		return Mathf.Lerp(num5, num6, num4);
	}

	private static int Wrap(int value, int period)
	{
		int num = value % period;
		if (num >= 0)
		{
			return num;
		}
		return num + period;
	}

	internal static Sprite CreateSprite(string name, int size, Color[] pixels)
	{
		//IL_0004: 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_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: 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_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		Texture2D val = new Texture2D(size, size, (TextureFormat)4, false)
		{
			name = name,
			wrapMode = (TextureWrapMode)1,
			filterMode = (FilterMode)1
		};
		val.SetPixels(pixels);
		val.Apply(false, true);
		Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f), 100f);
		((Object)obj).name = name;
		return obj;
	}

	private static Texture2D CreateTexture(string name, int size, Color[] pixels)
	{
		//IL_0004: 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_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: 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_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		Texture2D val = new Texture2D(size, size, (TextureFormat)4, true)
		{
			name = name,
			wrapMode = (TextureWrapMode)0,
			filterMode = (FilterMode)2,
			anisoLevel = 4
		};
		val.SetPixels(pixels);
		val.Apply(true, true);
		return val;
	}

	internal static Material CreateMaterial(string name, Material donor, Texture2D albedo)
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Expected O, but got Unknown
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		Material val;
		if ((Object)(object)donor != (Object)null)
		{
			val = new Material(donor);
		}
		else
		{
			Shader val2 = Shader.Find("Standard") ?? Shader.Find("Legacy Shaders/Diffuse");
			if ((Object)(object)val2 == (Object)null)
			{
				SeekerPlugin.Log.LogWarning((object)("No usable shader found for '" + name + "'."));
				return null;
			}
			val = new Material(val2);
		}
		((Object)val).name = name;
		if ((Object)(object)albedo != (Object)null && val.HasProperty("_MainTex"))
		{
			val.SetTexture("_MainTex", (Texture)(object)albedo);
			val.SetTextureScale("_MainTex", Vector2.one);
			val.SetTextureOffset("_MainTex", Vector2.zero);
		}
		SetColor(val, "_Color", Color.white);
		ClearTexture(val, "_BumpMap");
		ClearTexture(val, "_MetallicGlossMap");
		ClearTexture(val, "_EmissionMap");
		SetColor(val, "_EmissionColor", Color.black);
		val.DisableKeyword("_NORMALMAP");
		val.DisableKeyword("_METALLICGLOSSMAP");
		val.DisableKeyword("_EMISSION");
		return val;
	}

	internal static void SetColor(Material material, string property, Color value)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)material != (Object)null && material.HasProperty(property))
		{
			material.SetColor(property, value);
		}
	}

	internal static void SetFloat(Material material, string property, float value)
	{
		if ((Object)(object)material != (Object)null && material.HasProperty(property))
		{
			material.SetFloat(property, value);
		}
	}

	private static void ClearTexture(Material material, string property)
	{
		if (material.HasProperty(property))
		{
			material.SetTexture(property, (Texture)null);
		}
	}
}
[BepInPlugin("gokbe.valseeker", "ValSeeker", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class SeekerPlugin : BaseUnityPlugin
{
	public const string ModGuid = "gokbe.valseeker";

	public const string ModName = "ValSeeker";

	public const string ModVersion = "1.0.0";

	public const string RodPrefabName = "SeekerRod";

	public const string ItemToken = "$item_seekerrod";

	private const string BaseItemName = "Club";

	private const string GlowDonorName = "SurtlingCore";

	internal static ManualLogSource Log;

	internal static ConfigEntry<float> RadiusBase;

	internal static ConfigEntry<float> RadiusPerLevel;

	internal static ConfigEntry<float> MaxRadius;

	internal static ConfigEntry<float> ScanInterval;

	internal static ConfigEntry<float> HoldToOpen;

	internal static ConfigEntry<bool> ShowHints;

	internal static ConfigEntry<bool> Beam;

	internal static ConfigEntry<bool> Sounds;

	internal static ConfigEntry<float> XpPerFind;

	internal static ConfigEntry<float> XpPerTick;

	internal static ConfigEntry<float> XpTickSeconds;

	internal static ConfigEntry<float> FindDistance;

	internal static ConfigEntry<bool> RequireKnownResource;

	internal static ConfigEntry<bool> RequireExploredMap;

	private Harmony m_harmony;

	private void Awake()
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Expected O, but got Unknown
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Expected O, but got Unknown
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Expected O, but got Unknown
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Expected O, but got Unknown
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Expected O, but got Unknown
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Expected O, but got Unknown
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Expected O, but got Unknown
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Expected O, but got Unknown
		//IL_0281: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: Expected O, but got Unknown
		//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0305: Unknown result type (might be due to invalid IL or missing references)
		//IL_0310: Unknown result type (might be due to invalid IL or missing references)
		//IL_031b: Unknown result type (might be due to invalid IL or missing references)
		//IL_032b: Expected O, but got Unknown
		//IL_0326: Unknown result type (might be due to invalid IL or missing references)
		//IL_032b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0347: Unknown result type (might be due to invalid IL or missing references)
		//IL_0351: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		RadiusBase = ((BaseUnityPlugin)this).Config.Bind<float>("Range", "RadiusBase", 40f, new ConfigDescription("Seeking range in metres at Smelling level 0.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 512f), Array.Empty<object>()));
		RadiusPerLevel = ((BaseUnityPlugin)this).Config.Bind<float>("Range", "RadiusPerLevel", 1f, new ConfigDescription("Metres of range every Smelling level adds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
		MaxRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Range", "MaxRadius", 128f, new ConfigDescription("Upper limit of the range. The game only knows the world about 128 m (2 zones) around a player, so a larger value only helps with a higher simulation distance.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 512f), Array.Empty<object>()));
		ScanInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Range", "ScanInterval", 0.5f, new ConfigDescription("Seconds between two looks for the nearest deposit while seeking.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>()));
		HoldToOpen = ((BaseUnityPlugin)this).Config.Bind<float>("Controls", "HoldToOpen", 0.15f, new ConfigDescription("Seconds the attack button must be held before the resource picker opens.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
		ShowHints = ((BaseUnityPlugin)this).Config.Bind<bool>("Controls", "ShowHints", true, "Show a short reminder of the buttons when the rod is equipped.");
		Beam = ((BaseUnityPlugin)this).Config.Bind<bool>("Controls", "Beam", true, "Draw a short beam of light from the core towards the deposit while seeking.");
		Sounds = ((BaseUnityPlugin)this).Config.Bind<bool>("Controls", "Sounds", true, "Play the wishbone pings while seeking (faster the closer the deposit is).");
		XpPerFind = ((BaseUnityPlugin)this).Config.Bind<float>("Smelling", "XpPerFind", 5f, new ConfigDescription("Smelling experience for reaching a deposit the rod led you to (once per deposit).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
		XpPerTick = ((BaseUnityPlugin)this).Config.Bind<float>("Smelling", "XpPerTick", 0.5f, new ConfigDescription("Smelling experience every XpTickSeconds while the rod is pointing at a deposit.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
		XpTickSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Smelling", "XpTickSeconds", 5f, new ConfigDescription("Seconds between two experience ticks while seeking.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>()));
		FindDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Smelling", "FindDistance", 6f, new ConfigDescription("Distance in metres at which a deposit counts as found.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 30f), Array.Empty<object>()));
		RequireKnownResource = ((BaseUnityPlugin)this).Config.Bind<bool>("Discovery", "RequireKnownResource", true, "The picker only lists resources you have already found: the item must be a known material (you picked one up before). The first deposit of a kind still has to be found on foot.");
		RequireExploredMap = ((BaseUnityPlugin)this).Config.Bind<bool>("Discovery", "RequireExploredMap", false, "The rod only finds deposits inside map areas you have already uncovered.");
		SeekerTargets.Bind(((BaseUnityPlugin)this).Config);
		AddLocalizations();
		RodAssets.BuildIcon();
		SeekerRod.Skill = SkillManager.Instance.AddSkill(new SkillConfig
		{
			Identifier = "gokbe.valseeker.smelling",
			Name = "$skill_smelling",
			Description = "$skill_smelling_desc",
			Icon = RodAssets.Icon,
			IncreaseStep = 1f
		});
		PrefabManager.OnVanillaPrefabsAvailable += CreateRod;
		m_harmony = new Harmony("gokbe.valseeker");
		try
		{
			m_harmony.PatchAll(typeof(SeekerPlugin).Assembly);
		}
		catch (Exception ex)
		{
			Log.LogError((object)("Harmony patching failed (the rod will swing instead of seeking): " + ex));
		}
	}

	private void Update()
	{
		try
		{
			SeekerRod.Update(Time.deltaTime);
		}
		catch (Exception ex)
		{
			Log.LogError((object)("Seeker Rod disabled after an error: " + ex));
			((Behaviour)this).enabled = false;
		}
	}

	private void OnDestroy()
	{
		Harmony harmony = m_harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}

	private unsafe void CreateRod()
	{
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c9: Expected O, but got Unknown
		//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fd: Expected O, but got Unknown
		//IL_0307: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: Expected O, but got Unknown
		//IL_0317: Unknown result type (might be due to invalid IL or missing references)
		//IL_031d: Expected O, but got Unknown
		//IL_032f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0339: Expected O, but got Unknown
		//IL_036b: Unknown result type (might be due to invalid IL or missing references)
		//IL_036c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("SeekerRod", "Club");
			if ((Object)(object)val == (Object)null || (Object)(object)val.GetComponent<ItemDrop>() == (Object)null)
			{
				Log.LogError((object)"Vanilla prefab 'Club' not found, the Seeker Rod was not created.");
				return;
			}
			Log.LogDebug((object)("Seeker Rod is built from:\n" + Describe(val.transform, 0)));
			Transform val2 = val.transform.Find("attach");
			MeasureDonor(val, val2, out var axis, out var length);
			Material val3 = FindMaterial(val, null);
			GameObject prefab = PrefabManager.Instance.GetPrefab("SurtlingCore");
			Material val4 = (((Object)(object)prefab != (Object)null) ? FindMaterial(prefab, "_EmissionColor") : null);
			Log.LogInfo((object)("Seeker Rod materials: shaft from " + (((Object)(object)val3 != (Object)null) ? (((Object)val3).name + " (" + ((Object)val3.shader).name + ")") : "Standard") + ", core from " + (((Object)(object)val4 != (Object)null) ? (((Object)val4).name + " (" + ((Object)val4.shader).name + ")") : "the shaft")));
			RodAssets.Build(val3, val4, length);
			bool flag = HasModelOutside(val.transform, val2);
			StripVisuals(val, val2);
			if ((Object)(object)val2 != (Object)null)
			{
				AddVisual(val2, axis, val.layer);
			}
			if ((Object)(object)val2 == (Object)null || flag)
			{
				AddVisual(val.transform, axis, val.layer);
			}
			SharedData shared = val.GetComponent<ItemDrop>().m_itemData.m_shared;
			shared.m_name = "$item_seekerrod";
			shared.m_description = "$item_seekerrod_desc";
			shared.m_icons = (Sprite[])(object)new Sprite[1] { RodAssets.Icon };
			shared.m_itemType = (ItemType)3;
			shared.m_animationState = (AnimationState)1;
			shared.m_maxStackSize = 1;
			shared.m_maxQuality = 1;
			shared.m_variants = 0;
			shared.m_weight = 1f;
			shared.m_value = 0;
			shared.m_dlc = "";
			shared.m_teleportable = true;
			shared.m_questItem = false;
			shared.m_useDurability = false;
			shared.m_toolTier = 0;
			shared.m_damages = default(DamageTypes);
			shared.m_attackForce = 0f;
			shared.m_backstabBonus = 1f;
			shared.m_blockPower = 0f;
			shared.m_blockable = true;
			shared.m_attackStatusEffect = null;
			shared.m_equipStatusEffect = null;
			shared.m_setName = "";
			shared.m_movementModifier = 0f;
			shared.m_alwaysRotate = false;
			shared.m_attack.m_attackAnimation = "";
			shared.m_attack.m_attackType = (AttackType)3;
			shared.m_secondaryAttack.m_attackAnimation = "";
			ItemConfig val5 = new ItemConfig();
			val5.CraftingStation = "piece_workbench";
			val5.MinStationLevel = 2;
			val5.Amount = 1;
			val5.Requirements = (RequirementConfig[])(object)new RequirementConfig[3]
			{
				new RequirementConfig("FineWood", 4, 0, true),
				new RequirementConfig("SurtlingCore", 1, 0, true),
				new RequirementConfig("GreydwarfEye", 3, 0, true)
			};
			ItemConfig val6 = val5;
			ItemManager.Instance.AddItem(new CustomItem(val, false, val6));
			ManualLogSource log = Log;
			string[] obj = new string[5]
			{
				"Seeker Rod registered (SeekerRod, ",
				length.ToString("0.00", CultureInfo.InvariantCulture),
				" m along ",
				null,
				null
			};
			Vector3 val7 = axis;
			obj[3] = ((object)(*(Vector3*)(&val7))/*cast due to .constrained prefix*/).ToString();
			obj[4] = ").";
			log.LogInfo((object)string.Concat(obj));
		}
		catch (Exception ex)
		{
			Log.LogError((object)("Failed to create the Seeker Rod: " + ex));
		}
		finally
		{
			PrefabManager.OnVanillaPrefabsAvailable -= CreateRod;
		}
	}

	private static void MeasureDonor(GameObject prefab, Transform attach, out Vector3 axis, out float length)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: 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_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: 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_007b: 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_006d: 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_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: 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_00b2: 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_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//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)
		axis = Vector3.up;
		length = 0.9f;
		Transform val = (((Object)(object)attach != (Object)null) ? attach : prefab.transform);
		MeshFilter componentInChildren = ((Component)val).GetComponentInChildren<MeshFilter>(true);
		if (!((Object)(object)componentInChildren == (Object)null) && !((Object)(object)componentInChildren.sharedMesh == (Object)null))
		{
			Bounds bounds = componentInChildren.sharedMesh.bounds;
			Vector3 size = ((Bounds)(ref bounds)).size;
			int num = ((!(size.x >= size.y) || !(size.x >= size.z)) ? ((size.y >= size.z) ? 1 : 2) : 0);
			Vector3 center = ((Bounds)(ref bounds)).center;
			Vector3 val2 = ((Bounds)(ref bounds)).max;
			float num2 = Mathf.Abs(((Vector3)(ref val2))[num]);
			val2 = ((Bounds)(ref bounds)).min;
			float num3;
			if (!(num2 >= Mathf.Abs(((Vector3)(ref val2))[num])))
			{
				val2 = ((Bounds)(ref bounds)).min;
				num3 = ((Vector3)(ref val2))[num];
			}
			else
			{
				val2 = ((Bounds)(ref bounds)).max;
				num3 = ((Vector3)(ref val2))[num];
			}
			((Vector3)(ref center))[num] = num3;
			Vector3 val3 = val.InverseTransformPoint(((Component)componentInChildren).transform.TransformPoint(center));
			if (!(((Vector3)(ref val3)).magnitude < 0.2f))
			{
				axis = ((Vector3)(ref val3)).normalized;
				length = Mathf.Clamp(((Vector3)(ref val3)).magnitude, 0.7f, 1.2f);
			}
		}
	}

	private static Material FindMaterial(GameObject source, string requiredProperty)
	{
		MeshRenderer[] componentsInChildren = source.GetComponentsInChildren<MeshRenderer>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			Material[] sharedMaterials = ((Renderer)componentsInChildren[i]).sharedMaterials;
			foreach (Material val in sharedMaterials)
			{
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val.shader == (Object)null) && val.HasProperty("_MainTex") && ((Object)val.shader).name.IndexOf("Particle", StringComparison.OrdinalIgnoreCase) < 0 && (requiredProperty == null || val.HasProperty(requiredProperty)))
				{
					return val;
				}
			}
		}
		return null;
	}

	private static bool HasModelOutside(Transform root, Transform attach)
	{
		MeshRenderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<MeshRenderer>(true);
		foreach (MeshRenderer val in componentsInChildren)
		{
			if ((Object)(object)attach == (Object)null || !((Component)val).transform.IsChildOf(attach))
			{
				return true;
			}
		}
		return false;
	}

	private static void StripVisuals(GameObject prefab, Transform attach)
	{
		List<GameObject> list = new List<GameObject>();
		Transform[] componentsInChildren = prefab.GetComponentsInChildren<Transform>(true);
		foreach (Transform val in componentsInChildren)
		{
			if (!((Object)(object)val == (Object)(object)prefab.transform) && !((Object)(object)val == (Object)(object)attach) && ((Object)(object)val.parent == (Object)(object)prefab.transform || (Object)(object)val.parent == (Object)(object)attach))
			{
				bool num = (Object)(object)((Component)val).GetComponentInChildren<Renderer>(true) != (Object)null || (Object)(object)((Component)val).GetComponentInChildren<Light>(true) != (Object)null || (Object)(object)((Component)val).GetComponentInChildren<ParticleSystem>(true) != (Object)null || (Object)(object)((Component)val).GetComponentInChildren<MeshFilter>(true) != (Object)null;
				bool flag = (Object)(object)((Component)val).GetComponentInChildren<Collider>(true) != (Object)null;
				if (num && !flag)
				{
					list.Add(((Component)val).gameObject);
				}
			}
		}
		foreach (GameObject item in list)
		{
			Object.DestroyImmediate((Object)(object)item);
		}
		componentsInChildren = (Transform[])(object)((!((Object)(object)attach != (Object)null)) ? new Transform[0] : new Transform[1] { attach });
		foreach (Transform val2 in componentsInChildren)
		{
			LODGroup[] componentsInChildren2 = ((Component)val2).GetComponentsInChildren<LODGroup>(true);
			for (int j = 0; j < componentsInChildren2.Length; j++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren2[j]);
			}
			Renderer[] componentsInChildren3 = ((Component)val2).GetComponentsInChildren<Renderer>(true);
			for (int j = 0; j < componentsInChildren3.Length; j++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren3[j]);
			}
			MeshFilter[] componentsInChildren4 = ((Component)val2).GetComponentsInChildren<MeshFilter>(true);
			for (int j = 0; j < componentsInChildren4.Length; j++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren4[j]);
			}
		}
	}

	private static void AddVisual(Transform parent, Vector3 axis, int layer)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: 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_005f: 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_0097: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: 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)
		GameObject val = new GameObject("seeker_visual");
		val.layer = layer;
		val.transform.SetParent(parent, false);
		val.transform.localRotation = Quaternion.FromToRotation(Vector3.up, axis);
		val.AddComponent<SeekerVisual>();
		GameObject val2 = new GameObject("seeker_shaft")
		{
			layer = layer
		};
		val2.transform.SetParent(val.transform, false);
		val2.AddComponent<MeshFilter>().sharedMesh = RodAssets.ShaftMesh;
		MeshRenderer val3 = val2.AddComponent<MeshRenderer>();
		if ((Object)(object)RodAssets.ShaftMaterial != (Object)null)
		{
			((Renderer)val3).sharedMaterial = RodAssets.ShaftMaterial;
		}
		GameObject val4 = new GameObject("seeker_tip")
		{
			layer = layer
		};
		val4.transform.SetParent(val.transform, false);
		val4.transform.localPosition = new Vector3(0f, RodAssets.Length + 0.028800001f, 0f);
		val4.AddComponent<MeshFilter>().sharedMesh = RodAssets.TipMesh;
		MeshRenderer val5 = val4.AddComponent<MeshRenderer>();
		if ((Object)(object)RodAssets.TipMaterial != (Object)null)
		{
			((Renderer)val5).sharedMaterial = RodAssets.TipMaterial;
		}
		Light obj = val4.AddComponent<Light>();
		obj.type = (LightType)2;
		obj.color = RodAssets.IdleGlow;
		obj.intensity = 0.5f;
		obj.range = 4f;
		obj.shadows = (LightShadows)0;
		val4.AddComponent<SeekerTip>();
	}

	private static string Describe(Transform transform, int depth)
	{
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Expected O, but got Unknown
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.Append(' ', depth * 2).Append(((Object)transform).name).Append(((Component)transform).gameObject.activeSelf ? " [" : " (inactive) [");
		Component[] components = ((Component)transform).GetComponents<Component>();
		foreach (Component val in components)
		{
			if ((Object)(object)val != (Object)null && !(val is Transform))
			{
				stringBuilder.Append(((object)val).GetType().Name).Append(' ');
			}
		}
		stringBuilder.Append("]\n");
		foreach (Transform item in transform)
		{
			Transform transform2 = item;
			stringBuilder.Append(Describe(transform2, depth + 1));
		}
		return stringBuilder.ToString();
	}

	internal static string Localize(string text)
	{
		if (Localization.instance == null)
		{
			return text;
		}
		return Localization.instance.Localize(text);
	}

	private static void AddLocalizations()
	{
		CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
		string text = "English";
		localization.AddTranslation(ref text, new Dictionary<string, string>
		{
			{ "item_seekerrod", "Seeker Rod" },
			{ "item_seekerrod_desc", "A fine wood rod crowned with a surtling core. Hold $KEY_Attack to choose a resource, hold $KEY_Block to seek the nearest one. Its reach grows with your Smelling." },
			{ "skill_smelling", "Smelling" },
			{ "skill_smelling_desc", "Your nose for hidden riches. Extends the reach of the Seeker Rod." },
			{ "valseeker_hint", "Seeker Rod: hold $KEY_Attack to choose a resource, hold $KEY_Block to seek" },
			{ "valseeker_choose", "Choose a resource first (hold $KEY_Attack)" },
			{ "valseeker_selected", "Seeking {0}" },
			{ "valseeker_nothing", "nothing within {0} m" },
			{ "valseeker_found", "Found: {0}" },
			{ "valseeker_nearby", "nearby" },
			{ "valseeker_none_nearby", "none nearby" },
			{ "valseeker_above", "above you" },
			{ "valseeker_below", "below you" },
			{ "valseeker_range", "Reach" },
			{ "valseeker_seeking", "Seeking" },
			{ "valseeker_nomenu", "The resource picker could not open" },
			{ "valseeker_nothing_known", "You have not found any of these resources yet" },
			{ "valseeker_buried", "buried" },
			{ "valseeker_tin", "Tin" },
			{ "valseeker_copper", "Copper" },
			{ "valseeker_silver", "Silver" },
			{ "valseeker_iron", "Iron scrap" },
			{ "valseeker_obsidian", "Obsidian" },
			{ "valseeker_blackmarble", "Black marble" },
			{ "valseeker_flametal", "Flametal" },
			{ "valseeker_gold", "Gold" },
			{ "valseeker_sulfur", "Sulfur" },
			{ "valseeker_thistle", "Thistle" },
			{ "valseeker_dragonegg", "Dragon egg" },
			{ "valseeker_guck", "Guck" },
			{ "valseeker_tar", "Tar" },
			{ "valseeker_cloudberry", "Cloudberries" }
		});
		text = "Turkish";
		localization.AddTranslation(ref text, new Dictionary<string, string>
		{
			{ "item_seekerrod", "Arayıcı Asa" },
			{ "item_seekerrod_desc", "Tepesinde surtling çekirdeği olan ince ahşap bir asa. Kaynak seçmek için $KEY_Attack tuşunu, en yakınını aramak için $KEY_Block tuşunu basılı tut. Menzili Koku Alma ile artar." },
			{ "skill_smelling", "Koku Alma" },
			{ "skill_smelling_desc", "Gizli zenginlikleri koklama yeteneğin. Arayıcı Asa'nın menzilini artırır." },
			{ "valseeker_hint", "Arayıcı Asa: kaynak seçmek için $KEY_Attack, aramak için $KEY_Block tuşunu basılı tut" },
			{ "valseeker_choose", "Önce bir kaynak seç ($KEY_Attack tuşunu basılı tut)" },
			{ "valseeker_selected", "{0} aranıyor" },
			{ "valseeker_nothing", "{0} m içinde yok" },
			{ "valseeker_found", "Bulundu: {0}" },
			{ "valseeker_nearby", "yakında" },
			{ "valseeker_none_nearby", "yakında yok" },
			{ "valseeker_above", "yukarıda" },
			{ "valseeker_below", "aşağıda" },
			{ "valseeker_range", "Menzil" },
			{ "valseeker_seeking", "Aranan" },
			{ "valseeker_nomenu", "Kaynak seçim menüsü açılamadı" },
			{ "valseeker_nothing_known", "Bu kaynaklardan henüz hiçbirini bulmadın" },
			{ "valseeker_buried", "gömülü" },
			{ "valseeker_tin", "Kalay" },
			{ "valseeker_copper", "Bakır" },
			{ "valseeker_silver", "Gümüş" },
			{ "valseeker_iron", "Demir hurdası" },
			{ "valseeker_obsidian", "Obsidyen" },
			{ "valseeker_blackmarble", "Kara mermer" },
			{ "valseeker_flametal", "Alev metali" },
			{ "valseeker_gold", "Altın" },
			{ "valseeker_sulfur", "Kükürt" },
			{ "valseeker_thistle", "Devedikeni" },
			{ "valseeker_dragonegg", "Ejderha yumurtası" },
			{ "valseeker_guck", "Guck" },
			{ "valseeker_tar", "Katran" },
			{ "valseeker_cloudberry", "Bulut yemişi" }
		});
	}
}
[HarmonyPatch(typeof(Hud), "UpdateCrosshair")]
internal static class Hud_UpdateCrosshair_Patch
{
	private static void Postfix(Hud __instance, Player player)
	{
		if (!((Object)(object)player == (Object)null) && !((Object)(object)__instance.m_hoverName == (Object)null))
		{
			string text = SeekerRod.HudText(player);
			if (text != null)
			{
				string text2 = ((TMP_Text)__instance.m_hoverName).text;
				((TMP_Text)__instance.m_hoverName).text = (string.IsNullOrEmpty(text2) ? text : (text2 + "\n" + text));
			}
		}
	}
}
[HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[]
{
	typeof(ItemData),
	typeof(int),
	typeof(bool),
	typeof(float),
	typeof(int),
	typeof(bool)
})]
internal static class ItemData_GetTooltip_Patch
{
	private static void Postfix(ItemData item, ref string __result)
	{
		if (SeekerRod.IsRod(item))
		{
			SeekerTarget seekerTarget = SeekerRod.SelectedTarget(item);
			string text = ((seekerTarget != null) ? seekerTarget.LocalizedName : "-");
			float num = SeekerRod.CurrentRadius(Player.m_localPlayer);
			__result = __result + "\n\n" + SeekerPlugin.Localize("$valseeker_seeking") + ": <color=orange>" + text + "</color>\n" + SeekerPlugin.Localize("$valseeker_range") + ": <color=orange>" + Mathf.RoundToInt(num).ToString(CultureInfo.InvariantCulture) + " m</color>";
		}
	}
}
internal class SeekerRadial : IRadialConfig
{
	private class ElementConfig : IRadialConfig
	{
		private readonly SeekerTarget m_target;

		public string LocalizedName => m_target.LocalizedName;

		public Sprite Sprite => m_target.Icon;

		public ElementConfig(SeekerTarget target)
		{
			m_target = target;
		}

		public void InitRadialConfig(RadialBase radial)
		{
		}
	}

	private static readonly MethodInfo SetSubTitle = AccessTools.PropertySetter(typeof(RadialMenuElement), "SubTitle");

	private static readonly MethodInfo ResetAllVariables = AccessTools.Method(typeof(RadialBase), "ResetAllVariables", (Type[])null, (Type[])null);

	private const float GraceSeconds = 0.2f;

	private static float s_openedAt;

	private List<SeekerTarget> m_targets;

	public string LocalizedName => SeekerPlugin.Localize("$item_seekerrod");

	public Sprite Sprite => RodAssets.Icon;

	public static bool Open(Player player, out string problem)
	{
		problem = "$valseeker_nomenu";
		RadialBase val = (((Object)(object)Hud.instance != (Object)null) ? Hud.instance.m_radialMenu : null);
		if ((Object)(object)val == (Object)null)
		{
			SeekerPlugin.Log.LogWarning((object)"Picker: the HUD has no radial menu.");
			return false;
		}
		if (val.Active)
		{
			SeekerPlugin.Log.LogDebug((object)"Picker: a radial menu is already open.");
			return false;
		}
		List<SeekerTarget> list = SeekerTargets.Listed(player);
		if (list.Count == 0)
		{
			problem = ((SeekerTargets.Available.Count == 0) ? "$valseeker_nomenu" : "$valseeker_nothing_known");
			SeekerPlugin.Log.LogDebug((object)("Picker: nothing to list (" + SeekerTargets.Available.Count + " targets exist, none known yet)."));
			return false;
		}
		if (ResetAllVariables != null)
		{
			ResetAllVariables.Invoke(val, null);
		}
		s_openedAt = Time.time;
		val.CanOpen = true;
		val.Open((IRadialConfig)(object)new SeekerRadial
		{
			m_targets = list
		}, (IRadialConfig)null);
		SeekerPlugin.Log.LogDebug((object)("Picker opened: active=" + val.Active + ", listed=" + list.Count));
		return val.Active;
	}

	private static bool OpenButtonHeld()
	{
		if (ZInput.GetButton("Attack") || ZInput.GetButton("JoyAttack"))
		{
			return true;
		}
		Mouse current = Mouse.current;
		if (current != null)
		{
			return current.leftButton.isPressed;
		}
		return false;
	}

	public void InitRadialConfig(RadialBase radial)
	{
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		RadialConfigHelper.SetXYControls(radial);
		radial.GetReleaseToUse = delegate
		{
			if (!(Time.time - s_openedAt < 0.2f) && !ZInput.IsGamepadActive())
			{
				bool num = !OpenButtonHeld();
				if (num)
				{
					SeekerPlugin.Log.LogDebug((object)"Picker: attack button released, choosing the hovered resource.");
				}
				return num;
			}
			return false;
		};
		radial.GetConfirm = () => ZInput.IsGamepadActive() && ZInput.GetButtonDown("JoyRadialInteract");
		radial.GetBack = () => false;
		radial.GetClose = delegate
		{
			int num;
			if (!ZInput.GetKeyDown((KeyCode)27, false) && !ZInput.GetButtonDown("Block") && !ZInput.GetButtonDown("JoyRadialClose"))
			{
				num = (ZInput.GetButtonDown("JoyRadialBack") ? 1 : 0);
				if (num == 0)
				{
					goto IL_0041;
				}
			}
			else
			{
				num = 1;
			}
			SeekerPlugin.Log.LogDebug((object)"Picker: closed without choosing.");
			goto IL_0041;
			IL_0041:
			return (byte)num != 0;
		};
		radial.GetThrow = () => false;
		radial.GetOpenThrowMenu = () => false;
		radial.GetFlick = () => false;
		radial.GetDoubleTap = () => false;
		radial.OnInteractionDelay = delegate
		{
		};
		radial.ShouldAnimateIn = true;
		Player localPlayer = Player.m_localPlayer;
		List<SeekerTarget> list = m_targets ?? SeekerTargets.Listed(localPlayer);
		float radius = (((Object)(object)localPlayer != (Object)null) ? SeekerRod.CurrentRadius(localPlayer) : 0f);
		Dictionary<SeekerTarget, int> counts = (((Object)(object)localPlayer != (Object)null) ? SeekerTargets.CountAll(list, ((Component)localPlayer).transform.position, radius) : new Dictionary<SeekerTarget, int>());
		List<RadialMenuElement> list2 = new List<RadialMenuElement>();
		foreach (SeekerTarget item in list)
		{
			try
			{
				list2.Add(CreateElement(radial, item, counts));
			}
			catch (Exception ex)
			{
				SeekerPlugin.Log.LogError((object)("Picker: could not create the element for '" + item.Key + "': " + ex));
			}
		}
		radial.ConstructRadial(list2);
	}

	private static RadialMenuElement CreateElement(RadialBase radial, SeekerTarget target, Dictionary<SeekerTarget, int> counts)
	{
		GroupElement val = Object.Instantiate<GroupElement>(RadialData.SO.GroupElement);
		val.Init((IRadialConfig)(object)new ElementConfig(target), (IRadialConfig)null, radial);
		((RadialMenuElement)val).Interact = delegate
		{
			SeekerRod.Select(target);
			return true;
		};
		((RadialMenuElement)val).CloseOnInteract = () => true;
		counts.TryGetValue(target, out var value);
		string text = ((value > 0) ? (value.ToString(CultureInfo.InvariantCulture) + " " + SeekerPlugin.Localize("$valseeker_nearby")) : SeekerPlugin.Localize("$valseeker_none_nearby"));
		if (SetSubTitle != null)
		{
			SetSubTitle.Invoke(val, new object[1] { text });
		}
		return (RadialMenuElement)(object)val;
	}
}
internal static class SeekerRod
{
	[HarmonyPatch(typeof(Player), "SetControls")]
	private static class Player_SetControls_Patch
	{
		private static void Prefix(Player __instance, ref bool attack, ref bool attackHold, ref bool block, ref bool blockHold)
		{
			if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && RodEquipped(__instance))
			{
				attack = false;
				attackHold = false;
				block = false;
				blockHold = false;
			}
		}
	}

	[HarmonyPatch(typeof(Player), "AlwaysRotateCamera")]
	private static class Player_AlwaysRotateCamera_Patch
	{
		private static void Postfix(Player __instance, ref bool __result)
		{
			if (!__result && ShouldFace((Character)(object)__instance, out var _))
			{
				__result = true;
			}
		}
	}

	[HarmonyPatch(typeof(Character), "UpdateRotation")]
	private static class Character_UpdateRotation_Patch
	{
		private static void Prefix(Character __instance, out Quaternion? __state)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			__state = null;
			if (ShouldFace(__instance, out var yaw))
			{
				__state = LookYaw.Invoke(__instance);
				LookYaw.Invoke(__instance) = yaw;
			}
		}

		private static void Postfix(Character __instance, Quaternion? __state)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (__state.HasValue)
			{
				LookYaw.Invoke(__instance) = __state.Value;
			}
		}
	}

	private const string SelectionKey = "valseeker.target";

	private const float BeamLength = 1.6f;

	private static readonly MethodInfo StopEmoteMethod = AccessTools.Method(typeof(Character), "StopEmote", (Type[])null, (Type[])null);

	private static readonly FieldRef<Character, Quaternion> LookYaw = AccessTools.FieldRefAccess<Character, Quaternion>("m_lookYaw");

	public static SkillType Skill;

	private static bool s_equipped;

	private static bool s_pointing;

	private static bool s_hasTarget;

	private static SeekerTarget s_target;

	private static Vector3 s_targetPosition;

	private static ZDOID s_targetId;

	private static float s_targetDistance;

	private static float s_radius;

	private static float s_holdTimer;

	private static float s_scanTimer;

	private static float s_pulseTimer;

	private static float s_pulseStrength;

	private static float s_xpTimer;

	private static float s_emoteTimer;

	private static readonly HashSet<ZDOID> s_found = new HashSet<ZDOID>();

	private static SE_Finder s_finder;

	private static ObjectDB s_finderSource;

	public static bool Facing
	{
		get
		{
			if (s_pointing)
			{
				return s_hasTarget;
			}
			return false;
		}
	}

	public static bool Pointing => s_pointing;

	public static bool AttackHeld()
	{
		if (!ZInput.GetButton("Attack"))
		{
			return ZInput.GetButton("JoyAttack");
		}
		return true;
	}

	private static bool BlockHeld()
	{
		if (!ZInput.GetButton("Block"))
		{
			return ZInput.GetButton("JoyBlock");
		}
		return true;
	}

	public static bool IsRod(ItemData item)
	{
		if (item != null && item.m_shared != null)
		{
			return item.m_shared.m_name == "$item_seekerrod";
		}
		return false;
	}

	public static bool RodEquipped(Player player)
	{
		if ((Object)(object)player != (Object)null)
		{
			return IsRod(((Humanoid)player).GetCurrentWeapon());
		}
		return false;
	}

	private static bool CanTakeInput()
	{
		if (!InventoryGui.IsVisible() && !Menu.IsVisible() && !Console.IsVisible() && !TextInput.IsVisible() && !Minimap.IsOpen() && !StoreGui.IsVisible() && !Hud.IsPieceSelectionVisible())
		{
			if (!((Object)(object)Chat.instance == (Object)null))
			{
				return !Chat.instance.HasFocus();
			}
			return true;
		}
		return false;
	}

	public static SeekerTarget SelectedTarget(Player player)
	{
		ItemData val = (((Object)(object)player != (Object)null) ? ((Humanoid)player).GetCurrentWeapon() : null);
		if (!IsRod(val) || val.m_customData == null)
		{
			return null;
		}
		if (!val.m_customData.TryGetValue("valseeker.target", out var value))
		{
			return null;
		}
		return SeekerTargets.Find(value);
	}

	public static SeekerTarget SelectedTarget(ItemData rod)
	{
		if (rod == null || rod.m_customData == null || !rod.m_customData.TryGetValue("valseeker.target", out var value))
		{
			return null;
		}
		return SeekerTargets.Find(value);
	}

	public static void Select(SeekerTarget target)
	{
		Player localPlayer = Player.m_localPlayer;
		ItemData val = (((Object)(object)localPlayer != (Object)null) ? ((Humanoid)localPlayer).GetCurrentWeapon() : null);
		if (IsRod(val) && target != null)
		{
			if (val.m_customData == null)
			{
				val.m_customData = new Dictionary<string, string>();
			}
			val.m_customData["valseeker.target"] = target.Key;
			s_hasTarget = false;
			s_scanTimer = 0f;
			((Character)localPlayer).Message((MessageType)1, SeekerPlugin.Localize("$valseeker_selected").Replace("{0}", target.LocalizedName), 0, target.Icon, false);
		}
	}

	public static float CurrentRadius(Player player)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		float num = (((Object)(object)player != (Object)null) ? ((Character)player).GetSkills().GetSkillLevel(Skill) : 0f);
		float num2 = SeekerPlugin.RadiusBase.Value + SeekerPlugin.RadiusPerLevel.Value * num;
		return Mathf.Min(new float[3]
		{
			num2,
			SeekerPlugin.MaxRadius.Value,
			KnownWorldRadius()
		});
	}

	private static float KnownWorldRadius()
	{
		//IL_0015: 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)
		int num = 2;
		try
		{
			if ((Object)(object)ZNet.instance != (Object)null)
			{
				SimulationDistance syncedSimulationDistance = ZNet.instance.GetSyncedSimulationDistance();
				num = Mathf.Max(1, ((SimulationDistance)(ref syncedSimulationDistance)).NearSimulationDistance);
			}
		}
		catch (Exception)
		{
		}
		return (float)num * 64f;
	}

	public static void Update(float dt)
	{
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || !RodEquipped(localPlayer))
		{
			if (s_pointing)
			{
				StopPointing(localPlayer);
			}
			s_equipped = false;
			s_holdTimer = 0f;
			return;
		}
		if (!s_equipped)
		{
			s_equipped = true;
			s_holdTimer = 0f;
			if (SeekerPlugin.ShowHints.Value)
			{
				((Character)localPlayer).Message((MessageType)1, SeekerPlugin.Localize("$valseeker_hint"), 0, RodAssets.Icon, false);
			}
		}
		if (Hud.InRadial() || !CanTakeInput())
		{
			if (s_pointing)
			{
				StopPointing(localPlayer);
			}
			s_holdTimer = 0f;
			return;
		}
		bool flag = AttackHeld();
		bool flag2 = BlockHeld();
		if (flag)
		{
			if (s_holdTimer >= 0f)
			{
				s_holdTimer += dt;
				if (s_holdTimer >= SeekerPlugin.HoldToOpen.Value)
				{
					s_holdTimer = -1f;
					if (s_pointing)
					{
						StopPointing(localPlayer);
					}
					if (!SeekerRadial.Open(localPlayer, out var problem))
					{
						((Character)localPlayer).Message((MessageType)2, SeekerPlugin.Localize(problem), 0, (Sprite)null, false);
					}
					return;
				}
			}
		}
		else
		{
			s_holdTimer = 0f;
		}
		if (flag2 && !flag)
		{
			if (!s_pointing)
			{
				StartPointing(localPlayer);
			}
			UpdatePointing(localPlayer, dt);
		}
		else if (s_pointing)
		{
			StopPointing(localPlayer);
		}
	}

	private static void StartPointing(Player player)
	{
		s_pointing = true;
		s_hasTarget = false;
		s_scanTimer = 0f;
		s_pulseTimer = 0f;
		s_pulseStrength = 0f;
		s_xpTimer = 0f;
		s_emoteTimer = 0f;
		s_target = SelectedTarget(player);
		if (s_target == null)
		{
			((Character)player).Message((MessageType)2, SeekerPlugin.Localize("$valseeker_choose"), 0, (Sprite)null, false);
		}
	}

	private static void StopPointing(Player player)
	{
		s_pointing = false;
		s_hasTarget = false;
		s_pulseStrength = 0f;
		if ((Object)(object)player != (Object)null && ((Character)player).InEmote() && StopEmoteMethod != null)
		{
			StopEmoteMethod.Invoke(player, null);
		}
	}

	private static void UpdatePointing(Player player, float dt)
	{
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: 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)
		s_target = SelectedTarget(player);
		if (s_target == null)
		{
			s_hasTarget = false;
			return;
		}
		s_radius = CurrentRadius(player);
		s_scanTimer -= dt;
		if (s_scanTimer <= 0f)
		{
			s_scanTimer = Mathf.Max(0.1f, SeekerPlugin.ScanInterval.Value);
			Scan(player);
		}
		if (!s_hasTarget)
		{
			s_pulseStrength = Mathf.MoveTowards(s_pulseStrength, 0f, dt);
			return;
		}
		s_targetDistance = Vector3.Distance(((Component)player).transform.position, s_targetPosition);
		s_emoteTimer -= dt;
		if (s_emoteTimer <= 0f && !((Character)player).InEmote() && ((Character)player).GetMoveDir() == Vector3.zero)
		{
			s_emoteTimer = 0.6f;
			player.StartEmote("point", false);
		}
		UpdatePulse(player, dt);
		UpdateSkill(player, dt);
	}

	private static void Scan(Player player)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: 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)
		Vector3 point;
		float distance;
		ZDO val = SeekerTargets.FindClosest(s_target, ((Component)player).transform.position, s_radius, out point, out distance);
		if (val == null)
		{
			s_hasTarget = false;
			return;
		}
		if (!s_hasTarget || val.m_uid != s_targetId)
		{
			s_pulseTimer = 0f;
		}
		s_hasTarget = true;
		s_targetId = val.m_uid;
		s_targetPosition = point;
		s_targetDistance = distance;
	}

	private static void UpdatePulse(Player player, float dt)
	{
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		SE_Finder val = Finder();
		float num = (((Object)(object)val != (Object)null) ? val.m_closeFrequency : 0.5f);
		float num2 = (((Object)(object)val != (Object)null) ? val.m_distantFrequency : 2f);
		float num3 = Mathf.Lerp(num, num2, Mathf.Clamp01(s_targetDistance / Mathf.Max(1f, s_radius)));
		s_pulseStrength = Mathf.MoveTowards(s_pulseStrength, 0f, dt * 2.5f);
		s_pulseTimer += dt;
		if (s_pulseTimer < num3)
		{
			return;
		}
		s_pulseTimer = 0f;
		s_pulseStrength = 1f;
		if (!((Object)(object)val == (Object)null) && SeekerPlugin.Sounds.Value)
		{
			float num4 = s_targetDistance / Mathf.Max(1f, s_radius);
			EffectList val2 = ((num4 < 0.25f) ? val.m_pingEffectNear : ((num4 < 0.6f) ? val.m_pingEffectMed : val.m_pingEffectFar));
			if (val2 != null)
			{
				val2.Create(((Component)player).transform.position, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID));
			}
		}
	}

	private static SE_Finder Finder()
	{
		ObjectDB instance = ObjectDB.instance;
		if ((Object)(object)instance == (Object)null)
		{
			return null;
		}
		if ((Object)(object)s_finderSource == (Object)(object)instance)
		{
			return s_finder;
		}
		s_finderSource = instance;
		s_finder = null;
		foreach (StatusEffect statusEffect in instance.m_StatusEffects)
		{
			SE_Finder val = (SE_Finder)(object)((statusEffect is SE_Finder) ? statusEffect : null);
			if ((Object)(object)val != (Object)null)
			{
				s_finder = val;
				break;
			}
		}
		return s_finder;
	}

	private static void UpdateSkill(Player player, float dt)
	{
		//IL_0066: 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_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		s_xpTimer += dt;
		if (s_xpTimer >= SeekerPlugin.XpTickSeconds.Value)
		{
			s_xpTimer = 0f;
			if (SeekerPlugin.XpPerTick.Value > 0f)
			{
				((Character)player).RaiseSkill(Skill, SeekerPlugin.XpPerTick.Value);
			}
		}
		if (s_targetDistance <= SeekerPlugin.FindDistance.Value && s_found.Add(s_targetId))
		{
			if (s_found.Count > 1000)
			{
				s_found.Clear();
				s_found.Add(s_targetId);
			}
			if (SeekerPlugin.XpPerFind.Value > 0f)
			{
				((Character)player).RaiseSkill(Skill, SeekerPlugin.XpPerFind.Value);
			}
			((Character)player).Message((MessageType)2, SeekerPlugin.Localize("$valseeker_found").Replace("{0}", s_target.LocalizedName), 0, (Sprite)null, false);
		}
	}

	public static bool ShouldFace(Character character, out Quaternion yaw)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: 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)
		yaw = Quaternion.identity;
		if (!Facing || (Object)(object)character == (Object)null || (Object)(object)character != (Object)(object)Player.m_localPlayer)
		{
			return false;
		}
		Vector3 val = s_targetPosition - ((Component)character).transform.position;
		val.y = 0f;
		if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
		{
			return false;
		}
		yaw = Quaternion.LookRotation(((Vector3)(ref val)).normalized);
		return true;
	}

	public static bool AimDirection(Vector3 from, out Vector3 direction)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: 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_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		direction = Vector3.zero;
		Player localPlayer = Player.m_localPlayer;
		if (!Facing || (Object)(object)localPlayer == (Object)null || (!((Character)localPlayer).InEmote() && !(((Character)localPlayer).GetMoveDir() == Vector3.zero)))
		{
			return false;
		}
		direction = s_targetPosition - from;
		if (((Vector3)(ref direction)).sqrMagnitude < 0.01f)
		{
			return false;
		}
		((Vector3)(ref direction)).Normalize();
		return true;
	}

	public static bool TipState(out Color color, out float intensity, out Vector3 direction, out bool beam)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: 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_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: 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_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: 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)
		//IL_00b9: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
		color = RodAssets.IdleGlow;
		intensity = 0.25f;
		direction = Vector3.zero;
		beam = false;
		if (!s_pointing)
		{
			return false;
		}
		if (s_target == null)
		{
			intensity = 0.15f + 0.1f * Mathf.PingPong(Time.time, 1f);
			return true;
		}
		color = s_target.Color;
		if (!s_hasTarget)
		{
			intensity = 0.2f + 0.15f * Mathf.PingPong(Time.time * 0.8f, 1f);
			return true;
		}
		Player localPlayer = Player.m_localPlayer;
		Vector3 val = (((Object)(object)localPlayer != (Object)null) ? ((Component)localPlayer).transform.position : Vector3.zero);
		Vector3 val2 = s_targetPosition - val;
		direction = ((Vector3)(ref val2)).normalized;
		intensity = 0.4f + 0.6f * s_pulseStrength;
		beam = SeekerPlugin.Beam.Value;
		return true;
	}

	public static string HudText(Player player)
	{
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		if (!s_pointing || (Object)(object)player != (Object)(object)Player.m_localPlayer)
		{
			return null;
		}
		if (s_target == null)
		{
			return "<color=#ff9040>" + SeekerPlugin.Localize("$valseeker_choose") + "</color>";
		}
		if (!s_hasTarget)
		{
			return s_target.LocalizedName + ": <color=#ff9040>" + SeekerPlugin.Localize("$valseeker_nothing").Replace("{0}", Mathf.RoundToInt(s_radius).ToString(CultureInfo.InvariantCulture)) + "</color>";
		}
		string text = s_target.LocalizedName + ": <color=#80ff80>" + Mathf.RoundToInt(s_targetDistance).ToString(CultureInfo.InvariantCulture) + " m</color>";
		float num = s_targetPosition.y - ((Component)player).transform.position.y;
		float num2 = default(float);
		if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(s_targetPosition, ref num2) && s_targetPosition.y < num2 - 1.5f)
		{
			text = text + " (" + SeekerPlugin.Localize("$valseeker_buried") + ")";
		}
		else if (num < -4f)
		{
			text = text + " (" + SeekerPlugin.Localize("$valseeker_below") + ")";
		}
		else if (num > 4f)
		{
			text = text + " (" + SeekerPlugin.Localize("$valseeker_above") + ")";
		}
		return text;
	}
}
public class SeekerVisual : MonoBehaviour
{
	private const float MaxBend = 50f;

	private Quaternion m_restRotation;

	private Player m_owner;

	private float m_ownerTimer;

	private void Awake()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		m_restRotation = ((Component)this).transform.localRotation;
	}

	private void LateUpdate()
	{
		//IL_0071: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: 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)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
		m_ownerTimer -= Time.deltaTime;
		if (m_ownerTimer <= 0f)
		{
			m_ownerTimer = 1f;
			m_owner = ((Component)this).GetComponentInParent<Player>();
		}
		if ((Object)(object)m_owner == (Object)null || (Object)(object)m_owner != (Object)(object)Player.m_localPlayer || !SeekerRod.AimDirection(((Component)this).transform.position, out var direction))
		{
			((Component)this).transform.localRotation = m_restRotation;
			return;
		}
		Transform val = (((Object)(object)((Component)this).transform.parent != (Object)null) ? ((Component)this).transform.parent.parent : null);
		if ((Object)(object)val != (Object)null && (Object)(object)val.parent != (Object)null)
		{
			Vector3 val2 = val.position - val.parent.position;
			if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f)
			{
				direction = Vector3.RotateTowards(((Vector3)(ref val2)).normalized, direction, 0.87266463f, 0f);
			}
		}
		((Component)this).transform.rotation = Quaternion.FromToRotation(Vector3.up, direction);
	}
}
public class SeekerTip : MonoBehaviour
{
	private const float LightScale = 2.2f;

	private Light m_light;

	private Renderer m_renderer;

	private MaterialPropertyBlock m_block;

	private LineRenderer m_beam;

	private Player m_owner;

	private float m_ownerTimer;

	private bool m_hasEmission;

	private bool m_hasColor;

	private const float BeamLength = 1.6f;

	private void Awake()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		m_light = ((Component)this).GetComponent<Light>();
		m_renderer = ((Component)this).GetComponent<Renderer>();
		m_block = new MaterialPropertyBlock();
		Material val = (((Object)(object)m_renderer != (Object)null) ? m_renderer.sharedMaterial : null);
		m_hasEmission = (Object)(object)val != (Object)null && val.HasProperty("_EmissionColor");
		m_hasColor = (Object)(object)val != (Object)null && val.HasProperty("_Color");
	}

	private void Update()
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: 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_007b: Unknown result type (might be due to invalid IL or missing references)
		m_ownerTimer -= Time.deltaTime;
		if (m_ownerTimer <= 0f)
		{
			m_ownerTimer = 1f;
			m_owner = ((Component)this).GetComponentInParent<Player>();
		}
		Color color = RodAssets.IdleGlow;
		float intensity = 0.25f;
		Vector3 direction = Vector3.zero;
		bool beam = false;
		if ((Object)(object)m_owner != (Object)null && (Object)(object)m_owner == (Object)(object)Player.m_localPlayer)
		{
			SeekerRod.TipState(out color, out intensity, out direction, out beam);
		}
		Apply(color, intensity, direction, beam);
	}

	private void Apply(Color color, float intensity, Vector3 direction, bool beam)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: 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_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)m_light != (Object)null)
		{
			m_light.color = color;
			m_light.intensity = intensity * 2.2f;
			m_light.range = 3f + 5f * intensity;
		}
		if ((Object)(object)m_renderer != (Object)null)
		{
			m_renderer.GetPropertyBlock(m_block);
			if (m_hasEmission)
			{
				m_block.SetColor("_EmissionColor", color * (0.6f + 4f * intensity));
			}
			if (m_hasColor)
			{
				m_block.SetColor("_Color", Color.Lerp(Color.white, color, 0.5f));
			}
			m_renderer.SetPropertyBlock(m_block);
		}
		if (!beam)
		{
			if ((Object)(object)m_beam != (Object)null)
			{
				((Renderer)m_beam).enabled = false;
			}
		}
		else if (!((Object)(object)m_beam == (Object)null) || CreateBeam())
		{
			((Renderer)m_beam).enabled = true;
			Vector3 position = ((Component)this).transform.position;
			m_beam.SetPosition(0, position);
			m_beam.SetPosition(1, position + direction * 1.6f);
			Color startColor = default(Color);
			((Color)(ref startColor))..ctor(color.r, color.g, color.b, 0.45f + 0.5f * intensity);
			m_beam.startColor = startColor;
			m_beam.endColor = new Color(color.r, color.g, color.b, 0f);
		}
	}

	private bool CreateBeam()
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Expected O, but got Unknown
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Expected O, but got Unknown
		Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Particles/Standard Unlit") ?? Shader.Find("Legacy Shaders/Particles/Alpha Blended");
		if ((Object)(object)val == (Object)null)
		{
			return false;
		}
		GameObject val2 = new GameObject("valseeker_beam");
		val2.transform.SetParent(((Component)this).transform, false);
		m_beam = val2.AddComponent<LineRenderer>();
		m_beam.useWorldSpace = true;
		m_beam.positionCount = 2;
		m_beam.startWidth = 0.035f;
		m_beam.endWidth = 0.005f;
		m_beam.numCapVertices = 3;
		((Renderer)m_beam).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)m_beam).receiveShadows = false;
		((Renderer)m_beam).material = new Material(val);
		return true;
	}
}
internal class SeekerTarget
{
	public string Key;

	public string Name;

	public string IconItem;

	public Color Color;

	public string[] Prefabs;

	public readonly HashSet<int> Hashes = new HashSet<int>();

	public Sprite Icon;

	public string KnownToken;

	public string LocalizedName => SeekerPlugin.Localize(Name);

	public bool IsKnown(Player player)
	{
		if ((Object)(object)player != (Object)null && KnownToken != null)
		{
			return player.IsKnownMaterial(KnownToken);
		}
		return false;
	}
}
internal class DepositLayout
{
	private enum Kind
	{
		Point,
		MineRock,
		MineRock5
	}

	private static readonly int PickedHash = ZDOVars.s_picked;

	private static readonly int HealthHash = ZDOVars.s_health;

	private static readonly Dictionary<int, DepositLayout> s_cache = new Dictionary<int, DepositLayout>();

	private static ZNetScene s_cacheSource;

	private static readonly List<int> s_indices = new List<int>();

	private Kind m_kind;

	private Vector3[] m_parts = (Vector3[])(object)new Vector3[0];

	private string[] m_healthKeys = new string[0];

	private float m_fullHealth;

	public static DepositLayout Of(int prefabHash)
	{
		ZNetScene instance = ZNetScene.instance;
		if ((Object)(object)s_cacheSource != (Object)(object)instance)
		{
			s_cache.Clear();
			s_cacheSource = instance;
		}
		if (!s_cache.TryGetValue(prefabHash, out var value))
		{
			value = Build(((Object)(object)instance != (Object)null) ? instance.GetPrefab(prefabHash) : null);
			s_cache[prefabHash] = value;
		}
		return value;
	}

	private static DepositLayout Build(GameObject prefab)
	{
		DepositLayout depositLayout = new DepositLayout
		{
			m_kind = Kind.Point
		};
		if ((Object)(object)prefab == (Object)null)
		{
			return depositLayout;
		}
		MineRock5 component = prefab.GetComponent<MineRock5>();
		MineRock component2 = prefab.GetComponent<MineRock>();
		if ((Object)(object)component != (Object)null)
		{
			depositLayout.m_kind = Kind.MineRock5;
			depositLayout.m_parts = PartCenters(prefab.transform, prefab);
		}
		else if ((Object)(object)component2 != (Object)null)
		{
			depositLayout.m_kind = Kind.MineRock;
			depositLayout.m_fullHealth = component2.m_health;
			depositLayout.m_parts = PartCenters(prefab.transform, ((Object)(object)component2.m_areaRoot != (Object)null) ? component2.m_areaRoot : prefab);
			depositLayout.m_healthKeys = new string[depositLayout.m_parts.Length];
			for (int i = 0; i < depositLayout.m_healthKeys.Length; i++)
			{
				depositLayout.m_healthKeys[i] = "Health" + i;
			}
		}
		SeekerPlugin.Log.LogDebug((object)("Deposit layout " + ((Object)prefab).name + ": " + depositLayout.m_kind.ToString() + ", " + depositLayout.m_parts.Length + " parts"));
		return depositLayout;
	}

	private static Vector3[] PartCenters(Transform root, GameObject areaRoot)
	{
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: 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)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: 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)
		List<Vector3> list = new List<Vector3>();
		Collider[] componentsInChildren = areaRoot.GetComponentsInChildren<Collider>(true);
		foreach (Collider val in componentsInChildren)
		{
			if (ActiveWithin(root, ((Component)val).transform))
			{
				BoxCollider val2 = (BoxCollider)(object)((val is BoxCollider) ? val : null);
				SphereCollider val3 = (SphereCollider)(object)((val is SphereCollider) ? val : null);
				CapsuleCollider val4 = (CapsuleCollider)(object)((val is CapsuleCollider) ? val : null);
				MeshCollider val5 = (MeshCollider)(object)((val is MeshCollider) ? val : null);
				Vector3 val6;
				if ((Object)(object)val2 != (Object)null)
				{
					val6 = val2.center;
				}
				else if ((Object)(object)val3 != (Object)null)
				{
					val6 = val3.center;
				}
				else if ((Object)(object)val4 != (Object)null)
				{
					val6 = val4.center;
				}
				else if ((Object)(object)val5 != (Object)null && (Object)(object)val5.sharedMesh != (Object)null)
				{
					Bounds bounds = val5.sharedMesh.bounds;
					val6 = ((Bounds)(ref bounds)).center;
				}
				else
				{
					val6 = Vector3.zero;
				}
				list.Add(root.InverseTransformPoint(((Component)val).transform.TransformPoint(val6)));
			}
		}
		return list.ToArray();
	}

	private static bool ActiveWithin(Transform root, Transform t)
	{
		while ((Object)(object)t != (Object)null && (Object)(object)t != (Object)(object)root)
		{
			if (!((Component)t).gameObject.activeSelf)
			{
				return false;
			}
			t = t.parent;
		}
		return true;
	}

	public bool ClosestLivePart(ZDO zdo, Vector3 from, out Vector3 point, out float sqrDistance)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: 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_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: 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)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: 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)
		//IL_00a1: Expected O, but got Unknown
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = (point = zdo.GetPosition());
		Vector3 val2 = val - from;
		sqrDistance = ((Vector3)(ref val2)).sqrMagnitude;
		if (m_kind == Kind.Point || m_parts.Length == 0)
		{
			return !zdo.GetBool(PickedHash, false);
		}
		s_indices.Clear();
		if (m_kind == Kind.MineRock5)
		{
			string text = zdo.GetString(HealthHash, "");
			if (text.Length == 0)
			{
				for (int i = 0; i < m_parts.Length; i++)
				{
					s_indices.Add(i);
				}
			}
			else
			{
				try
				{
					ZPackage val3 = new ZPackage(text);
					int num = val3.ReadInt();
					for (int j = 0; j < num && j < m_parts.Length; j++)
					{
						if (val3.ReadSingle() > 0f)
						{
							s_indices.Add(j);
						}
					}
				}
				catch (Exception)
				{
					s_indices.Clear();
					for (int k = 0; k < m_parts.Length; k++)
					{
						s_indices.Add(k);
					}
				}
			}
		}
		else
		{
			for (int l = 0; l < m_parts.Length; l++)
			{
				if (zdo.GetFloat(m_healthKeys[l], m_fullHealth) > 0f)
				{
					s_i