Decompiled source of ContentPlus v0.5.0

BepInEx/plugins/FieldQuests/InfernoProtocol.FieldQuests.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.Json;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Game.AI;
using Game.Combat;
using Game.Data;
using Game.LevelOperations;
using Game.PlayerOperations;
using Game.UI;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using SaveSystem;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("FrankMods")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Quest board, XP progression and unlockable equipment finishes for Inferno Protocol.")]
[assembly: AssemblyFileVersion("0.5.0.0")]
[assembly: AssemblyInformationalVersion("0.5.0+477d00f8c6e6102e4d9ad948d3169f90685e9781")]
[assembly: AssemblyProduct("ContentPlus")]
[assembly: AssemblyTitle("InfernoProtocol.FieldQuests")]
[assembly: AssemblyVersion("0.5.0.0")]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.All)]
	internal sealed class NullableAttribute : Attribute
	{
		public NullableAttribute(byte value)
		{
		}

		public NullableAttribute(byte[] value)
		{
		}
	}
	[AttributeUsage(AttributeTargets.All)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public NullableContextAttribute(byte value)
		{
		}
	}
}
namespace InfernoProtocol.FieldQuests
{
	internal static class BoardHouseSite
	{
		internal static bool TryFind(out Vector3 position, out Vector3 facing, out string description)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_006a: 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_008a: 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_00a5: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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)
			//IL_0116: 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)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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_0128: 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_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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_01a5: 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_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: 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_0239: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = default(Vector3);
			val = (position = (facing = val));
			description = "Waiting for the outdoor trader and porch";
			foreach (TradeController item in Object.FindObjectsOfType<TradeController>())
			{
				if ((Object)(object)item == (Object)null || (Object)(object)((Component)item).GetComponentInParent<Interior>() != (Object)null || (Object)(object)((Component)item).GetComponentInParent<MazeLayer>() != (Object)null)
				{
					continue;
				}
				Vector3 position2 = ((Component)item).transform.position;
				if ((Object)(object)Player.localPlayer == (Object)null || Player.isInMaze || !BoardSiteRules.IsOutdoorAnchor(position2.y - ((Component)Player.localPlayer).transform.position.y, Vector3.Distance(position2, ((Component)Player.localPlayer).transform.position)))
				{
					continue;
				}
				if (!TryHouse(position2, out var center, out var outward, out var landmark))
				{
					description = $"Outdoor trader at {position2}; waiting for nearby house geometry";
					continue;
				}
				val = Vector3.Cross(outward, Vector3.up);
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				float num = BoardSiteRules.OppositeTraderOffset(Vector3.Dot(position2 - center, normalized));
				float num2 = Vector3.Dot(position2 - center, outward);
				float[] array = new float[3] { 0.65f, 1f, 1.35f };
				foreach (float num3 in array)
				{
					float[] array2 = new float[3] { 0f, 0.35f, 0.7f };
					foreach (float num4 in array2)
					{
						float num5 = num + num4;
						if (BoardSiteRules.ClearsEntrance(num5))
						{
							Vector3 candidate = center + normalized * num5 + outward * (num2 + num3);
							candidate.y = position2.y;
							if (TryGround(candidate, outward, out var feet))
							{
								position = feet;
								facing = feet + outward;
								description = $"outdoor house front-right porch opposite trader at {position2}; {landmark}; house center={center}";
								return true;
							}
						}
					}
				}
				description = "Outdoor porch found (" + landmark + "), but the marked side has no clear board footprint";
			}
			return false;
		}

		private static bool TryHouse(Vector3 trader, out Vector3 center, out Vector3 outward, out string landmark)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_002b: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: 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_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_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: 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_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: 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_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			center = (outward = default(Vector3));
			landmark = "";
			HashSet<int> hashSet = new HashSet<int>();
			float num = float.MaxValue;
			foreach (Collider item in (Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(trader + Vector3.up, 12f, -5, (QueryTriggerInteraction)1))
			{
				Transform val = ((Component)item).transform;
				while ((Object)(object)val != (Object)null)
				{
					if (hashSet.Add(((Object)val).GetInstanceID()))
					{
						string text = ((Object)val).name.ToLowerInvariant();
						if ((text.Contains("house") || text.Contains("cabin") || text.Contains("building") || text.Contains("shop") || text.Contains("trade")) && !((Object)(object)((Component)val).GetComponentInParent<Interior>() != (Object)null) && !((Object)(object)((Component)val).GetComponentInParent<MazeLayer>() != (Object)null))
						{
							bool flag = false;
							Bounds val2 = default(Bounds);
							foreach (Renderer componentsInChild in ((Component)val).GetComponentsInChildren<Renderer>())
							{
								if (componentsInChild.enabled)
								{
									if (!flag)
									{
										val2 = componentsInChild.bounds;
										flag = true;
									}
									else
									{
										((Bounds)(ref val2)).Encapsulate(componentsInChild.bounds);
									}
								}
							}
							if (flag && !(((Bounds)(ref val2)).size.y < 2.5f) && !(((Bounds)(ref val2)).size.y > 15f) && !(((Bounds)(ref val2)).size.x > 30f) && !(((Bounds)(ref val2)).size.z > 30f) && !(Mathf.Max(((Bounds)(ref val2)).size.x, ((Bounds)(ref val2)).size.z) < 4f))
							{
								float num2 = Vector3.Distance(((Bounds)(ref val2)).ClosestPoint(trader), trader);
								if (!(num2 > 7f) && !(num2 >= num))
								{
									Vector3 val3 = trader - ((Bounds)(ref val2)).center;
									val3.y = 0f;
									Vector3 forward = val.forward;
									forward.y = 0f;
									((Vector3)(ref forward)).Normalize();
									Vector3 right = val.right;
									right.y = 0f;
									((Vector3)(ref right)).Normalize();
									Vector3 val4 = ((Mathf.Abs(Vector3.Dot(val3, forward)) >= Mathf.Abs(Vector3.Dot(val3, right))) ? forward : right);
									if (!(((Vector3)(ref val4)).sqrMagnitude < 0.5f))
									{
										if (Vector3.Dot(val4, val3) < 0f)
										{
											val4 = -val4;
										}
										center = ((Bounds)(ref val2)).center;
										center.y = trader.y;
										outward = val4;
										landmark = ((Object)val).name;
										num = num2;
									}
								}
							}
						}
					}
					val = val.parent;
				}
			}
			if (num < float.MaxValue)
			{
				return true;
			}
			foreach (HandledPhysicalDoor item2 in Object.FindObjectsOfType<HandledPhysicalDoor>())
			{
				if ((Object)(object)((Component)item2).GetComponentInParent<Interior>() != (Object)null || (Object)(object)((Component)item2).GetComponentInParent<MazeLayer>() != (Object)null)
				{
					continue;
				}
				Vector3 val5;
				if (!((Object)(object)item2.objectRenderer != (Object)null))
				{
					val5 = ((Component)item2).transform.position;
				}
				else
				{
					Bounds bounds = item2.objectRenderer.bounds;
					val5 = ((Bounds)(ref bounds)).center;
				}
				Vector3 val6 = val5;
				float num3 = Vector3.Distance(val6, trader);
				if (num3 > 9f || num3 >= num || Mathf.Abs(val6.y - trader.y) > 3f)
				{
					continue;
				}
				Vector3 val7 = ((Component)item2).transform.forward;
				val7.y = 0f;
				if (!(((Vector3)(ref val7)).sqrMagnitude < 0.1f))
				{
					((Vector3)(ref val7)).Normalize();
					if (Vector3.Dot(val7, trader - val6) < 0f)
					{
						val7 = -val7;
					}
					center = val6;
					center.y = trader.y;
					outward = val7;
					landmark = "outdoor physical door " + ((Object)item2).name;
					num = num3;
				}
			}
			return num < float.MaxValue;
		}

		private static bool TryGround(Vector3 candidate, Vector3 outward, out Vector3 feet)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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)
			//IL_0020: 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)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_009a: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_011d: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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_0149: 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_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: 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_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: 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_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: 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_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: 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_01f7: Unknown result type (might be due to invalid IL or missing references)
			feet = default(Vector3);
			List<RaycastHit> list = new List<RaycastHit>();
			foreach (RaycastHit item in (Il2CppArrayBase<RaycastHit>)(object)Physics.RaycastAll(candidate + Vector3.up * 2.5f, Vector3.down, 6f, -5, (QueryTriggerInteraction)1))
			{
				list.Add(item);
			}
			list.Sort((RaycastHit a, RaycastHit b) => Mathf.Abs(((RaycastHit)(ref a)).point.y - candidate.y).CompareTo(Mathf.Abs(((RaycastHit)(ref b)).point.y - candidate.y)));
			RaycastHit val3 = default(RaycastHit);
			foreach (RaycastHit item2 in list)
			{
				RaycastHit current2 = item2;
				if (!(((RaycastHit)(ref current2)).normal.y < 0.97f) && !(Mathf.Abs(((RaycastHit)(ref current2)).point.y - candidate.y) > 2.5f) && (!((Object)(object)((RaycastHit)(ref current2)).collider.attachedRigidbody != (Object)null) || ((RaycastHit)(ref current2)).collider.attachedRigidbody.isKinematic))
				{
					Vector3 val = ((RaycastHit)(ref current2)).point + Vector3.up * 0.04f;
					Quaternion val2 = Quaternion.LookRotation(outward);
					if (!Physics.CheckBox(val + Vector3.up * 1.2f, new Vector3(1.08f, 1.14f, 0.4f), val2, -5, (QueryTriggerInteraction)1) && Physics.Raycast(val + outward * 1.4f + Vector3.up, Vector3.down, ref val3, 2f, -5, (QueryTriggerInteraction)1) && !(Mathf.Abs(((RaycastHit)(ref val3)).point.y - val.y) > 0.3f) && !Physics.CheckCapsule(((RaycastHit)(ref val3)).point + Vector3.up * 0.4f, ((RaycastHit)(ref val3)).point + Vector3.up * 1.5f, 0.32f, -5, (QueryTriggerInteraction)1))
					{
						feet = val;
						return true;
					}
				}
			}
			return false;
		}
	}
	internal static class BoardPlacement
	{
		internal const float X = -23.165f;

		internal const float Y = 0.199f;

		internal const float Z = -20.094f;

		internal const float Yaw = 3.526f;
	}
	internal static class BoardSiteRules
	{
		internal static (float X, float Z) Offset(float outwardX, float outwardZ, float right, float front)
		{
			return (X: (0f - outwardZ) * right + outwardX * front, Z: outwardX * right + outwardZ * front);
		}

		internal static bool ClearsEntrance(float right)
		{
			return right - 1.08f >= 2f;
		}

		internal static bool IsOutdoorAnchor(float heightDifference, float distance)
		{
			if (Math.Abs(heightDifference) <= 12f)
			{
				return distance <= 100f;
			}
			return false;
		}

		internal static float OppositeTraderOffset(float traderSide)
		{
			return Math.Max(3.2f, Math.Abs(traderSide));
		}
	}
	public static class FinishPattern
	{
		public readonly struct Ink
		{
			public readonly float R;

			public readonly float G;

			public readonly float B;

			public Ink(float r, float g, float b)
			{
				R = r;
				G = g;
				B = b;
			}
		}

		private static float Hash(int x, int y)
		{
			int num = x * 374761393 + y * 668265263;
			int num2 = (num ^ (num >>> 13)) * 1274126177;
			return (float)(uint)(num2 ^ (num2 >>> 16)) / 4.2949673E+09f;
		}

		private static float Noise(float x, float y)
		{
			int num = (int)MathF.Floor(x);
			int num2 = (int)MathF.Floor(y);
			float num3 = x - (float)num;
			float num4 = y - (float)num2;
			num3 = num3 * num3 * (3f - 2f * num3);
			num4 = num4 * num4 * (3f - 2f * num4);
			float num5 = Hash(num, num2) * (1f - num3) + Hash(num + 1, num2) * num3;
			float num6 = Hash(num, num2 + 1) * (1f - num3) + Hash(num + 1, num2 + 1) * num3;
			return num5 * (1f - num4) + num6 * num4;
		}

		private static float Frac(float x)
		{
			return x - MathF.Floor(x);
		}

		public static Ink Sample(int finish, float u, float v)
		{
			switch (finish)
			{
			case 1:
			{
				float num5 = Noise(u * 15f, v * 15f) * 0.7f + Noise(u * 37f, v * 37f) * 0.3f;
				if (!(num5 < 0.36f))
				{
					if (!(num5 < 0.5f))
					{
						if (!(num5 < 0.64f))
						{
							return new Ink(0.68f, 0.65f, 0.43f);
						}
						return new Ink(0.43f, 0.49f, 0.25f);
					}
					return new Ink(0.22f, 0.32f, 0.13f);
				}
				return new Ink(0.08f, 0.12f, 0.07f);
			}
			case 2:
			{
				float num6 = Frac((u + v * 0.55f) * 9f);
				if (num6 < 0.055f)
				{
					return new Ink(0.82f, 0.91f, 0.94f);
				}
				if (Frac(v * 8f) < 0.04f)
				{
					return new Ink(0.09f, 0.16f, 0.23f);
				}
				if (!(num6 < 0.38f))
				{
					return new Ink(0.025f, 0.08f, 0.18f);
				}
				return new Ink(0.09f, 0.32f, 0.65f);
			}
			case 3:
			{
				float num8 = u * 12f;
				float num9 = v * 12f;
				float num10 = 100f;
				float num11 = 100f;
				int num12 = (int)MathF.Floor(num8);
				int num13 = (int)MathF.Floor(num9);
				for (int i = -1; i <= 1; i++)
				{
					for (int j = -1; j <= 1; j++)
					{
						float num14 = (float)(num12 + i) + Hash(num12 + i, num13 + j) - num8;
						float num15 = (float)(num13 + j) + Hash(num12 + i + 71, num13 + j + 39) - num9;
						float num16 = num14 * num14 + num15 * num15;
						if (num16 < num10)
						{
							num11 = num10;
							num10 = num16;
						}
						else if (num16 < num11)
						{
							num11 = num16;
						}
					}
				}
				float num17 = MathF.Sqrt(num11) - MathF.Sqrt(num10);
				if (!(num17 < 0.045f))
				{
					if (!(num17 < 0.095f))
					{
						return new Ink(0.065f, 0.05f, 0.045f);
					}
					return new Ink(0.42f, 0.065f, 0.02f);
				}
				return new Ink(0.96f, 0.38f, 0.06f);
			}
			case 4:
			{
				float num24 = Frac((u + v) * 14f);
				float num25 = Frac((u - v) * 14f);
				if (num24 < 0.065f || num25 < 0.065f)
				{
					return new Ink(0.75f, 0.56f, 0.24f);
				}
				if (num24 < 0.12f || num25 < 0.12f)
				{
					return new Ink(0.08f, 0.055f, 0.025f);
				}
				return new Ink(0.32f, 0.21f, 0.1f);
			}
			case 5:
			{
				float num22 = Noise(MathF.Floor(u * 48f) / 3f, MathF.Floor(v * 48f) / 3f);
				if (!(num22 < 0.35f))
				{
					if (!(num22 < 0.51f))
					{
						if (!(num22 < 0.66f))
						{
							return new Ink(0.93f, 0.95f, 0.91f);
						}
						return new Ink(0.73f, 0.8f, 0.83f);
					}
					return new Ink(0.46f, 0.57f, 0.64f);
				}
				return new Ink(0.13f, 0.21f, 0.29f);
			}
			case 6:
				if (Frac(v * 6f) < 0.075f)
				{
					return new Ink(0.72f, 0.74f, 0.69f);
				}
				if (!(Frac((u + v) * 10f) < 0.48f))
				{
					return new Ink(0.055f, 0.06f, 0.055f);
				}
				return new Ink(0.95f, 0.7f, 0.045f);
			case 7:
			{
				float num18 = Frac(u * 13f + MathF.Sin(v * 28f) * 0.24f + Noise(u * 9f, v * 19f) * 1.4f);
				if (!(num18 < 0.26f))
				{
					if (!(num18 < 0.36f))
					{
						return new Ink(0.62f, 0.3f, 0.085f);
					}
					return new Ink(0.84f, 0.68f, 0.35f);
				}
				return new Ink(0.06f, 0.045f, 0.025f);
			}
			case 8:
			{
				float num21 = Frac(u * 5f);
				if (num21 < 0.12f)
				{
					return new Ink(0.88f, 0.86f, 0.78f);
				}
				if (num21 < 0.31f)
				{
					if (((int)(u * 80f) + (int)(v * 80f)) % 2 != 0)
					{
						return new Ink(0.035f, 0.035f, 0.045f);
					}
					return new Ink(0.83f, 0.81f, 0.74f);
				}
				return new Ink(0.56f, 0.025f, 0.055f);
			}
			case 9:
			{
				float num23 = Frac(v * 12f + MathF.Sin(u * 25f) * 0.35f + MathF.Sin(u * 49f) * 0.1f);
				if (!(num23 < 0.1f))
				{
					if (!(num23 < 0.39f))
					{
						if (!(num23 < 0.52f))
						{
							return new Ink(0.025f, 0.09f, 0.17f);
						}
						return new Ink(0.08f, 0.26f, 0.36f);
					}
					return new Ink(0.055f, 0.57f, 0.61f);
				}
				return new Ink(0.86f, 0.93f, 0.86f);
			}
			case 10:
			{
				float num7 = Frac((Noise(u * 7f, v * 7f) * 0.75f + Noise(u * 19f, v * 19f) * 0.25f) * 23f);
				if (!(num7 < 0.14f))
				{
					if (!(num7 < 0.23f))
					{
						return new Ink(0.055f, 0.15f, 0.12f);
					}
					return new Ink(0.29f, 0.44f, 0.3f);
				}
				return new Ink(0.78f, 0.84f, 0.55f);
			}
			case 11:
			{
				float num19 = Frac((u + v) * 18f);
				float num20 = Frac((u - v) * 18f);
				if (num19 < 0.16f)
				{
					if (!(num20 < 0.16f))
					{
						return new Ink(0.53f, 0.36f, 0.12f);
					}
					return new Ink(0.91f, 0.72f, 0.3f);
				}
				if (num20 < 0.16f)
				{
					return new Ink(0.74f, 0.57f, 0.23f);
				}
				if (((int)(u * 100f) + (int)(v * 100f)) % 2 != 0)
				{
					return new Ink(0.11f, 0.025f, 0.18f);
				}
				return new Ink(0.22f, 0.055f, 0.31f);
			}
			case 12:
			{
				float num = u * 16f;
				float num2 = v * 16f;
				int num3 = (int)num;
				int y = (int)num2;
				float num4 = Hash(num3 * 2 + ((Frac(num) + Frac(num2) > 1f) ? 1 : 0), y);
				if (!(num4 < 0.25f))
				{
					if (!(num4 < 0.5f))
					{
						if (!(num4 < 0.75f))
						{
							return new Ink(0.88f, 0.79f, 0.58f);
						}
						return new Ink(0.73f, 0.57f, 0.36f);
					}
					return new Ink(0.52f, 0.35f, 0.21f);
				}
				return new Ink(0.23f, 0.17f, 0.12f);
			}
			default:
				return new Ink(1f, 1f, 1f);
			}
		}
	}
	internal static class FinishTextures
	{
		internal static Texture2D Create(int finish, Texture source = null)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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_0106: 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_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(512, 512, (TextureFormat)4, true);
			RenderTexture val2 = null;
			RenderTexture active = RenderTexture.active;
			try
			{
				Color32[] array = null;
				if ((Object)(object)source != (Object)null)
				{
					val2 = RenderTexture.GetTemporary(512, 512, 0, (RenderTextureFormat)0);
					Graphics.Blit(source, val2);
					RenderTexture.active = val2;
					val.ReadPixels(new Rect(0f, 0f, 512f, 512f), 0, 0);
					array = Il2CppArrayBase<Color32>.op_Implicit((Il2CppArrayBase<Color32>)(object)val.GetPixels32());
				}
				Color32[] array2 = (Color32[])(object)new Color32[262144];
				for (int i = 0; i < 512; i++)
				{
					for (int j = 0; j < 512; j++)
					{
						int num = i * 512 + j;
						FinishPattern.Ink ink = FinishPattern.Sample(finish, (float)j / 512f, (float)i / 512f);
						Color32 val3 = (Color32)((array == null) ? new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue) : array[num]);
						float num2 = ((array == null) ? 1f : (0.35f + 0.65f * ((float)(int)val3.r * 0.2126f + (float)(int)val3.g * 0.7152f + (float)(int)val3.b * 0.0722f) / 255f));
						array2[num] = new Color32((byte)(ink.R * num2 * 255f), (byte)(ink.G * num2 * 255f), (byte)(ink.B * num2 * 255f), val3.a);
					}
				}
				val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(array2));
				val.Apply(true, true);
				((Object)val).name = "FieldQuests_Finish_" + finish;
				((Texture)val).wrapMode = (TextureWrapMode)(((Object)(object)source != (Object)null) ? ((int)source.wrapMode) : 0);
				((Texture)val).filterMode = (FilterMode)2;
				return val;
			}
			catch
			{
				Object.Destroy((Object)(object)val);
				throw;
			}
			finally
			{
				RenderTexture.active = active;
				if ((Object)(object)val2 != (Object)null)
				{
					RenderTexture.ReleaseTemporary(val2);
				}
			}
		}

		internal static Texture2D Apply(Material material, int finish)
		{
			string text = (material.HasProperty("_BaseMap") ? "_BaseMap" : (material.HasProperty("_BaseColorMap") ? "_BaseColorMap" : (material.HasProperty("_MainTex") ? "_MainTex" : null)));
			if (text == null)
			{
				return null;
			}
			Texture2D val = Create(finish, material.GetTexture(text));
			material.SetTexture(text, (Texture)(object)val);
			return val;
		}
	}
	internal sealed class QuestBoard : IDisposable
	{
		private readonly List<Material> _materials = new List<Material>();

		internal GameObject Root { get; private set; }

		internal Vector3 Position => Root.transform.position;

		internal Vector3 CosmeticPosition => Root.transform.TransformPoint(new Vector3(1.65f, 0f, 0f));

		internal string WaitingReason { get; private set; } = "Preparing the quest board";

		internal bool Create(Vector3? hostPosition = null, float hostYaw = 0f)
		{
			//IL_0033: 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_0038: 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_0071: Expected O, but got Unknown
			//IL_0094: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Root != (Object)null)
			{
				return true;
			}
			Vector3 position = (Vector3)(((??)hostPosition) ?? new Vector3(-23.165f, 0.199f, -20.094f));
			float num = (hostPosition.HasValue ? hostYaw : 3.526f);
			string text = (hostPosition.HasValue ? "host-selected location" : "saved ground position (no trader lookup)");
			try
			{
				Root = new GameObject("FieldQuests_QuestBoard");
				Root.layer = 2;
				Root.SetActive(false);
				Root.transform.position = position;
				Root.transform.rotation = Quaternion.Euler(0f, num, 0f);
				Build();
				Root.SetActive(true);
				WaitingReason = "";
				ManualLogSource logSource = QuestPlugin.LogSource;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(80, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Quest Board ready at ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(Position);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; static wood-and-paper board, no NPC model or animation.");
				}
				logSource.LogInfo(val);
				return true;
			}
			catch
			{
				Dispose();
				throw;
			}
		}

		private void Build()
		{
			//IL_0010: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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_00d0: 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_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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_0156: 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_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: 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_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0506: Unknown result type (might be due to invalid IL or missing references)
			//IL_0528: Unknown result type (might be due to invalid IL or missing references)
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_060c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0613: Expected O, but got Unknown
			//IL_0652: Unknown result type (might be due to invalid IL or missing references)
			//IL_0689: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0707: Unknown result type (might be due to invalid IL or missing references)
			//IL_0731: Unknown result type (might be due to invalid IL or missing references)
			//IL_0745: Unknown result type (might be due to invalid IL or missing references)
			//IL_0788: Unknown result type (might be due to invalid IL or missing references)
			//IL_07eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b5: Unknown result type (might be due to invalid IL or missing references)
			Material material = Material(new Color(0.19f, 0.105f, 0.052f));
			Material val = Material(new Color(0.32f, 0.205f, 0.11f));
			Material val2 = Material(new Color(0.28f, 0.17f, 0.085f));
			Material material2 = Material(new Color(0.08f, 0.1f, 0.105f));
			Material val3 = Material(new Color(0.86f, 0.8f, 0.64f));
			Material val4 = Material(new Color(0.75f, 0.79f, 0.72f));
			Material val5 = Material(new Color(0.18f, 0.2f, 0.18f));
			Material val6 = Material(new Color(0.3f, 0.57f, 0.49f));
			Part("FinishCabinet", new Vector3(1.65f, 0.46f, 0f), new Vector3(0.68f, 0.92f, 0.44f), material);
			Part("FinishCounter", new Vector3(1.65f, 0.96f, 0f), new Vector3(0.82f, 0.09f, 0.57f), material2);
			Collider(new Vector3(1.65f, 0.5f, 0f), new Vector3(0.72f, 1f, 0.5f));
			for (int i = 1; i < 5; i++)
			{
				Part("FinishSample", new Vector3(1.32f + (float)i * 0.13f, 1.08f, 0f), new Vector3(0.09f, 0.16f, 0.13f), Material(SkinVisuals.ColorFor(i)));
			}
			float[] array = new float[2] { -1f, 1f };
			foreach (float num in array)
			{
				BoardText("FINISHES", new Vector3(1.65f, 0.73f, num * 0.227f), num, new Vector2(590f, 140f), 65f, new Color(0.94f, 0.9f, 0.77f));
			}
			array = new float[2] { -0.88f, 0.88f };
			foreach (float num2 in array)
			{
				Part("TimberPost", new Vector3(num2, 1.12f, 0f), new Vector3(0.16f, 2.24f, 0.18f), material);
				Part("PostFoot", new Vector3(num2, 0.15f, 0f), new Vector3(0.185f, 0.3f, 0.205f), material2);
				Collider(new Vector3(num2, 1.12f, 0f), new Vector3(0.16f, 2.24f, 0.18f));
			}
			for (int k = 0; k < 6; k++)
			{
				Part("BackingPlank", new Vector3(0f, 0.89f + (float)k * 0.185f, 0f), new Vector3(1.64f, 0.18f, 0.1f), (k % 2 == 0) ? val : val2);
			}
			Part("LowerRail", new Vector3(0f, 0.76f, 0f), new Vector3(1.98f, 0.13f, 0.18f), material);
			Part("Header", new Vector3(0f, 2.055f, 0f), new Vector3(1.98f, 0.3f, 0.2f), material);
			Part("RainCap", new Vector3(0f, 2.245f, 0f), new Vector3(2.08f, 0.075f, 0.34f), material2);
			array = new float[2] { -0.78f, 0.78f };
			foreach (float num3 in array)
			{
				Part("InsetSideTrim", new Vector3(num3, 1.38f, 0.07f), new Vector3(0.035f, 1.08f, 0.045f), material);
			}
			Collider(new Vector3(0f, 1.47f, 0f), new Vector3(1.8f, 1.5f, 0.2f));
			array = new float[2] { 1f, -1f };
			foreach (float num4 in array)
			{
				BoardText("QUEST BOARD", new Vector3(0f, 2.09f, num4 * 0.108f), num4, new Vector2(1740f, 160f), 105f, new Color(0.94f, 0.9f, 0.77f));
				BoardText("FIELD ASSIGNMENTS", new Vector3(0f, 1.963f, num4 * 0.109f), num4, new Vector2(1600f, 70f), 38f, new Color(0.65f, 0.76f, 0.64f));
				float[] array2 = new float[2] { -0.88f, 0.88f };
				foreach (float num5 in array2)
				{
					float[] array3 = new float[2] { 0.76f, 2.055f };
					foreach (float num6 in array3)
					{
						Part("IronFastener", new Vector3(num5, num6, num4 * 0.106f), new Vector3(0.042f, 0.042f, 0.016f), material2);
					}
				}
				for (int n = 0; n < 3; n++)
				{
					float num7 = (float)(n - 1) * 0.49f;
					GameObject val7 = new GameObject("PinnedNotice");
					val7.layer = 2;
					val7.transform.SetParent(Root.transform, false);
					val7.transform.localPosition = new Vector3(num7, (n == 1) ? 0.025f : 0f, 0f);
					val7.transform.localRotation = Quaternion.Euler(0f, 0f, n switch
					{
						2 => 1.2f, 
						0 => -1.5f, 
						_ => 0f, 
					});
					Part("PostedAssignment", new Vector3(0f, 1.37f, num4 * 0.066f), new Vector3(0.415f, 0.64f, 0.014f), (n == 1) ? val4 : val3, val7.transform);
					Part("PaperPin", new Vector3(0f, 1.65f, num4 * 0.08f), new Vector3(0.027f, 0.027f, 0.013f), material2, val7.transform);
					Part("NoticeHeading", new Vector3(0f, 1.53f, num4 * 0.077f), new Vector3(0.29f, 0.045f, 0.009f), (n == 1) ? val6 : val5, val7.transform);
					for (int num8 = 0; num8 < 4; num8++)
					{
						Part("NoticeWriting", new Vector3(0f, 1.4f - (float)num8 * 0.064f, num4 * 0.077f), new Vector3((num8 == 3) ? 0.18f : ((num8 % 2 == 0) ? 0.29f : 0.24f), 0.009f, 0.008f), val5, val7.transform);
					}
					Part("RewardSeal", new Vector3(0.125f, 1.12f, num4 * 0.079f), new Vector3(0.055f, 0.055f, 0.012f), val6, val7.transform);
				}
			}
		}

		private Material Material(Color color)
		{
			//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_004a: 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_0052: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			Shader obj = Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard") ?? Shader.Find("Sprites/Default");
			if ((Object)(object)obj == (Object)null)
			{
				throw new InvalidOperationException("Quest board shader unavailable.");
			}
			Material val = new Material(obj)
			{
				name = "FieldQuests_BoardMaterial",
				color = color
			};
			if (val.HasProperty("_BaseColor"))
			{
				val.SetColor("_BaseColor", color);
			}
			if (val.HasProperty("_Smoothness"))
			{
				val.SetFloat("_Smoothness", 0.18f);
			}
			_materials.Add(val);
			return val;
		}

		private void Part(string name, Vector3 position, Vector3 size, Material material, Transform parent = null)
		{
			//IL_003f: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)obj).name = name;
			obj.layer = 2;
			obj.transform.SetParent(((Object)(object)parent != (Object)null) ? parent : Root.transform, false);
			obj.transform.localPosition = position;
			obj.transform.localScale = size;
			Collider component = obj.GetComponent<Collider>();
			component.enabled = false;
			Object.Destroy((Object)(object)component);
			Renderer component2 = obj.GetComponent<Renderer>();
			component2.sharedMaterial = material;
			if (size.z < 0.04f)
			{
				component2.shadowCastingMode = (ShadowCastingMode)0;
			}
		}

		private void Collider(Vector3 center, Vector3 size)
		{
			//IL_000c: 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)
			BoxCollider obj = Root.AddComponent<BoxCollider>();
			obj.center = center;
			obj.size = size;
		}

		private void BoardText(string text, Vector3 position, float side, Vector2 size, float fontSize, Color color)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_003e: 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_0059: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: 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_014e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("BoardTitle", (Type[])(object)new Type[2]
			{
				Il2CppType.Of<RectTransform>(),
				Il2CppType.Of<Canvas>()
			});
			val.transform.SetParent(Root.transform, false);
			val.layer = 2;
			val.GetComponent<Canvas>().renderMode = (RenderMode)2;
			RectTransform component = val.GetComponent<RectTransform>();
			component.sizeDelta = size;
			((Transform)component).localPosition = position;
			((Transform)component).localRotation = Quaternion.Euler(0f, (float)((side > 0f) ? 180 : 0), 0f);
			((Transform)component).localScale = Vector3.one * 0.001f;
			GameObject val2 = new GameObject("Title", (Type[])(object)new Type[3]
			{
				Il2CppType.Of<RectTransform>(),
				Il2CppType.Of<CanvasRenderer>(),
				Il2CppType.Of<TextMeshProUGUI>()
			});
			val2.transform.SetParent((Transform)(object)component, false);
			val2.layer = 2;
			TextMeshProUGUI component2 = val2.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component2).text = text;
			((TMP_Text)component2).fontSize = fontSize;
			((Graphic)component2).color = color;
			((TMP_Text)component2).fontStyle = (FontStyles)1;
			((TMP_Text)component2).alignment = (TextAlignmentOptions)514;
			((TMP_Text)component2).enableAutoSizing = false;
			((TMP_Text)component2).enableWordWrapping = false;
			((Graphic)component2).raycastTarget = false;
			((TMP_Text)component2).rectTransform.anchorMin = Vector2.zero;
			((TMP_Text)component2).rectTransform.anchorMax = Vector2.one;
			((TMP_Text)component2).rectTransform.offsetMin = Vector2.zero;
			((TMP_Text)component2).rectTransform.offsetMax = Vector2.zero;
		}

		internal bool CanRead(bool cosmetics = false)
		{
			//IL_0036: 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_003b: 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_004b: 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_0065: 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_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_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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_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_00ef: 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_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)
			//IL_00f8: 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_00d5: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Root == (Object)null || (Object)(object)Player.mainCamera == (Object)null || (Object)(object)Player.localPlayer == (Object)null)
			{
				return false;
			}
			Vector3 val = (cosmetics ? CosmeticPosition : Position);
			if (Vector3.Distance(((Component)Player.localPlayer).transform.position, val) >= (cosmetics ? 2.1f : 3.8f))
			{
				return false;
			}
			Vector3 val2 = val + Vector3.up * (cosmetics ? 1f : 1.4f);
			Vector3 position = ((Component)Player.mainCamera).transform.position;
			Vector3 val3 = val2 - position;
			val3.y = 0f;
			Vector3 forward = ((Component)Player.mainCamera).transform.forward;
			forward.y = 0f;
			if (((Vector3)(ref val3)).sqrMagnitude > 0.25f && Vector3.Dot(((Vector3)(ref forward)).normalized, ((Vector3)(ref val3)).normalized) < 0.35f)
			{
				return false;
			}
			Vector3 val4 = val2 - position;
			foreach (RaycastHit item in (Il2CppArrayBase<RaycastHit>)(object)Physics.RaycastAll(position, ((Vector3)(ref val4)).normalized, ((Vector3)(ref val4)).magnitude, -5, (QueryTriggerInteraction)1))
			{
				RaycastHit current = item;
				Transform transform = ((RaycastHit)(ref current)).transform;
				if (!((Object)(object)transform == (Object)null) && !transform.IsChildOf(Root.transform) && !transform.IsChildOf(((Component)Player.localPlayer).transform) && !transform.IsChildOf(((Component)Player.mainCamera).transform))
				{
					return false;
				}
			}
			return true;
		}

		public void Dispose()
		{
			if ((Object)(object)Root != (Object)null)
			{
				Object.Destroy((Object)(object)Root);
			}
			foreach (Material material in _materials)
			{
				if ((Object)(object)material != (Object)null)
				{
					Object.Destroy((Object)(object)material);
				}
			}
			_materials.Clear();
			Root = null;
		}
	}
	public sealed class QuestController : MonoBehaviour
	{
		private const string RequestChannel = "FrankMods.FieldQuests.Request.v1";

		private const string ResponseChannel = "FrankMods.FieldQuests.Response.v1";

		private NetworkManager _network;

		private CustomMessagingManager _messages;

		private HandleNamedMessageDelegate _requestHandler;

		private HandleNamedMessageDelegate _responseHandler;

		private Action _saveHandler;

		private readonly Dictionary<ulong, float> _lastRequest = new Dictionary<ulong, float>();

		private readonly QuestBoard _board = new QuestBoard();

		private QuestPanel _ui;

		private readonly SkinVisuals _skins = new SkinVisuals();

		private bool _skinFailed;

		internal QuestService Service;

		private float _nextCheck;

		private float _nextPoll;

		private float _nextBoardAttempt;

		private float _nextHudPoll;

		private bool _failed;

		private bool _wasListening;

		private readonly QuestInteraction _talk = new QuestInteraction();

		private float _nextSpawnWarning;

		private QuestBoardLocation _hostLocation;

		private string _placementStatus = "Preparing the quest board";

		private PropertyInfo _carpetMounted;

		private bool _checkedCarpet;

		internal bool BlockingInput
		{
			get
			{
				if (_ui != null)
				{
					return _ui.BlockingInput;
				}
				return false;
			}
		}

		public QuestController(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Update()
		{
			try
			{
				Tick();
			}
			catch (Exception ex)
			{
				if (!_failed)
				{
					QuestPlugin.LogSource.LogError((object)("FieldQuests runtime: " + ex));
				}
				_failed = true;
				_ui?.Dispose();
				_ui = null;
				_talk.Dispose();
			}
		}

		private void Tick()
		{
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Invalid comparison between Unknown and I4
			//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bb: Unknown result type (might be due to invalid IL or missing references)
			if (Time.unscaledTime >= _nextCheck)
			{
				_nextCheck = Time.unscaledTime + 0.5f;
				NetworkManager singleton = NetworkManager.Singleton;
				if ((Object)(object)singleton == (Object)null || !singleton.IsListening)
				{
					if (_wasListening)
					{
						Cleanup();
					}
					return;
				}
				if (!Player.isLocalPlayerLoaded)
				{
					_ui?.Close();
					_ui?.Tick();
					if (!BlockingInput)
					{
						_talk.Release();
					}
					return;
				}
				if ((Object)(object)_network != (Object)(object)singleton || !_wasListening)
				{
					Cleanup();
					_network = singleton;
					_messages = singleton.CustomMessagingManager;
					_requestHandler = DelegateSupport.ConvertDelegate<HandleNamedMessageDelegate>((Delegate)new Action<ulong, FastBufferReader>(OnRequest));
					_responseHandler = DelegateSupport.ConvertDelegate<HandleNamedMessageDelegate>((Delegate)new Action<ulong, FastBufferReader>(OnResponse));
					_messages.RegisterNamedMessageHandler("FrankMods.FieldQuests.Request.v1", _requestHandler);
					_messages.RegisterNamedMessageHandler("FrankMods.FieldQuests.Response.v1", _responseHandler);
					_wasListening = true;
					QuestService.ValidateCatalog();
					if (singleton.IsServer)
					{
						Service = new QuestService();
						Service.Load();
						_saveHandler = DelegateSupport.ConvertDelegate<Action>((Delegate)(Action)delegate
						{
							try
							{
								Service?.SaveWithWorld();
							}
							catch (Exception ex3)
							{
								QuestPlugin.LogSource.LogError((object)("Quest save failed: " + ex3));
							}
						});
						SaveManager.onSaveComplete += _saveHandler;
					}
					_ui = new QuestPanel(Send);
				}
			}
			if (!_wasListening || _failed)
			{
				return;
			}
			if (!Player.isLocalPlayerLoaded || (Object)(object)Player.localPlayer == (Object)null)
			{
				_ui?.Close();
				_ui?.Tick();
				if (!BlockingInput)
				{
					_talk.Release();
				}
				return;
			}
			if ((Object)(object)_board.Root == (Object)null && Time.unscaledTime >= _nextBoardAttempt)
			{
				_nextBoardAttempt = Time.unscaledTime + 3f;
				try
				{
					if (_network.IsServer)
					{
						_board.Create();
						_placementStatus = _board.WaitingReason;
					}
					else
					{
						QuestBoardLocation hostLocation = _hostLocation;
						if (hostLocation != null && hostLocation.IsValid)
						{
							_board.Create((Vector3?)new Vector3(_hostLocation.X, _hostLocation.Y, _hostLocation.Z), _hostLocation.Yaw);
							_placementStatus = _board.WaitingReason;
						}
						else
						{
							_placementStatus = "Waiting for the host's quest board (host needs ContentPlus)";
							SendText("FrankMods.FieldQuests.Request.v1", NetworkManager.ServerClientId, "locate:");
						}
					}
				}
				catch (Exception ex)
				{
					_placementStatus = "Quest board could not be created; retrying (details in game log)";
					if (Time.unscaledTime >= _nextSpawnWarning)
					{
						QuestPlugin.LogSource.LogWarning((object)("Quest board placement: " + ex));
					}
				}
				if ((Object)(object)_board.Root == (Object)null && Time.unscaledTime >= _nextSpawnWarning)
				{
					_nextSpawnWarning = Time.unscaledTime + 30f;
					QuestPlugin.LogSource.LogWarning((object)("Quest board: " + _placementStatus));
				}
			}
			bool flag = Application.isFocused && (!Cursor.visible || (int)Cursor.lockState == 1) && !PlayerInventoryUI.isOpen && !SkillWheelManager.isOpen && !((ANetworkEntity)Player.localPlayer).isDead;
			bool flag2 = flag && _board.CanRead();
			bool flag3 = flag && _board.CanRead(cosmetics: true) && Vector3.Distance(Player.localTransform.position, _board.CosmeticPosition) < Vector3.Distance(Player.localTransform.position, _board.Position);
			flag2 = flag2 || flag3;
			if (!_skinFailed)
			{
				try
				{
					_skins.Tick();
				}
				catch (Exception ex2)
				{
					_skinFailed = true;
					QuestPlugin.LogSource.LogWarning((object)("Cosmetic rendering paused for this session: " + ex2));
					try
					{
						_skins.Dispose();
					}
					catch
					{
					}
				}
			}
			if (flag && !_ui.IsOpen && Time.unscaledTime >= _nextHudPoll)
			{
				_nextHudPoll = Time.unscaledTime + 5f;
				Send("progress", "");
			}
			bool flag4 = IsRidingCarpet();
			int num;
			if (flag2)
			{
				num = ((!flag4) ? 1 : 0);
				if (num != 0 && !BlockingInput)
				{
					_talk.Reserve();
					goto IL_04ce;
				}
			}
			else
			{
				num = 0;
			}
			if (!BlockingInput)
			{
				_talk.Release();
			}
			goto IL_04ce;
			IL_04ce:
			_ui.SetPrompt(flag2, ((Object)(object)_board.Root != (Object)null) ? _board.Position : Vector3.zero, flag4, _talk.Label, (Object)(object)_board.Root != (Object)null, _placementStatus, flag, flag3);
			bool pressed = _talk.Pressed;
			if (((uint)num & (pressed ? 1u : 0u)) != 0 && !BlockingInput)
			{
				_ui.Open(flag3);
				Send(_ui.IsCosmetics ? "wardrobe" : "view", "");
				_nextPoll = Time.unscaledTime + 1f;
			}
			if (_ui.IsOpen && (((ANetworkEntity)Player.localPlayer).isDead || (Object)(object)_board.Root == (Object)null || Vector3.Distance(Player.localTransform.position, _board.Position) > 5.5f))
			{
				_ui.Close();
			}
			_ui.Tick();
			if (_ui.IsOpen && Time.unscaledTime >= _nextPoll)
			{
				Send(_ui.IsCosmetics ? "wardrobe" : "view", "");
				_nextPoll = Time.unscaledTime + 1f;
			}
		}

		private bool IsRidingCarpet()
		{
			if (!_checkedCarpet)
			{
				_checkedCarpet = true;
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				for (int i = 0; i < assemblies.Length; i++)
				{
					Type type = assemblies[i].GetType("InfernoProtocol.MagicCarpet.MagicCarpetController", throwOnError: false);
					if (type != null)
					{
						_carpetMounted = type.GetProperty("IsMounted", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
					}
				}
			}
			object obj = _carpetMounted?.GetValue(null);
			if (obj is bool)
			{
				return (bool)obj;
			}
			return false;
		}

		private void Send(string verb, string id)
		{
			//IL_0069: 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)
			if (!((Object)(object)_network == (Object)null) && (!((Object)(object)_board.Root == (Object)null) || !(verb != "progress")))
			{
				if (_network.IsServer)
				{
					QuestView view = Service.Execute(Player.localPlayer, verb, id, ((Object)(object)_board.Root != (Object)null) ? _board.Position : Vector3.zero);
					_skins.Receive(view);
					_ui.Receive(view);
				}
				else
				{
					SendText("FrankMods.FieldQuests.Request.v1", NetworkManager.ServerClientId, verb + ":" + id);
				}
			}
		}

		private void OnRequest(ulong sender, FastBufferReader reader)
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)_network == (Object)null || !_network.IsServer || Service == null || ((FastBufferReader)(ref reader)).Length > 512)
				{
					return;
				}
				float unscaledTime = Time.unscaledTime;
				if (_lastRequest.TryGetValue(sender, out var value) && unscaledTime - value < 0.15f)
				{
					return;
				}
				_lastRequest[sender] = unscaledTime;
				string text = default(string);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref text, true);
				if (text == null || text.Length > 80)
				{
					return;
				}
				string[] array = text.Split(':');
				NetworkClient val = default(NetworkClient);
				if (array.Length != 2 || !_network.ConnectedClients.TryGetValue(sender, ref val))
				{
					return;
				}
				if (array[0] == "locate")
				{
					QuestBoardLocation location = (((Object)(object)_board.Root == (Object)null) ? null : new QuestBoardLocation
					{
						X = _board.Position.x,
						Y = _board.Position.y,
						Z = _board.Position.z,
						Yaw = _board.Root.transform.eulerAngles.y
					});
					SendText("FrankMods.FieldQuests.Response.v1", sender, JsonSerializer.Serialize(new QuestView
					{
						LocationOnly = true,
						Location = location,
						Message = _placementStatus
					}));
				}
				else
				{
					if ((Object)(object)_board.Root == (Object)null && array[0] != "progress")
					{
						return;
					}
					Player val2 = (((Object)(object)val.PlayerObject != (Object)null) ? ((Component)val.PlayerObject).GetComponent<Player>() : null);
					if ((Object)(object)val2 == (Object)null)
					{
						foreach (Player item in Object.FindObjectsOfType<Player>())
						{
							if (((NetworkBehaviour)item).IsSpawned && ((NetworkBehaviour)item).OwnerClientId == sender)
							{
								val2 = item;
								break;
							}
						}
					}
					if (!((Object)(object)val2 == (Object)null))
					{
						QuestView value2 = Service.Execute(val2, array[0], array[1], ((Object)(object)_board.Root != (Object)null) ? _board.Position : Vector3.zero);
						SendText("FrankMods.FieldQuests.Response.v1", sender, JsonSerializer.Serialize(value2));
					}
				}
			}
			catch (Exception ex)
			{
				QuestPlugin.LogSource.LogWarning((object)("Quest request rejected: " + ex.Message));
			}
		}

		private void OnResponse(ulong sender, FastBufferReader reader)
		{
			try
			{
				if ((Object)(object)_network == (Object)null || _network.IsServer || sender != NetworkManager.ServerClientId || ((FastBufferReader)(ref reader)).Length > 20000)
				{
					return;
				}
				string json = default(string);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref json, true);
				QuestView questView = JsonSerializer.Deserialize<QuestView>(json);
				if (questView == null || questView.Protocol != 1 || questView.Rows == null || questView.Rows.Count > QuestCatalog.All.Length)
				{
					return;
				}
				if (questView.LocationOnly)
				{
					QuestBoardLocation location = questView.Location;
					if (location != null && location.IsValid)
					{
						_hostLocation = questView.Location;
					}
					if (!string.IsNullOrEmpty(questView.Message))
					{
						_placementStatus = questView.Message;
					}
					return;
				}
				HashSet<string> hashSet = new HashSet<string>();
				foreach (QuestRow row in questView.Rows)
				{
					if (row == null || QuestCatalog.Find(row.Id) == null || !hashSet.Add(row.Id))
					{
						return;
					}
				}
				_skins.Receive(questView);
				_ui?.Receive(questView);
			}
			catch (Exception ex)
			{
				QuestPlugin.LogSource.LogWarning((object)("Quest response rejected: " + ex.Message));
			}
		}

		private void SendText(string channel, ulong target, string value)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			int num = value.Length * 2 + 32;
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(num, (Allocator)2, num);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe(value, true);
				_messages.SendNamedMessage(channel, target, val, (NetworkDelivery)4);
			}
			finally
			{
				((FastBufferWriter)(ref val)).Dispose();
			}
		}

		internal void Cleanup()
		{
			if ((Delegate)(object)_saveHandler != (Delegate)null)
			{
				SaveManager.onSaveComplete -= _saveHandler;
			}
			_saveHandler = null;
			_ui?.Dispose();
			_ui = null;
			_skins.Dispose();
			_skinFailed = false;
			_talk.Dispose();
			_board.Dispose();
			if (_messages != null)
			{
				try
				{
					_messages.UnregisterNamedMessageHandler("FrankMods.FieldQuests.Request.v1");
					_messages.UnregisterNamedMessageHandler("FrankMods.FieldQuests.Response.v1");
				}
				catch
				{
				}
			}
			Service = null;
			_messages = null;
			_network = null;
			_hostLocation = null;
			_placementStatus = "Preparing the quest board";
			_nextHudPoll = 0f;
			_nextBoardAttempt = 0f;
			_nextSpawnWarning = 0f;
			_lastRequest.Clear();
			_wasListening = false;
			_failed = false;
		}

		private void OnDestroy()
		{
			Cleanup();
		}
	}
	internal sealed class QuestInteraction : IDisposable
	{
		private readonly List<ButtonControl> _buttons = new List<ButtonControl>();

		private readonly List<InputAction> _disabled = new List<InputAction>();

		private bool _active;

		internal bool Pressed
		{
			get
			{
				if (!_active || !_buttons.Exists((ButtonControl b) => b.wasPressedThisFrame))
				{
					Keyboard current = Keyboard.current;
					if (current == null)
					{
						return false;
					}
					return ((ButtonControl)current.f9Key).wasPressedThisFrame;
				}
				return true;
			}
		}

		internal string Label
		{
			get
			{
				bool playingWithGamepad = PlayerInputDispatcher.playingWithGamepad;
				foreach (ButtonControl button in _buttons)
				{
					if (((Il2CppObjectBase)((InputControl)button).device).TryCast<Gamepad>() != null == playingWithGamepad)
					{
						return ((InputControl)button).displayName;
					}
				}
				return "F9";
			}
		}

		internal void Reserve()
		{
			if (_active)
			{
				return;
			}
			PlayerActionContainer actions = PlayerInputDispatcher.actions;
			InputAction val = ((actions != null) ? actions.interact : null);
			if (val == null || !val.enabled)
			{
				return;
			}
			_buttons.Clear();
			Enumerator<InputControl> enumerator = val.controls.GetEnumerator();
			while (enumerator.MoveNext())
			{
				ButtonControl val2 = ((Il2CppObjectBase)enumerator.Current).TryCast<ButtonControl>();
				if (val2 != null)
				{
					_buttons.Add(val2);
				}
			}
			InputActionAsset inputActionsAsset = PlayerInputDispatcher.inputActionsAsset;
			ReadOnlyArray<InputActionMap> val3 = ((inputActionsAsset != null) ? inputActionsAsset.actionMaps : null);
			if (val3 != null)
			{
				Enumerator<InputActionMap> enumerator2 = val3.GetEnumerator();
				while (enumerator2.MoveNext())
				{
					Enumerator<InputAction> enumerator3 = enumerator2.Current.actions.GetEnumerator();
					while (enumerator3.MoveNext())
					{
						InputAction current = enumerator3.Current;
						if (!current.enabled)
						{
							continue;
						}
						bool flag = false;
						enumerator = current.controls.GetEnumerator();
						while (enumerator.MoveNext())
						{
							InputControl control = enumerator.Current;
							if (_buttons.Exists((ButtonControl b) => ((InputControl)b).path == control.path))
							{
								flag = true;
								break;
							}
						}
						if (flag)
						{
							_disabled.Add(current);
						}
					}
				}
			}
			foreach (InputAction item in _disabled)
			{
				item.Disable();
			}
			_active = true;
		}

		internal void Release(bool force = false)
		{
			if (!force && _buttons.Exists((ButtonControl b) => b.isPressed))
			{
				return;
			}
			foreach (InputAction item in _disabled)
			{
				if (item.actionMap == null || item.actionMap.enabled)
				{
					item.Enable();
				}
			}
			_disabled.Clear();
			_buttons.Clear();
			_active = false;
		}

		public void Dispose()
		{
			Release(force: true);
		}
	}
	public sealed class Quest
	{
		public readonly string Id;

		public readonly string Title;

		public readonly string Description;

		public readonly string Target;

		public readonly string Reward;

		public readonly int Amount;

		public readonly int Xp;

		public readonly int Level;

		public readonly bool Hunt;

		public Quest(string id, string title, string description, string target, int amount, string reward, int xp, int level, bool hunt)
		{
			Id = id;
			Title = title;
			Description = description;
			Target = target;
			Amount = amount;
			Reward = reward;
			Xp = xp;
			Level = level;
			Hunt = hunt;
		}
	}
	public static class QuestCatalog
	{
		public static readonly Quest[] All = new Quest[24]
		{
			new Quest("s01", "A place to begin", "A good camp starts with solid timber. Bring logs for the supply reserve.", "Log", 8, "LeatherShoes", 100, 1, hunt: false),
			new Quest("s02", "Firm foundations", "We need stone to reinforce the paths around camp.", "Stone", 12, "WoodenSpear", 120, 1, hunt: false),
			new Quest("s03", "Light the way", "Help us keep the perimeter lit after sundown.", "Torch", 3, "Flashlight", 140, 1, hunt: false),
			new Quest("s04", "First-aid reserve", "A small medical reserve can save a life. Stock the infirmary.", "Bandage", 3, "LeatherFlaskEmpty", 150, 1, hunt: false),
			new Quest("s05", "A warm welcome", "Bring drinking water for the next arrivals.", "WaterBottleFilled", 2, "StonePickaxe", 130, 1, hunt: false),
			new Quest("s06", "Field dressings", "Supply clean cloth for field dressings. Earn protective headgear for your next expedition.", "ClothPiece", 6, "ScrapHelmet", 180, 2, hunt: false),
			new Quest("s07", "A proper workshop", "Deliver planks so we can expand the work area.", "Plank", 8, "ScrapAxe", 220, 2, hunt: false),
			new Quest("s08", "Keep it together", "Tape is always in short supply at the repair bench.", "Tape", 3, "ScrapPickaxe", 240, 2, hunt: false),
			new Quest("s09", "Copper prospect", "Bring copper ore for the camp's first metalwork trials.", "CopperOre", 8, "BronzeHammer", 280, 3, hunt: false),
			new Quest("s10", "The other half", "Tin will let us put that copper to better use.", "TinOre", 8, "BronzeAxe", 280, 3, hunt: false),
			new Quest("s11", "Bronze standard", "A batch of finished ingots will get the new workshop running.", "BronzeIngot", 4, "MiningHelmet", 360, 4, hunt: false),
			new Quest("s12", "Power reserve", "Deliver spare batteries for our night patrols.", "Battery", 3, "GasMask", 360, 4, hunt: false),
			new Quest("h01", "Small trouble", "Thin out the rats around our supply routes. Only your kills after accepting count.", "Rat", 5, "NailBat", 150, 1, hunt: true),
			new Quest("h02", "Shambling company", "Keep the walking dead away from our newcomers.", "Zombie", 5, "ScrapMachete", 180, 1, hunt: true),
			new Quest("h03", "Larger teeth", "Giant rats have been tearing through the supply trails.", "GiantRat", 3, "Crossbow", 240, 2, hunt: true),
			new Quest("h04", "Night watch", "Clear a larger group of zombies so our scouts can get through.", "Zombie", 15, "ScrapHelmet", 320, 2, hunt: true),
			new Quest("h05", "Scavenger patrol", "Trash eaters keep following our supply parties.", "TrashEater", 5, "ScrapMachete", 320, 2, hunt: true),
			new Quest("h06", "Unwanted company", "Put down the meat slimes blocking our route.", "MeatSlime", 5, "ScrapPant", 360, 3, hunt: true),
			new Quest("h07", "Forest sentries", "The leaf hunters have made the treeline dangerous.", "LeafHunter", 5, "ScrapShirt", 400, 3, hunt: true),
			new Quest("h08", "A quieter night", "Hunt the ghouls before another patrol goes missing.", "Ghoul", 4, "IronSpear", 420, 3, hunt: true),
			new Quest("h09", "Broken ambush", "Stop the goblin fighters stalking the outer paths.", "GoblinMelee", 8, "BronzeMachete", 440, 4, hunt: true),
			new Quest("h10", "Buzz off", "Giant flies are making the nearby routes miserable.", "GiantFly", 6, "GasMask", 460, 4, hunt: true),
			new Quest("h11", "Hold the line", "Prove the camp can rely on you against a sustained zombie threat.", "Zombie", 30, "Colt1911", 600, 5, hunt: true),
			new Quest("h12", "Veteran hunter", "Take down the stitchers threatening our expeditions.", "Stitcher", 5, "Katana", 750, 5, hunt: true)
		};

		public static Quest Find(string id)
		{
			return All.FirstOrDefault((Quest q) => q.Id == id);
		}

		public static Dictionary<string, string> Unavailable(Func<string, bool> itemExists, Func<string, bool> creatureExists)
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			Quest[] all = All;
			foreach (Quest quest in all)
			{
				try
				{
					if (!itemExists(quest.Reward))
					{
						dictionary[quest.Id] = "Missing reward: " + quest.Reward;
					}
					else if (!(quest.Hunt ? creatureExists(quest.Target) : itemExists(quest.Target)))
					{
						dictionary[quest.Id] = "Missing objective: " + quest.Target;
					}
				}
				catch (Exception ex)
				{
					dictionary[quest.Id] = "Asset lookup failed: " + ex.Message;
				}
			}
			return dictionary;
		}

		public static int Level(int xp)
		{
			int i;
			for (i = 1; i < 100 && xp >= Threshold(i + 1); i++)
			{
			}
			return i;
		}

		public static int Threshold(int level)
		{
			return checked(100 * (level - 1) * level);
		}
	}
	public sealed class Progress
	{
		public int Xp { get; set; }

		public Dictionary<string, int> Active { get; set; } = new Dictionary<string, int>();

		public HashSet<string> Completed { get; set; } = new HashSet<string>();

		public Dictionary<string, int> Skins { get; set; } = new Dictionary<string, int>();

		public string Accept(Quest quest)
		{
			if (quest == null)
			{
				return "Unknown assignment.";
			}
			if (Completed.Contains(quest.Id))
			{
				return "Already completed.";
			}
			if (Active.ContainsKey(quest.Id))
			{
				return "Already in your journal.";
			}
			if (QuestCatalog.Level(Xp) < quest.Level)
			{
				return $"Requires level {quest.Level}.";
			}
			if (Active.Count >= 6)
			{
				return "Your journal holds six active quests. Finish or abandon one first.";
			}
			Active.Add(quest.Id, 0);
			return "Quest accepted.";
		}

		public void Kill(string creature)
		{
			Quest[] all = QuestCatalog.All;
			foreach (Quest quest in all)
			{
				if (quest.Hunt && quest.Target == creature && Active.TryGetValue(quest.Id, out var value))
				{
					Active[quest.Id] = Math.Min(quest.Amount, value + 1);
				}
			}
		}

		public void Complete(Quest quest)
		{
			if (!Active.ContainsKey(quest.Id) || Completed.Contains(quest.Id))
			{
				throw new InvalidOperationException("Quest is not claimable.");
			}
			int xp = checked(Xp + quest.Xp);
			Completed.Add(quest.Id);
			Active.Remove(quest.Id);
			Xp = xp;
		}
	}
	public readonly struct StackData : IEquatable<StackData>
	{
		public readonly string Item;

		public readonly int Count;

		public readonly byte Durability;

		public readonly byte Var1;

		public readonly byte Var2;

		public StackData(string item, int count, byte durability = 0, byte var1 = 0, byte var2 = 0)
		{
			Item = item;
			Count = count;
			Durability = durability;
			Var1 = var1;
			Var2 = var2;
		}

		public StackData WithCount(int count)
		{
			return new StackData(Item, count, Durability, Var1, Var2);
		}

		public bool Equals(StackData other)
		{
			if (Count == other.Count)
			{
				if (Count != 0)
				{
					if (Item == other.Item && Durability == other.Durability && Var1 == other.Var1)
					{
						return Var2 == other.Var2;
					}
					return false;
				}
				return true;
			}
			return false;
		}

		public override bool Equals(object obj)
		{
			if (obj is StackData other)
			{
				return Equals(other);
			}
			return false;
		}

		public override int GetHashCode()
		{
			if (Count != 0)
			{
				return HashCode.Combine(Item, Count, Durability, Var1, Var2);
			}
			return 0;
		}

		public static bool operator ==(StackData a, StackData b)
		{
			return a.Equals(b);
		}

		public static bool operator !=(StackData a, StackData b)
		{
			return !a.Equals(b);
		}
	}
	public sealed class Slot
	{
		public string Container { get; init; }

		public int Index { get; init; }

		public bool RewardDestination { get; init; }

		public StackData Before { get; init; }

		public StackData After { get; set; }
	}
	public static class TurnInPlanner
	{
		public static bool Plan(List<Slot> slots, Quest quest, StackData reward, out string error)
		{
			foreach (Slot slot2 in slots)
			{
				slot2.After = slot2.Before;
			}
			int num = ((!quest.Hunt) ? quest.Amount : 0);
			foreach (Slot slot3 in slots)
			{
				if (num == 0)
				{
					break;
				}
				if (!(slot3.Before.Item != quest.Target) && slot3.Before.Count > 0)
				{
					int num2 = Math.Min(num, slot3.Before.Count);
					slot3.After = slot3.Before.WithCount(slot3.Before.Count - num2);
					num -= num2;
				}
			}
			if (num != 0)
			{
				error = "Not enough materials. Nothing was consumed.";
				return false;
			}
			Slot slot = slots.FirstOrDefault((Slot s) => s.RewardDestination && s.After.Count == 0);
			if (slot == null)
			{
				error = "Free one inventory or backpack slot for your reward.";
				return false;
			}
			slot.After = reward;
			error = "";
			return true;
		}
	}
	public static class SlotTransaction
	{
		public static void Commit(List<Slot> changed, Func<Slot, StackData> read, Action<Slot, StackData> write)
		{
			foreach (Slot item3 in changed)
			{
				if (read(item3) != item3.Before)
				{
					throw new InvalidOperationException("An inventory changed. Try again.");
				}
			}
			int num = 0;
			try
			{
				foreach (Slot item4 in changed)
				{
					if (read(item4) != item4.Before)
					{
						throw new InvalidOperationException("An inventory changed during turn-in.");
					}
					num++;
					write(item4, item4.After);
					if (read(item4) != item4.After)
					{
						throw new InvalidOperationException("Inventory write did not stick.");
					}
				}
			}
			catch (Exception item)
			{
				List<Exception> list = new List<Exception>();
				for (int num2 = num - 1; num2 >= 0; num2--)
				{
					try
					{
						write(changed[num2], changed[num2].Before);
						if (read(changed[num2]) != changed[num2].Before)
						{
							throw new InvalidOperationException("Rollback verification failed.");
						}
					}
					catch (Exception item2)
					{
						list.Add(item2);
					}
				}
				if (list.Count > 0)
				{
					list.Insert(0, item);
					throw new AggregateException("Inventory rollback failed.", list);
				}
				throw;
			}
		}
	}
	public sealed class QuestRow
	{
		public string Id { get; set; }

		public int Count { get; set; }

		public int Carried { get; set; }

		public int Stored { get; set; }

		public string State { get; set; }
	}
	public sealed class QuestView
	{
		public int Protocol { get; set; } = 1;

		public string Message { get; set; } = "";

		public int Xp { get; set; }

		public List<QuestRow> Rows { get; set; } = new List<QuestRow>();

		public bool LocationOnly { get; set; }

		public bool ProgressOnly { get; set; }

		public Dictionary<string, int> Skins { get; set; } = new Dictionary<string, int>();

		public List<int> SkinUnlocks { get; set; } = new List<int>();

		public QuestBoardLocation Location { get; set; }
	}
	public sealed class QuestBoardLocation
	{
		public float X { get; set; }

		public float Y { get; set; }

		public float Z { get; set; }

		public float Yaw { get; set; }

		public bool IsValid
		{
			get
			{
				if (float.IsFinite(X) && float.IsFinite(Y) && float.IsFinite(Z) && float.IsFinite(Yaw) && Math.Abs(X) < 1000000f && Math.Abs(Y) < 1000000f)
				{
					return Math.Abs(Z) < 1000000f;
				}
				return false;
			}
		}
	}
	internal sealed class QuestPanel : IDisposable
	{
		private sealed class ActionBox
		{
			internal Image Image;

			internal TextMeshProUGUI Label;

			internal Action Click;

			internal bool Enabled = true;

			internal Color BaseColor;
		}

		private readonly Action<string, string> _send;

		private readonly List<ActionBox> _buttons = new List<ActionBox>();

		private readonly List<InputActionMap> _disabledMaps = new List<InputActionMap>();

		private readonly List<InputAction> _previouslyDisabledActions = new List<InputAction>();

		private readonly List<QuestRow> _visible = new List<QuestRow>();

		private readonly ActionBox[] _tabs = new ActionBox[5];

		private readonly ActionBox[] _rows = new ActionBox[6];

		private readonly Image[] _rowIcons = (Image[])(object)new Image[6];

		private readonly TextMeshProUGUI[] _rowStatus = (TextMeshProUGUI[])(object)new TextMeshProUGUI[6];

		private readonly string[] _filters = new string[5] { "All assignments", "My journal", "Hunts", "Supplies", "Completed" };

		private GameObject _canvas;

		private GameObject _window;

		private Image _scrim;

		private Image _xpFill;

		private Image _objectiveFill;

		private Image _rewardIcon;

		private Image _targetIcon;

		private TextMeshProUGUI _prompt;

		private TextMeshProUGUI _level;

		private TextMeshProUGUI _xp;

		private TextMeshProUGUI _title;

		private TextMeshProUGUI _description;

		private TextMeshProUGUI _objective;

		private TextMeshProUGUI _sources;

		private TextMeshProUGUI _reward;

		private TextMeshProUGUI _rewardXp;

		private TextMeshProUGUI _status;

		private TextMeshProUGUI _pagination;

		private TextMeshProUGUI _listTitle;

		private ActionBox _primary;

		private ActionBox _abandon;

		private QuestView _view;

		private Color _accent = new Color(0.45f, 0.88f, 0.8f, 1f);

		private readonly Color _ink = new Color(0.88f, 0.93f, 0.93f, 1f);

		private readonly Color _muted = new Color(0.56f, 0.65f, 0.68f, 1f);

		private readonly Color _panel = new Color(0.045f, 0.065f, 0.075f, 0.96f);

		private int _filter;

		private int _selection;

		private string _confirmation;

		private string _pendingClaim;

		private float _pendingSince;

		private float _receiptUntil;

		private float _displayXp = -1f;

		private TextMeshProUGUI _receipt;

		private GameObject _levelHud;

		private TextMeshProUGUI _hudLevel;

		private Image _hudFill;

		private int _hudXp = -1;

		private float _nextHudTheme;

		private GameObject _dialog;

		private TextMeshProUGUI _dialogTitle;

		private TextMeshProUGUI _dialogBody;

		private TextMeshProUGUI _dialogReward;

		private Image _dialogIcon;

		private ActionBox _dialogConfirm;

		private ActionBox _dialogCancel;

		private bool _dialogResult;

		private bool _dialogCancelSelected;

		private float _dialogOpened;

		private bool _cosmetics;

		private readonly Dictionary<int, Sprite> _finishPreviews = new Dictionary<int, Sprite>();

		private TextMeshProUGUI _brand;

		private TextMeshProUGUI _sidebarTitle;

		private TextMeshProUGUI _welcome;

		private ActionBox _finishPrevious;

		private ActionBox _finishNext;

		private TextMeshProUGUI _briefingTitle;

		private TextMeshProUGUI _finishPage;

		private TextMeshProUGUI _collection;

		private Image _objectiveTrack;

		private Image _levelTrack;

		private int _savedFinish;

		private int _savedEquipment;

		private bool _releasePending;

		private bool _savedCursor;

		private bool _lookWasEnabled;

		private CursorLockMode _savedLock;

		private float _openTime;

		private float _repeatAt;

		private float _messageUntil;

		private float _lastResponse;

		private float _nextAction;

		private int _navHeld;

		internal bool IsCosmetics => _cosmetics;

		internal bool IsOpen { get; private set; }

		internal bool BlockingInput
		{
			get
			{
				if (!IsOpen)
				{
					return _releasePending;
				}
				return true;
			}
		}

		private QuestRow Selected
		{
			get
			{
				if (_visible.Count <= _selection)
				{
					return null;
				}
				return _visible[_selection];
			}
		}

		internal QuestPanel(Action<string, string> send)
		{
			//IL_00a5: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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_00e8: 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)
			_send = send;
			Build();
		}

		internal void Open(bool cosmetics = false)
		{
			//IL_00c1: 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)
			if (BlockingInput)
			{
				return;
			}
			_cosmetics = cosmetics;
			_filter = (cosmetics ? _savedFinish : 0);
			_selection = (cosmetics ? _savedEquipment : 0);
			((TMP_Text)_brand).text = (cosmetics ? "FINISHES  /  EQUIPMENT COSMETICS" : "FIELD NOTES  /  QUEST BOARD");
			((TMP_Text)_sidebarTitle).text = (cosmetics ? "CHOOSE A FINISH" : "THE QUEST BOARD");
			((Component)_welcome).gameObject.SetActive(!cosmetics);
			((Component)_finishPrevious.Image).gameObject.SetActive(cosmetics);
			((Component)_finishNext.Image).gameObject.SetActive(cosmetics);
			LayoutFinishes(cosmetics);
			LoadTheme();
			_savedCursor = Cursor.visible;
			_savedLock = Cursor.lockState;
			_disabledMaps.Clear();
			_previouslyDisabledActions.Clear();
			PlayerActionContainer actions = PlayerInputDispatcher.actions;
			int lookWasEnabled;
			if (actions == null)
			{
				lookWasEnabled = 0;
			}
			else
			{
				InputAction look = actions.look;
				lookWasEnabled = ((((look != null) ? new bool?(look.enabled) : ((bool?)null)) == true) ? 1 : 0);
			}
			_lookWasEnabled = (byte)lookWasEnabled != 0;
			InputActionAsset inputActionsAsset = PlayerInputDispatcher.inputActionsAsset;
			ReadOnlyArray<InputActionMap> val = ((inputActionsAsset != null) ? inputActionsAsset.actionMaps : null);
			if (val != null)
			{
				Enumerator<InputActionMap> enumerator = val.GetEnumerator();
				while (enumerator.MoveNext())
				{
					InputActionMap current = enumerator.Current;
					if (!current.enabled)
					{
						continue;
					}
					Enumerator<InputAction> enumerator2 = current.actions.GetEnumerator();
					while (enumerator2.MoveNext())
					{
						InputAction current2 = enumerator2.Current;
						if (!current2.enabled)
						{
							_previouslyDisabledActions.Add(current2);
						}
					}
					_disabledMaps.Add(current);
					current.Disable();
				}
			}
			PlayerInputDispatcher.SetEnableLookInput(false);
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
			_window.SetActive(true);
			((Component)_scrim).gameObject.SetActive(true);
			_levelHud.SetActive(false);
			((Component)_prompt).gameObject.SetActive(false);
			IsOpen = true;
			_confirmation = null;
			_openTime = Time.unscaledTime;
			_pendingClaim = null;
			_dialog.SetActive(false);
			_receiptUntil = 0f;
			_displayXp = _view?.Xp ?? 0;
			_lastResponse = Time.unscaledTime;
			((TMP_Text)_status).text = "Loading quest board...";
			Refresh();
		}

		internal void Close()
		{
			if (IsOpen)
			{
				if (_cosmetics)
				{
					_savedFinish = _filter;
					_savedEquipment = _selection;
				}
				IsOpen = false;
				_releasePending = true;
				_window.SetActive(false);
				((Component)_scrim).gameObject.SetActive(false);
				_confirmation = null;
				_dialog.SetActive(false);
			}
		}

		private void RestoreInput()
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			foreach (InputActionMap disabledMap in _disabledMaps)
			{
				if (disabledMap != null)
				{
					disabledMap.Enable();
				}
			}
			_disabledMaps.Clear();
			foreach (InputAction previouslyDisabledAction in _previouslyDisabledActions)
			{
				if (previouslyDisabledAction != null)
				{
					previouslyDisabledAction.Disable();
				}
			}
			_previouslyDisabledActions.Clear();
			PlayerInputDispatcher.SetEnableLookInput(_lookWasEnabled);
			Cursor.lockState = _savedLock;
			Cursor.visible = _savedCursor;
			_releasePending = false;
		}

		internal void Receive(QuestView view)
		{
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			if (view == null)
			{
				return;
			}
			if (view.ProgressOnly || view.Rows.Count > 0 || _cosmetics)
			{
				UpdateLevelHud(view.Xp);
			}
			if (view.ProgressOnly)
			{
				return;
			}
			bool flag = _pendingClaim != null;
			string selectedId = Selected?.Id;
			Quest quest = ((_view == null || view.Xp <= _view.Xp) ? null : QuestCatalog.All.FirstOrDefault((Quest q) => _view.Rows.Any((QuestRow r) => r.Id == q.Id && r.State != "COMPLETED") && view.Rows.Any((QuestRow r) => r.Id == q.Id && r.State == "COMPLETED")));
			if (quest != null && IsOpen)
			{
				int num = QuestCatalog.Level(_view.Xp);
				int num2 = QuestCatalog.Level(view.Xp);
				((TMP_Text)_receipt).text = $"REWARD RECEIVED  /  {Name(quest.Reward)} x1  /  +{quest.Xp} XP" + ((num2 > num) ? $"  /  LEVEL UP: {num2}" : "");
				((Graphic)_receipt).color = _accent;
				_receiptUntil = Time.unscaledTime + 6f;
				if (SkinCatalog.RewardFor(quest.Id).Length > 0)
				{
					TextMeshProUGUI receipt = _receipt;
					((TMP_Text)receipt).text = ((TMP_Text)receipt).text + "  /  " + SkinCatalog.RewardFor(quest.Id);
				}
			}
			if (_pendingClaim != null && (view.Rows.Any((QuestRow r) => r.Id == _pendingClaim && r.State == "COMPLETED") || !string.IsNullOrEmpty(view.Message)))
			{
				_pendingClaim = null;
			}
			_view = view;
			_lastResponse = Time.unscaledTime;
			if (IsOpen && flag && _pendingClaim == null)
			{
				_dialogResult = true;
				((TMP_Text)_dialogTitle).text = ((quest != null) ? "ASSIGNMENT COMPLETE" : "TURN-IN UPDATE");
				((TMP_Text)_dialogBody).text = ((quest != null) ? (quest.Title + "\nYour reward has been delivered.") : view.Message);
				if (quest != null)
				{
					((TMP_Text)_dialogReward).text = Name(quest.Reward) + $" x1   /   +{quest.Xp} XP";
				}
				else
				{
					((TMP_Text)_dialogReward).text = "No success confirmed. Check your assignment before retrying.";
					((Behaviour)_dialogIcon).enabled = false;
				}
				if (quest != null && SkinCatalog.RewardFor(quest.Id).Length > 0)
				{
					TextMeshProUGUI dialogReward = _dialogReward;
					((TMP_Text)dialogReward).text = ((TMP_Text)dialogReward).text + "\n" + SkinCatalog.RewardFor(quest.Id);
				}
				_dialogConfirm.Enabled = false;
				((Component)_dialogConfirm.Image).gameObject.SetActive(false);
				((TMP_Text)_dialogCancel.Label).text = "CONTINUE  /  B or Esc";
				_dialog.SetActive(true);
			}
			if (!string.IsNullOrEmpty(view.Message))
			{
				((TMP_Text)_status).text = view.Message;
				_messageUntil = Time.unscaledTime + 8f;
				if (_cosmetics)
				{
					((TMP_Text)_receipt).text = view.Message;
					((Graphic)_receipt).color = _accent;
					_receiptUntil = Time.unscaledTime + 6f;
				}
			}
			Refresh();
			int num3 = _visible.FindIndex((QuestRow r) => r.Id == selectedId);
			if (num3 >= 0 && num3 != _selection)
			{
				_selection = num3;
				Refresh();
			}
		}

		internal void SetPrompt(bool visible, Vector3 boardPosition, bool riding, string talkButton, bool boardReady, string placementStatus, bool gameplay, bool cosmetics = false)
		{
			_levelHud.SetActive(gameplay && !BlockingInput && _hudXp >= 0);
			if (gameplay && Time.unscaledTime >= _nextHudTheme)
			{
				_nextHudTheme = Time.unscaledTime + 5f;
				LoadTheme();
			}
			((Component)_prompt).gameObject.SetActive(visible && !BlockingInput);
			if (visible)
			{
				((TMP_Text)_prompt).text = (riding ? "QUEST BOARD\nDismount your carpet to read the board" : (cosmetics ? ("FINISHES  /  COSMETIC STATION\n[" + talkButton + "]  Customize equipment") : ("QUEST BOARD  /  FIELD ASSIGNMENTS\n[" + talkButton + "]  Read board  /  Browse quests")));
			}
		}

		internal void Tick()
		{
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: 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_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0660: Unknown result type (might be due to invalid IL or missing references)
			//IL_0665: Unknown result type (might be due to invalid IL or missing references)
			//IL_066e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0692: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0710: Unknown result type (might be due to invalid IL or missing references)
			//IL_0716: Unknown result type (might be due to invalid IL or missing references)
			//IL_0720: Unknown result type (might be due to invalid IL or missing references)
			//IL_0707: Unknown result type (might be due to invalid IL or missing references)
			if (!Application.isFocused || !Player.isLocalPlayerLoaded || (Object)(object)Player.localPlayer == (Object)null || ((ANetworkEntity)Player.localPlayer).isDead)
			{
				_levelHud.SetActive(false);
			}
			if (_releasePending)
			{
				if (Released())
				{
					RestoreInput();
				}
			}
			else
			{
				if (!IsOpen)
				{
					return;
				}
				if (_pendingClaim != null && Time.unscaledTime - _pendingSince > 8f)
				{
					_pendingClaim = null;
					if (_dialog.activeSelf)
					{
						_dialogResult = true;
						((TMP_Text)_dialogTitle).text = "CONFIRMATION DELAYED";
						((TMP_Text)_dialogBody).text = "The host has not confirmed the turn-in. Check the refreshed quest state before retrying.";
						((Component)_dialogConfirm.Image).gameObject.SetActive(false);
						((TMP_Text)_dialogCancel.Label).text = "BACK";
					}
					((TMP_Text)_status).text = "No confirmation received. Refresh the board before retrying.";
					_messageUntil = Time.unscaledTime + 6f;
					Refresh();
				}
				if (Time.unscaledTime > _receiptUntil)
				{
					((TMP_Text)_receipt).text = (_cosmetics ? "Earn it through quests. Save your look. Equip it whenever you like." : "A safer camp. A stronger survivor. One assignment at a time.");
					((Graphic)_receipt).color = _muted;
				}
				else
				{
					((Graphic)_receipt).color = Color.Lerp(_muted, _accent, Mathf.Clamp01((_receiptUntil - Time.unscaledTime) / 0.6f));
				}
				if (_view != null)
				{
					_displayXp = ((_displayXp < 0f) ? ((float)_view.Xp) : Mathf.MoveTowards(_displayXp, (float)_view.Xp, Math.Max(120f, Math.Abs((float)_view.Xp - _displayXp) * 5f) * Time.unscaledDeltaTime));
					int num = QuestCatalog.Level((int)_displayXp);
					int num2 = QuestCatalog.Threshold(num);
					int num3 = QuestCatalog.Threshold(num + 1);
					((Graphic)_xpFill).rectTransform.anchorMax = new Vector2(Mathf.Clamp01((_displayXp - (float)num2) / (float)(num3 - num2)), 1f);
					((TMP_Text)_level).text = $"LEVEL {num:00}";
					((TMP_Text)_xp).text = $"{(int)_displayXp - num2:N0} / {num3 - num2:N0} XP\n{_view.Rows.Count((QuestRow r) => r.State == "COMPLETED")} assignments completed";
				}
				if (!Application.isFocused)
				{
					Close();
					return;
				}
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
				PlayerInputDispatcher.SetEnableLookInput(false);
				foreach (InputActionMap disabledMap in _disabledMaps)
				{
					if (disabledMap.enabled)
					{
						disabledMap.Disable();
					}
				}
				if (Time.unscaledTime - _lastResponse > 6f)
				{
					((TMP_Text)_status).text = "Waiting for the host. The host must have ContentPlus installed.";
				}
				else if (Time.unscaledTime > _messageUntil && _confirmation == null)
				{
					((TMP_Text)_status).text = ((!_cosmetics) ? ((Gamepad.current != null) ? "D-pad: browse / filter  |  A: action  |  X: abandon  |  LB/RB: page  |  B: back" : "Click: select / action  |  Wheel: browse  |  Arrow keys: browse / filter  |  Enter: action  |  Esc: back") : ((Gamepad.current != null) ? "D-pad left/right: finish  |  Up/down: equipment  |  LB/R