Decompiled source of Pilgrim v0.5.4

plugins/Pilgrim.dll

Decompiled 3 days ago
using System;
using System.Collections;
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.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Pilgrim")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ec505d5eb0f2ae61b41ece9163da03e8bc7f6e0e")]
[assembly: AssemblyProduct("Pilgrim")]
[assembly: AssemblyTitle("Pilgrim")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace EnvReporter
{
	[BepInPlugin("com.ctogle.pilgrim", "Pilgrim", "0.5.4")]
	public class Plugin : BaseUnityPlugin
	{
		internal struct LegendaryDef
		{
			public string Key;

			public string Prefab;

			public string DefaultIngredient;

			public SkillType SkillType;

			public string SkillLabel;

			public string DefaultActivateMsg;

			public string DefaultDeactivateMsg;
		}

		internal struct HuntDef
		{
			public string Key;

			public string Prefab;

			public string DefaultIngredient;

			public Biome Biome;

			public float Scale;

			public string DefaultHoverText;

			public string DefaultMessage;

			public float DefaultDistance;
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<ItemData, bool> <>9__84_0;

			public static Func<ItemData, float> <>9__88_0;

			public static Func<GameObject, bool> <>9__91_0;

			public static Func<Recipe, bool> <>9__92_0;

			public static Func<ItemData, float> <>9__95_1;

			public static Action <>9__95_0;

			public static Func<ItemData, float> <>9__96_0;

			public static FileSystemEventHandler <>9__180_0;

			public static ConsoleEvent <>9__188_0;

			public static Func<StatusEffect, string> <>9__188_25;

			public static ConsoleEvent <>9__188_1;

			public static ConsoleEvent <>9__188_2;

			public static ConsoleEvent <>9__188_3;

			public static Func<string, string> <>9__188_26;

			public static Func<string, string> <>9__188_27;

			public static ConsoleEvent <>9__188_4;

			public static ConsoleEvent <>9__188_5;

			public static ConsoleEvent <>9__188_6;

			public static ConsoleEvent <>9__188_7;

			public static ConsoleEvent <>9__188_8;

			public static ConsoleEvent <>9__188_9;

			public static ConsoleEvent <>9__188_10;

			public static ConsoleEvent <>9__188_11;

			public static ConsoleEvent <>9__188_12;

			public static ConsoleEvent <>9__188_13;

			public static Func<Collider, WearNTear> <>9__188_28;

			public static Func<WearNTear, bool> <>9__188_29;

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

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

			public static Func<WearNTear, GameObject> <>9__188_32;

			public static ConsoleEvent <>9__188_14;

			public static Func<GameObject, string> <>9__188_35;

			public static Func<string, string> <>9__188_36;

			public static ConsoleEvent <>9__188_15;

			public static Func<KeyValuePair<string, string>, string> <>9__188_37;

			public static ConsoleEvent <>9__188_16;

			public static ConsoleEvent <>9__188_17;

			public static ConsoleEvent <>9__188_18;

			public static Func<GameObject, bool> <>9__188_38;

			public static Func<GameObject, string> <>9__188_39;

			public static Func<string, bool> <>9__188_40;

			public static Func<string, string> <>9__188_41;

			public static ConsoleEvent <>9__188_19;

			public static ConsoleEvent <>9__188_20;

			public static ConsoleEvent <>9__188_21;

			public static ConsoleEvent <>9__188_22;

			public static ConsoleEvent <>9__188_23;

			public static ConsoleEvent <>9__188_24;

			public static Predicate<StatusEffect> <>9__209_0;

			public static Predicate<StatusEffect> <>9__217_0;

			public static Predicate<StatusEffect> <>9__220_0;

			public static Predicate<StatusEffect> <>9__221_0;

			public static Predicate<StatusEffect> <>9__225_0;

			public static Action<long, float> <>9__228_0;

			public static Action<long, Vector3, float> <>9__240_0;

			public static Action<long> <>9__240_1;

			public static Func<Collider, WearNTear> <>9__246_0;

			public static Func<WearNTear, bool> <>9__246_1;

			public static Action<long, ZPackage> <>9__249_0;

			public static Func<Collider, WearNTear> <>9__259_0;

			public static Func<WearNTear, GameObject> <>9__259_2;

			public static Action<long, Vector3, float> <>9__265_0;

			public static Func<Collider, WearNTear> <>9__271_0;

			public static Func<WearNTear, Vector3> <>9__271_2;

			public static Func<WearNTear, ZNetView> <>9__271_3;

			public static Func<ZNetView, bool> <>9__271_4;

			public static Func<ZNetView, ZDOID> <>9__271_5;

			public static Func<ZDOID, string> <>9__271_6;

			public static Func<Vector3, string> <>9__271_7;

			public static Func<Collider, WearNTear> <>9__272_0;

			public static Func<WearNTear, Vector3> <>9__272_2;

			public static Func<WearNTear, ZNetView> <>9__272_3;

			public static Func<ZNetView, bool> <>9__272_4;

			public static Func<ZNetView, ZDOID> <>9__272_5;

			public static Func<ZDOID, string> <>9__272_6;

			public static Func<Vector3, string> <>9__272_7;

			public static Predicate<StatusEffect> <>9__278_0;

			public static Func<ItemData, bool> <>9__281_0;

			public static Predicate<StatusEffect> <>9__283_0;

			internal bool <FindCacheItem>b__84_0(ItemData i)
			{
				return i.m_shared.m_name == "Pilgrim's Cache";
			}

			internal float <SaveCrateInvIfClosed>b__88_0(ItemData i)
			{
				return (float)i.m_stack * i.m_shared.m_weight;
			}

			internal bool <RegisterCrateItem>b__91_0(GameObject g)
			{
				if ((Object)(object)g != (Object)null)
				{
					return ((Object)g).name == "PilgrimCrate";
				}
				return false;
			}

			internal bool <RegisterCrateRecipe>b__92_0(Recipe r)
			{
				if ((Object)(object)r != (Object)null)
				{
					return ((Object)r).name == "Recipe_PilgrimCrate";
				}
				return false;
			}

			internal void <OpenCrateUI>b__95_0()
			{
				if (_crateItem != null && _crateInventory != null)
				{
					float num = _crateInventory.GetAllItems().Sum((ItemData i) => (float)i.m_stack * i.m_shared.m_weight);
					_crateItem.m_customData["pilgrim_crate_weight"] = num.ToString(CultureInfo.InvariantCulture);
				}
			}

			internal float <OpenCrateUI>b__95_1(ItemData i)
			{
				return (float)i.m_stack * i.m_shared.m_weight;
			}

			internal float <SaveAndCloseCrateUI>b__96_0(ItemData i)
			{
				return (float)i.m_stack * i.m_shared.m_weight;
			}

			internal void <Awake>b__180_0(object _, FileSystemEventArgs __)
			{
				_cfgDirty = true;
			}

			internal void <RegisterCommands>b__188_0(ConsoleEventArgs args)
			{
				//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_030f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0314: Unknown result type (might be due to invalid IL or missing references)
				//IL_0324: Unknown result type (might be due to invalid IL or missing references)
				//IL_0330: Unknown result type (might be due to invalid IL or missing references)
				EnvMan instance = EnvMan.instance;
				if ((Object)(object)instance == (Object)null)
				{
					args.Context.AddString("EnvMan not ready.");
					return;
				}
				float tod = GetTod();
				string todLabel = GetTodLabel(tod);
				string text = GetEnvSetupName(instance, "m_currentEnv") ?? "unknown";
				string text2 = GetEnvSetupName(instance, "m_nextEnv") ?? "unknown";
				string text3 = instance.m_debugEnv ?? "";
				string text4 = (((Object)(object)Scheduler != (Object)null && Scheduler.Active) ? $"ON (prob {Scheduler.Probability:P0})" : "OFF");
				double num = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetTimeSeconds() : 0.0);
				args.Context.AddString("=== World State ===");
				args.Context.AddString($"TOD         : {tod:F2}  ({todLabel})  [ZNet raw: {num:F0}s  mod1800={num % 1800.0:F0}]");
				args.Context.AddString("Current env : " + text + ((text3.Length > 0) ? ("  [forced: " + text3 + "]") : ""));
				args.Context.AddString("Next env    : " + text2);
				args.Context.AddString($"Is wet      : {EnvMan.IsWet()}");
				args.Context.AddString($"Is cold     : {EnvMan.IsCold()}");
				args.Context.AddString($"Is freezing : {EnvMan.IsFreezing()}");
				args.Context.AddString($"Wind        : {instance.GetWindIntensity():F2}  dir {instance.GetWindDir()}");
				args.Context.AddString("Scheduler   : " + text4);
				RandEventSystem instance2 = RandEventSystem.instance;
				if ((Object)(object)instance2 != (Object)null)
				{
					object obj = AnyField(instance2, "m_activeEvent", "m_currentEvent");
					if (obj != null && (!(AnyField(instance2, "m_haveActiveEvent") is bool flag) || flag) && obj != null)
					{
						string arg = (AnyField(obj, "m_name") as string) ?? "?";
						float num2 = ((AnyField(instance2, "m_eventTimer", "m_timer") is float num3) ? num3 : 0f);
						string arg2 = ((AnyField(instance2, "m_eventPos", "m_pos") is Vector3 val) ? $"({val.x:F0},{val.z:F0})" : "?");
						args.Context.AddString($"Active raid : {arg}  |  {num2:F0}s  |  @ {arg2}");
					}
					else
					{
						args.Context.AddString("Active raid : none");
					}
				}
			}

			internal void <RegisterCommands>b__188_1(ConsoleEventArgs args)
			{
				//IL_0098: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_0197: 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_020c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0214: Unknown result type (might be due to invalid IL or missing references)
				List<Player> allPlayers = Player.GetAllPlayers();
				if (allPlayers == null || allPlayers.Count == 0)
				{
					args.Context.AddString("No players found.");
					return;
				}
				args.Context.AddString($"=== Players ({allPlayers.Count}) ===");
				List<Vector3> list = new List<Vector3>();
				foreach (Player item in allPlayers)
				{
					string playerName = item.GetPlayerName();
					float health = ((Character)item).GetHealth();
					float maxHealth = ((Character)item).GetMaxHealth();
					float stamina = item.GetStamina();
					float maxStamina = ((Character)item).GetMaxStamina();
					float eitr = item.GetEitr();
					float maxEitr = ((Character)item).GetMaxEitr();
					Vector3 position = ((Component)item).transform.position;
					list.Add(position);
					string arg = ((object)item.GetCurrentBiome()/*cast due to .constrained prefix*/).ToString();
					SEMan sEMan = ((Character)item).GetSEMan();
					List<StatusEffect> list2 = ((sEMan != null) ? sEMan.GetStatusEffects() : null);
					string text = ((list2 != null && list2.Count > 0) ? string.Join(", ", list2.Select((StatusEffect e) => (!string.IsNullOrEmpty(e.m_name)) ? e.m_name : ((Object)e).name)) : "none");
					args.Context.AddString("--- " + playerName + " ---");
					args.Context.AddString($"  HP {health:F0}/{maxHealth:F0}  |  Stamina {stamina:F0}/{maxStamina:F0}  |  Eitr {eitr:F0}/{maxEitr:F0}");
					args.Context.AddString($"  Biome: {arg}  |  Pos: ({position.x:F0},{position.z:F0})");
					args.Context.AddString("  Effects: " + text);
				}
				if (list.Count <= 1)
				{
					return;
				}
				float num = 0f;
				for (int num2 = 0; num2 < list.Count; num2++)
				{
					for (int num3 = num2 + 1; num3 < list.Count; num3++)
					{
						float num4 = Vector3.Distance(list[num2], list[num3]);
						if (num4 > num)
						{
							num = num4;
						}
					}
				}
				args.Context.AddString($"Party spread: {num:F0}m");
			}

			internal string <RegisterCommands>b__188_25(StatusEffect e)
			{
				if (!string.IsNullOrEmpty(e.m_name))
				{
					return e.m_name;
				}
				return ((Object)e).name;
			}

			internal void <RegisterCommands>b__188_2(ConsoleEventArgs args)
			{
				ClearSkiesExpiry = 0f;
				RainExpiry = 0f;
				GiantRainExpiry = 0f;
				WaterWalkExpiry = 0f;
				SeekEnvExpiry = 0f;
				DungeonEnvExpiry = 0f;
				HomeEnvExpiry = 0f;
				if (GiantExpiry > 0f)
				{
					Player localPlayer = Player.m_localPlayer;
					if ((Object)(object)localPlayer != (Object)null)
					{
						DeactivateGiant(localPlayer);
					}
					else
					{
						GiantExpiry = 0f;
					}
				}
				if ((Object)(object)EnvMan.instance != (Object)null)
				{
					EnvMan.instance.m_debugEnv = "";
				}
				EnvMan instance = EnvMan.instance;
				if (instance != null)
				{
					instance.ResetDebugWind();
				}
				args.Context.AddString("Weather overrides cleared.");
			}

			internal void <RegisterCommands>b__188_3(ConsoleEventArgs args)
			{
				ActivateSeek(args.Context);
			}

			internal void <RegisterCommands>b__188_4(ConsoleEventArgs args)
			{
				EnvScheduler scheduler = Scheduler;
				if ((Object)(object)scheduler == (Object)null)
				{
					args.Context.AddString("Scheduler not ready.");
					return;
				}
				if (args.Length < 2)
				{
					PrintSchedule(args, scheduler);
					return;
				}
				switch (args[1].ToLower())
				{
				case "on":
					scheduler.Active = true;
					args.Context.AddString("Scheduler ON");
					break;
				case "off":
					scheduler.Active = false;
					args.Context.AddString("Scheduler OFF");
					break;
				case "prob":
				{
					if (args.Length >= 3 && float.TryParse(args[2], out var result))
					{
						scheduler.Probability = Mathf.Clamp01(result);
						args.Context.AddString($"Probability → {scheduler.Probability:P0}");
					}
					break;
				}
				case "night":
					if (args.Length >= 3)
					{
						scheduler.NightPool = (from x in args[2].Split(',')
							select x.Trim()).ToList();
						args.Context.AddString("Night pool → " + string.Join(", ", scheduler.NightPool));
					}
					break;
				case "noon":
					if (args.Length >= 3)
					{
						scheduler.NoonPool = (from x in args[2].Split(',')
							select x.Trim()).ToList();
						args.Context.AddString("Noon pool → " + string.Join(", ", scheduler.NoonPool));
					}
					break;
				default:
					PrintSchedule(args, scheduler);
					break;
				}
			}

			internal string <RegisterCommands>b__188_26(string x)
			{
				return x.Trim();
			}

			internal string <RegisterCommands>b__188_27(string x)
			{
				return x.Trim();
			}

			internal void <RegisterCommands>b__188_5(ConsoleEventArgs args)
			{
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null)
				{
					args.Context.AddString("No local player.");
					return;
				}
				ActivateWaterWalk(localPlayer);
				args.Context.AddString("Water walk active.");
			}

			internal void <RegisterCommands>b__188_6(ConsoleEventArgs args)
			{
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_00be: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_008f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b8: 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)
				if ((Object)(object)Scheduler == (Object)null)
				{
					args.Context.AddString("Scheduler not ready.");
					return;
				}
				string text = ((args.Length > 1) ? args[1].ToLower() : "n");
				BroadcastBird((Vector3)(text switch
				{
					"s" => new Vector3(0f, 0f, -1f), 
					"e" => new Vector3(1f, 0f, 0f), 
					"w" => new Vector3(-1f, 0f, 0f), 
					_ => new Vector3(0f, 0f, 1f), 
				}));
				args.Context.AddString("Bird away (" + text + ").");
			}

			internal void <RegisterCommands>b__188_7(ConsoleEventArgs args)
			{
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null)
				{
					args.Context.AddString("No player.");
					return;
				}
				args.Context.AddString("=== Trader State ===");
				string[] traderLocations = TraderLocations;
				foreach (string text in traderLocations)
				{
					bool flag = HasMetTrader(text);
					Vector3 result;
					string text2 = (FindClosestLocation(text, ((Component)localPlayer).transform.position, out result) ? $"{Vector3.Distance(((Component)localPlayer).transform.position, result):F0}m" : "not found");
					args.Context.AddString($"  {text}: met={flag}  dist={text2}  pos={result}");
				}
			}

			internal void <RegisterCommands>b__188_8(ConsoleEventArgs args)
			{
				args.Context.AddString("=== Campfire Rituals ===");
				args.Context.AddString("  " + SeekFood + " (Boar Meat)       → Guiding Wind — seek next boss altar");
				args.Context.AddString("  Mushroom* (Yellow Mushroom)      → Reset forsaken power cooldown");
				args.Context.AddString("  " + HomeFood + " (Dandelion)      → Guiding Wind — find your bed");
				args.Context.AddString("  " + FeatherFood + " (Feathers)    → Feather Fall — no fall damage 60s");
				args.Context.AddString("  Any Trophy                  → Dungeon Seeker — find nearest dungeon");
				args.Context.AddString($"Global cooldown: {RitualCooldownDuration}s. Hold item in slot 1, look at burning campfire, press 1.");
			}

			internal void <RegisterCommands>b__188_9(ConsoleEventArgs args)
			{
				ShowHintsEnabled = ((args.Args.Length > 1) ? (args.Args[1].ToLower() == "on") : (!ShowHintsEnabled));
				args.Context.AddString("Ritual hints: " + (ShowHintsEnabled ? "ON" : "OFF"));
			}

			internal void <RegisterCommands>b__188_10(ConsoleEventArgs args)
			{
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null)
				{
					return;
				}
				string text = ((args.Args.Length > 1) ? args.Args[1].ToLower() : "all");
				(string, bool, string, string)[] ritualItemMap = RitualItemMap;
				for (int i = 0; i < ritualItemMap.Length; i++)
				{
					(string, bool, string, string) tuple = ritualItemMap[i];
					string item = tuple.Item3;
					string item2 = tuple.Item4;
					if (!(text != "all") || !(item != text))
					{
						LearnRitual(localPlayer, item, item2);
					}
				}
				args.Context.AddString((text == "all") ? "All rituals learned." : ("Learned: " + text));
			}

			internal void <RegisterCommands>b__188_11(ConsoleEventArgs args)
			{
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null)
				{
					return;
				}
				int num = 0;
				int num2 = 0;
				HashSet<string> hashSet = new HashSet<string>();
				(string, bool, string, string)[] ritualItemMap = RitualItemMap;
				for (int i = 0; i < ritualItemMap.Length; i++)
				{
					(string, bool, string, string) tuple = ritualItemMap[i];
					string item = tuple.Item1;
					bool item2 = tuple.Item2;
					string item3 = tuple.Item3;
					RitualItemConfig value;
					string text = ((!item2) ? item : (Cfg.Rituals.Items.TryGetValue(item3, out value) ? value.Item.TrimEnd('*') : item));
					if (hashSet.Add(text))
					{
						if (((Humanoid)localPlayer).GetInventory().AddItem(text, 1, 1, 0, 0L, "", false) != null)
						{
							num++;
						}
						else
						{
							num2++;
						}
					}
				}
				args.Context.AddString($"Ritual kit: {num} items added, {num2} prefabs not found.");
			}

			internal void <RegisterCommands>b__188_12(ConsoleEventArgs args)
			{
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null)
				{
					return;
				}
				string text = ((args.Args.Length > 1) ? args.Args[1].ToLower() : "all");
				(string, bool, string, string)[] ritualItemMap = RitualItemMap;
				for (int i = 0; i < ritualItemMap.Length; i++)
				{
					string item = ritualItemMap[i].Item3;
					if (!(text != "all") || !(item != text))
					{
						localPlayer.m_customData.Remove("ath_known_" + item);
					}
				}
				args.Context.AddString((text == "all") ? "All rituals forgotten." : ("Forgotten: " + text));
			}

			internal void <RegisterCommands>b__188_13(ConsoleEventArgs args)
			{
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null)
				{
					return;
				}
				List<string> list = new List<string>();
				(string, bool, string, string)[] ritualItemMap = RitualItemMap;
				for (int i = 0; i < ritualItemMap.Length; i++)
				{
					string item = ritualItemMap[i].Item3;
					string key = "ath_uses_" + item;
					if (localPlayer.m_customData.TryGetValue(key, out var value))
					{
						list.Add("  " + item + ": " + value);
					}
				}
				if (list.Count == 0)
				{
					args.Context.AddString("No rituals performed yet.");
					return;
				}
				list.Sort();
				args.Context.AddString("Ritual usage:");
				foreach (string item2 in list)
				{
					args.Context.AddString(item2);
				}
			}

			internal void <RegisterCommands>b__188_14(ConsoleEventArgs args)
			{
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_0202: Unknown result type (might be due to invalid IL or missing references)
				//IL_0219: Unknown result type (might be due to invalid IL or missing references)
				//IL_0232: Unknown result type (might be due to invalid IL or missing references)
				//IL_023c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0241: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0258: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e6: 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_01dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_054f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0568: Unknown result type (might be due to invalid IL or missing references)
				//IL_0581: 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_0611: Unknown result type (might be due to invalid IL or missing references)
				//IL_062a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0631: Unknown result type (might be due to invalid IL or missing references)
				//IL_0638: Unknown result type (might be due to invalid IL or missing references)
				//IL_063f: Unknown result type (might be due to invalid IL or missing references)
				//IL_061e: Unknown result type (might be due to invalid IL or missing references)
				//IL_06fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_070c: Unknown result type (might be due to invalid IL or missing references)
				//IL_071b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0653: Unknown result type (might be due to invalid IL or missing references)
				//IL_06c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0663: Unknown result type (might be due to invalid IL or missing references)
				//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0677: Unknown result type (might be due to invalid IL or missing references)
				<>c__DisplayClass188_0 CS$<>8__locals4 = new <>c__DisplayClass188_0
				{
					player = Player.m_localPlayer
				};
				if ((Object)(object)CS$<>8__locals4.player == (Object)null)
				{
					return;
				}
				WearNTear val = (from c in Physics.OverlapSphere(((Component)CS$<>8__locals4.player).transform.position, 5f)
					select ((Component)c).GetComponentInParent<WearNTear>() into w
					where (Object)(object)w != (Object)null && (Object)(object)((Component)w).GetComponent<Piece>() != (Object)null
					orderby Vector3.Distance(((Component)w).transform.position, ((Component)CS$<>8__locals4.player).transform.position)
					select w).FirstOrDefault();
				if ((Object)(object)val == (Object)null)
				{
					args.Context.AddString("[inspect] No structure within 5m.");
					return;
				}
				HashSet<WearNTear> hashSet = FloodFillStructure(val);
				SortedDictionary<string, int> sortedDictionary = new SortedDictionary<string, int>();
				SortedDictionary<string, int> sortedDictionary2 = new SortedDictionary<string, int>();
				Bounds val2 = default(Bounds);
				bool flag = false;
				int num = 0;
				float num2 = 0f;
				int num3 = 0;
				float num4 = float.MaxValue;
				float num5 = float.MinValue;
				int num6 = 0;
				FieldInfo field = typeof(WearNTear).GetField("m_support", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				MethodInfo method = typeof(WearNTear).GetMethod("GetMaxSupport", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				int mask = LayerMask.GetMask(new string[1] { "terrain" });
				RaycastHit val4 = default(RaycastHit);
				foreach (WearNTear item in hashSet)
				{
					string text = ((Object)((Component)item).gameObject).name.Replace("(Clone)", "").Trim().ToLower();
					string key = ((Object)((Component)item).gameObject).name.Replace("(Clone)", "").Trim();
					sortedDictionary.TryGetValue(key, out var value);
					sortedDictionary[key] = value + 1;
					Collider[] componentsInChildren = ((Component)item).GetComponentsInChildren<Collider>();
					foreach (Collider val3 in componentsInChildren)
					{
						if (!val3.isTrigger)
						{
							Bounds bounds = val3.bounds;
							if (!flag)
							{
								val2 = bounds;
								flag = true;
							}
							else
							{
								((Bounds)(ref val2)).Encapsulate(bounds);
							}
						}
					}
					float y = ((Component)item).transform.position.y;
					float num8 = y;
					if (Physics.Raycast(new Vector3(((Component)item).transform.position.x, y + 50f, ((Component)item).transform.position.z), Vector3.down, ref val4, 200f, mask))
					{
						num8 = ((RaycastHit)(ref val4)).point.y;
					}
					if (y <= num8 + 1f)
					{
						num++;
					}
					if (text.Contains("roof"))
					{
						num3++;
					}
					if (field != null)
					{
						float num9 = (float)(field.GetValue(item) ?? ((object)0f));
						float num10 = ((method != null) ? ((float)(method.Invoke(item, null) ?? ((object)num9))) : num9);
						if (num9 < num4)
						{
							num4 = num9;
						}
						if (num9 > num5)
						{
							num5 = num9;
						}
						if (num10 > 0f && num9 >= num10 * 0.99f)
						{
							num6++;
						}
					}
					ZNetView component = ((Component)item).GetComponent<ZNetView>();
					if ((Object)(object)component != (Object)null)
					{
						float num11 = num2;
						ZDO zDO = component.GetZDO();
						num2 = num11 + ((((zDO != null) ? new float?(zDO.GetFloat(ZDOVars.s_health, item.m_health)) : ((float?)null)) / item.m_health) ?? 1f);
					}
					else
					{
						num2 += 1f;
					}
					Piece component2 = ((Component)item).GetComponent<Piece>();
					if (component2?.m_resources == null)
					{
						continue;
					}
					Requirement[] resources = component2.m_resources;
					foreach (Requirement val5 in resources)
					{
						if (val5?.m_resItem?.m_itemData?.m_shared?.m_name != null && val5.m_amount > 0)
						{
							string key2 = ((Object)((Component)val5.m_resItem).gameObject).name.Replace("(Clone)", "").Trim();
							sortedDictionary2.TryGetValue(key2, out var value2);
							sortedDictionary2[key2] = value2 + val5.m_amount;
						}
					}
				}
				int num12 = 0;
				SortedDictionary<string, int> sortedDictionary3 = new SortedDictionary<string, int>();
				foreach (WearNTear item2 in hashSet)
				{
					Piece component3 = ((Component)item2).GetComponent<Piece>();
					if ((Object)(object)component3 != (Object)null && component3.m_comfort > num12)
					{
						num12 = component3.m_comfort;
					}
					if ((Object)(object)((Component)item2).GetComponent<CraftingStation>() != (Object)null || (Object)(object)((Component)item2).GetComponent<StationExtension>() != (Object)null)
					{
						string key3 = ((Object)((Component)item2).gameObject).name.Replace("(Clone)", "").Trim();
						sortedDictionary3.TryGetValue(key3, out var value3);
						sortedDictionary3[key3] = value3 + 1;
					}
				}
				int count = hashSet.Count;
				float num13 = (flag ? ((Bounds)(ref val2)).size.y : 0f);
				float num14 = (flag ? ((Bounds)(ref val2)).size.x : 0f);
				float num15 = (flag ? ((Bounds)(ref val2)).size.z : 0f);
				float num16 = Mathf.Sqrt(num14 * num14 + num15 * num15);
				string text2 = ((num16 < 0.1f) ? "point" : ((num13 / num16 > 1.5f) ? "tower" : ((num13 / num16 > 0.6f) ? "balanced" : "hall")));
				float num17 = ((count > 0) ? (num2 / (float)count * 100f) : 0f);
				int num18 = 0;
				int num19 = 0;
				if (flag)
				{
					float num20 = 1f;
					Vector3 center = ((Bounds)(ref val2)).center;
					ZoneSystem instance = ZoneSystem.instance;
					float num21 = ((instance != null) ? instance.GetSolidHeight(new Vector3(center.x, center.y, center.z)) : ((Bounds)(ref val2)).min.y) + 1f;
					float num24 = default(float);
					bool flag2 = default(bool);
					for (float num22 = ((Bounds)(ref val2)).min.x; num22 <= ((Bounds)(ref val2)).max.x; num22 += num20)
					{
						for (float num23 = ((Bounds)(ref val2)).min.z; num23 <= ((Bounds)(ref val2)).max.z; num23 += num20)
						{
							Cover.GetCoverForPoint(new Vector3(num22, num21, num23), ref num24, ref flag2, 0.5f);
							num19++;
							if (num24 > 0f)
							{
								num18++;
							}
						}
					}
				}
				float num25 = ((num19 > 0) ? ((float)num18 / (float)num19 * 100f) : 0f);
				args.Context.AddString($"[inspect dbg] bounds={((Bounds)(ref val2)).min:F1} to {((Bounds)(ref val2)).max:F1} sampleY={((Bounds)(ref val2)).min.y + 0.5f:F1} sheltered={num18}/{num19}");
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.AppendLine($"<color=orange>── Structure ({count} pieces) ──</color>");
				stringBuilder.AppendLine($"Height: <color=white>{num13:F1}m</color>  Footprint: <color=white>{num14:F0}x{num15:F0}m</color>  Shape: <color=white>{text2}</color>");
				stringBuilder.AppendLine($"Ground: <color=white>{num}</color>  Roof: <color=white>{num3}</color>  Shelter: <color=white>{num25:F0}%</color>  Health: <color=white>{num17:F0}%</color>");
				if (field != null)
				{
					stringBuilder.AppendLine($"Support: full={num6}/{count}  min={num4:F0}  max={num5:F0}");
				}
				stringBuilder.AppendLine($"Comfort: <color=white>{num12}</color>");
				string text3 = string.Join("  ", sortedDictionary2.Select((KeyValuePair<string, int> kv) => $"<color=yellow>{kv.Key}</color>×{kv.Value}"));
				stringBuilder.AppendLine("Materials: " + text3);
				if (sortedDictionary3.Count > 0)
				{
					string text4 = string.Join("  ", sortedDictionary3.Select((KeyValuePair<string, int> kv) => $"<color=cyan>{kv.Key}</color>×{kv.Value}"));
					stringBuilder.AppendLine("Stations: " + text4);
				}
				stringBuilder.AppendLine("<color=grey>────────────────</color>");
				foreach (KeyValuePair<string, int> item3 in sortedDictionary)
				{
					stringBuilder.AppendLine($"  <color=yellow>{item3.Key}</color>: {item3.Value}");
				}
				string text5 = stringBuilder.ToString().TrimEnd();
				args.Context.AddString(text5);
				MessageHudTimerPatch.ExtendNextCenter = true;
				((Character)CS$<>8__locals4.player).Message((MessageType)2, text5, 0, (Sprite)null);
				((MonoBehaviour)plugin).StartCoroutine(FlashPieces(hashSet.Select((WearNTear w) => ((Component)w).gameObject).ToList()));
			}

			internal WearNTear <RegisterCommands>b__188_28(Collider c)
			{
				return ((Component)c).GetComponentInParent<WearNTear>();
			}

			internal bool <RegisterCommands>b__188_29(WearNTear w)
			{
				if ((Object)(object)w != (Object)null)
				{
					return (Object)(object)((Component)w).GetComponent<Piece>() != (Object)null;
				}
				return false;
			}

			internal string <RegisterCommands>b__188_31(KeyValuePair<string, int> kv)
			{
				return $"<color=yellow>{kv.Key}</color>×{kv.Value}";
			}

			internal string <RegisterCommands>b__188_33(KeyValuePair<string, int> kv)
			{
				return $"<color=cyan>{kv.Key}</color>×{kv.Value}";
			}

			internal GameObject <RegisterCommands>b__188_32(WearNTear w)
			{
				return ((Component)w).gameObject;
			}

			internal void <RegisterCommands>b__188_15(ConsoleEventArgs args)
			{
				<>c__DisplayClass188_1 CS$<>8__locals4 = new <>c__DisplayClass188_1();
				ZNetScene instance = ZNetScene.instance;
				if ((Object)(object)instance == (Object)null)
				{
					args.Context.AddString("ZNetScene not ready.");
					return;
				}
				BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
				if (!(typeof(ZNetScene).GetField("m_namedPrefabs", bindingAttr)?.GetValue(instance) is Dictionary<int, GameObject> dictionary))
				{
					args.Context.AddString("Could not read prefab list.");
					return;
				}
				CS$<>8__locals4.pattern = ((args.Length > 1) ? args[1].ToLower() : "");
				List<string> list = (from g in dictionary.Values
					where (Object)(object)g != (Object)null && (string.IsNullOrEmpty(CS$<>8__locals4.pattern) || ((Object)g).name.ToLower().Contains(CS$<>8__locals4.pattern))
					select ((Object)g).name into n
					orderby n
					select n).ToList();
				args.Context.AddString($"=== {list.Count} prefabs matching '{CS$<>8__locals4.pattern}' ===");
				foreach (string item in list)
				{
					args.Context.AddString("  " + item);
				}
			}

			internal string <RegisterCommands>b__188_35(GameObject g)
			{
				return ((Object)g).name;
			}

			internal string <RegisterCommands>b__188_36(string n)
			{
				return n;
			}

			internal void <RegisterCommands>b__188_16(ConsoleEventArgs args)
			{
				ZNetScene instance = ZNetScene.instance;
				if ((Object)(object)instance == (Object)null)
				{
					args.Context.AddString("ZNetScene not ready.");
					return;
				}
				BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
				if (!(typeof(ZNetScene).GetField("m_namedPrefabs", bindingAttr)?.GetValue(instance) is Dictionary<int, GameObject> dictionary))
				{
					args.Context.AddString("Could not read prefab list.");
					return;
				}
				Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
				foreach (GameObject value in dictionary.Values)
				{
					if ((Object)(object)value == (Object)null)
					{
						continue;
					}
					Renderer[] componentsInChildren = value.GetComponentsInChildren<Renderer>(true);
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						Material[] sharedMaterials = componentsInChildren[i].sharedMaterials;
						foreach (Material val in sharedMaterials)
						{
							if ((Object)(object)val == (Object)null || (Object)(object)val.shader == (Object)null)
							{
								continue;
							}
							string name = ((Object)val.shader).name;
							if (val.renderQueue >= 2450 || name.Contains("Transparent") || name.Contains("Alpha") || name.Contains("Particle") || name.Contains("Unlit"))
							{
								string key = ((Object)val).name + " | " + name;
								if (!dictionary2.ContainsKey(key))
								{
									dictionary2[key] = ((Object)value).name;
								}
							}
						}
					}
				}
				args.Context.AddString($"=== {dictionary2.Count} transparent materials ===");
				foreach (KeyValuePair<string, string> item in dictionary2.OrderBy((KeyValuePair<string, string> k) => k.Key))
				{
					args.Context.AddString("  " + item.Key + "  (eg: " + item.Value + ")");
				}
			}

			internal string <RegisterCommands>b__188_37(KeyValuePair<string, string> k)
			{
				return k.Key;
			}

			internal void <RegisterCommands>b__188_17(ConsoleEventArgs args)
			{
				if (args.Length < 2)
				{
					args.Context.AddString("Usage: ath_mats <prefabName>");
					return;
				}
				ZNetScene instance = ZNetScene.instance;
				GameObject val = ((instance != null) ? instance.GetPrefab(args[1]) : null);
				if ((Object)(object)val == (Object)null)
				{
					args.Context.AddString("Prefab '" + args[1] + "' not found.");
					return;
				}
				Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val2 in componentsInChildren)
				{
					Material[] sharedMaterials = val2.sharedMaterials;
					foreach (Material val3 in sharedMaterials)
					{
						if ((Object)(object)val3 != (Object)null)
						{
							Terminal context = args.Context;
							string[] obj = new string[6]
							{
								"  ",
								((Object)((Component)val2).gameObject).name,
								" | ",
								((Object)val3).name,
								" | ",
								null
							};
							Shader shader = val3.shader;
							obj[5] = ((shader != null) ? ((Object)shader).name : null);
							context.AddString(string.Concat(obj));
						}
					}
				}
			}

			internal void <RegisterCommands>b__188_18(ConsoleEventArgs args)
			{
				//IL_019a: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a1: Expected O, but got Unknown
				//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0205: Unknown result type (might be due to invalid IL or missing references)
				if (args.Length < 2)
				{
					args.Context.AddString("Usage: ath_wardmat <matName>");
					return;
				}
				Renderer activeCampfireWardRend = ActiveCampfireWardRend;
				if ((Object)(object)activeCampfireWardRend == (Object)null)
				{
					args.Context.AddString("[wardmat] No active campfire ward.");
					return;
				}
				string text = args[1].ToLower();
				ZNetScene instance = ZNetScene.instance;
				if ((Object)(object)instance == (Object)null)
				{
					args.Context.AddString("ZNetScene not ready.");
					return;
				}
				BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
				if (!(typeof(ZNetScene).GetField("m_namedPrefabs", bindingAttr)?.GetValue(instance) is Dictionary<int, GameObject> dictionary))
				{
					args.Context.AddString("Could not read prefab list.");
					return;
				}
				Material val = null;
				string text2 = null;
				foreach (GameObject value in dictionary.Values)
				{
					if ((Object)(object)value == (Object)null)
					{
						continue;
					}
					Renderer[] componentsInChildren = value.GetComponentsInChildren<Renderer>(true);
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						Material[] sharedMaterials = componentsInChildren[i].sharedMaterials;
						foreach (Material val2 in sharedMaterials)
						{
							if ((Object)(object)val2 != (Object)null && ((Object)val2).name.ToLower() == text)
							{
								val = val2;
								text2 = ((Object)value).name;
								break;
							}
						}
					}
					if ((Object)(object)val != (Object)null)
					{
						break;
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					args.Context.AddString("[wardmat] Material '" + args[1] + "' not found in any prefab.");
					return;
				}
				Material val3 = new Material(val);
				val3.SetInt("_Cull", 0);
				if (val3.HasProperty("_Color"))
				{
					val3.color = new Color(0.55f, 0f, 1f, 0.15f);
				}
				if (val3.HasProperty("_TintColor"))
				{
					val3.SetColor("_TintColor", new Color(0.55f, 0f, 1f, 0.15f));
				}
				activeCampfireWardRend.material = val3;
				Terminal context = args.Context;
				string[] obj = new string[6]
				{
					"[wardmat] Applied '",
					((Object)val).name,
					"' (shader: ",
					null,
					null,
					null
				};
				Shader shader = val.shader;
				obj[3] = ((shader != null) ? ((Object)shader).name : null);
				obj[4] = ") from ";
				obj[5] = text2;
				context.AddString(string.Concat(obj));
			}

			internal void <RegisterCommands>b__188_19(ConsoleEventArgs args)
			{
				//IL_01d4: 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)
				ZNetScene instance = ZNetScene.instance;
				if ((Object)(object)instance == (Object)null)
				{
					args.Context.AddString("ZNetScene not ready.");
					return;
				}
				BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
				Dictionary<int, GameObject> dictionary = typeof(ZNetScene).GetField("m_namedPrefabs", bindingAttr)?.GetValue(instance) as Dictionary<int, GameObject>;
				if (args.Length < 2 || args[1] == "list")
				{
					if (dictionary == null)
					{
						args.Context.AddString("Could not read prefab list.");
						return;
					}
					List<string> list = (from g in dictionary.Values
						where (Object)(object)g != (Object)null
						select ((Object)g).name into n
						where n.StartsWith("vfx_") || n.StartsWith("fx_") || n.StartsWith("sfx_")
						orderby n
						select n).ToList();
					args.Context.AddString($"=== {list.Count} VFX prefabs ===");
					{
						foreach (string item in list)
						{
							args.Context.AddString("  " + item);
						}
						return;
					}
				}
				Player localPlayer = Player.m_localPlayer;
				if (!((Object)(object)localPlayer == (Object)null))
				{
					GameObject prefab = instance.GetPrefab(args[1]);
					if ((Object)(object)prefab == (Object)null)
					{
						args.Context.AddString("Prefab '" + args[1] + "' not found.");
						return;
					}
					Object.Instantiate<GameObject>(prefab, ((Component)localPlayer).transform.position, Quaternion.identity);
					args.Context.AddString("Spawned " + args[1]);
				}
			}

			internal bool <RegisterCommands>b__188_38(GameObject g)
			{
				return (Object)(object)g != (Object)null;
			}

			internal string <RegisterCommands>b__188_39(GameObject g)
			{
				return ((Object)g).name;
			}

			internal bool <RegisterCommands>b__188_40(string n)
			{
				if (!n.StartsWith("vfx_") && !n.StartsWith("fx_"))
				{
					return n.StartsWith("sfx_");
				}
				return true;
			}

			internal string <RegisterCommands>b__188_41(string n)
			{
				return n;
			}

			internal void <RegisterCommands>b__188_20(ConsoleEventArgs args)
			{
				if (args.Length < 2)
				{
					args.Context.AddString("Usage: ath_cleanup_vfx <prefabName>");
					return;
				}
				string text = args[1];
				ZNetScene instance = ZNetScene.instance;
				ZDOMan instance2 = ZDOMan.instance;
				if ((Object)(object)instance == (Object)null || instance2 == null)
				{
					args.Context.AddString("Not ready.");
					return;
				}
				List<ZDO> list = new List<ZDO>();
				int num = 0;
				int num2 = 0;
				while (!instance2.GetAllZDOsWithPrefabIterative(text, list, ref num))
				{
				}
				foreach (ZDO item in list)
				{
					ZNetView val = instance.FindInstance(item);
					if ((Object)(object)val != (Object)null)
					{
						ZNetScene.instance.Destroy(((Component)val).gameObject);
						num2++;
					}
					else
					{
						instance2.DestroyZDO(item);
						num2++;
					}
				}
				args.Context.AddString($"Destroyed {num2} instances of '{text}'.");
			}

			internal void <RegisterCommands>b__188_21(ConsoleEventArgs args)
			{
				Player localPlayer = Player.m_localPlayer;
				if (!((Object)(object)localPlayer == (Object)null))
				{
					Vagon val = CartUpgrade.FindNearest(localPlayer, 10f);
					if ((Object)(object)val == (Object)null)
					{
						args.Context.AddString("No cart within 10m.");
					}
					else
					{
						CartUpgrade.Upgrade(localPlayer, val, args);
					}
				}
			}

			internal void <RegisterCommands>b__188_22(ConsoleEventArgs args)
			{
				EnvMan instance = EnvMan.instance;
				if ((Object)(object)instance == (Object)null)
				{
					args.Context.AddString("EnvMan not ready.");
					return;
				}
				args.Context.AddString($"=== Environments ({instance.m_environments.Count}) ===");
				foreach (EnvSetup environment in instance.m_environments)
				{
					args.Context.AddString("  " + environment.m_name);
				}
			}

			internal void <RegisterCommands>b__188_23(ConsoleEventArgs args)
			{
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null)
				{
					return;
				}
				int num = 0;
				MonoBehaviour[] array = Object.FindObjectsOfType<MonoBehaviour>();
				foreach (MonoBehaviour val in array)
				{
					if ((Object)(object)val == (Object)null || ((object)val).GetType().Name != "RandomFlyingBird" || Vector3.Distance(((Component)val).transform.position, ((Component)localPlayer).transform.position) > 60f)
					{
						continue;
					}
					num++;
					args.Context.AddString($"--- Bird {num} ({((Object)((Component)val).gameObject).name}) ---");
					BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
					FieldInfo[] fields = ((object)val).GetType().GetFields(bindingAttr);
					foreach (FieldInfo fieldInfo in fields)
					{
						try
						{
							args.Context.AddString($"  {fieldInfo.FieldType.Name} {fieldInfo.Name} = {fieldInfo.GetValue(val)}");
						}
						catch
						{
						}
					}
					Component[] componentsInChildren = ((Component)val).GetComponentsInChildren<Component>();
					foreach (Component val2 in componentsInChildren)
					{
						PropertyInfo propertyInfo = ((object)val2)?.GetType().GetProperty("parameters");
						if (propertyInfo == null || !(propertyInfo.GetValue(val2) is Array array2))
						{
							continue;
						}
						foreach (object item in array2)
						{
							PropertyInfo property = item.GetType().GetProperty("name");
							PropertyInfo property2 = item.GetType().GetProperty("type");
							args.Context.AddString($"  Anim param: {property?.GetValue(item)} ({property2?.GetValue(item)})");
						}
					}
				}
				if (num == 0)
				{
					args.Context.AddString("No birds within 60m.");
				}
			}

			internal void <RegisterCommands>b__188_24(ConsoleEventArgs args)
			{
				EnvMan instance = EnvMan.instance;
				if ((Object)(object)instance == (Object)null)
				{
					args.Context.AddString("EnvMan not ready.");
					return;
				}
				FieldInfo[] fields = typeof(EnvMan).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (FieldInfo fieldInfo in fields)
				{
					string name = fieldInfo.Name;
					if (name.ToLower().Contains("env") || name.ToLower().Contains("current") || name.ToLower().Contains("debug") || name.ToLower().Contains("time"))
					{
						object value = fieldInfo.GetValue(instance);
						string text = ((value == null) ? "null" : value.ToString());
						EnvSetup val = (EnvSetup)((value is EnvSetup) ? value : null);
						if (val != null)
						{
							text = "EnvSetup(" + val.m_name + ")";
						}
						args.Context.AddString(fieldInfo.FieldType.Name + " " + name + " = " + text);
					}
				}
			}

			internal bool <ApplySeekTargetLocal>b__209_0(StatusEffect s)
			{
				return ((Object)s).name == "SE_GuidingWind";
			}

			internal bool <ActivateHomeSeek>b__217_0(StatusEffect s)
			{
				return ((Object)s).name == "SE_GuidingWind";
			}

			internal bool <ActivateWaterWalk>b__220_0(StatusEffect s)
			{
				return ((Object)s).name == "SE_WaterWalk";
			}

			internal bool <ActivateGiant>b__221_0(StatusEffect s)
			{
				return ((Object)s).name == "SE_Giant";
			}

			internal bool <ActivateBurden>b__225_0(StatusEffect s)
			{
				return ((Object)s).name == "SE_Burden";
			}

			internal void <RegisterShieldBubbleRPC>b__228_0(long sender, float duration)
			{
				Player localPlayer = Player.m_localPlayer;
				if (!((Object)(object)localPlayer == (Object)null))
				{
					ApplyShieldBubble(localPlayer, duration);
				}
			}

			internal void <RegisterCampfireWardRPC>b__240_0(long sender, Vector3 pos, float duration)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				SpawnCampfireWard(pos, duration, null);
			}

			internal void <RegisterCampfireWardRPC>b__240_1(long sender)
			{
				CampfireWardExpiry = 0f;
				if ((Object)(object)ActiveCampfireWard != (Object)null)
				{
					Object.Destroy((Object)(object)ActiveCampfireWard);
					ActiveCampfireWard = null;
				}
			}

			internal WearNTear <ActivateRepair>b__246_0(Collider c)
			{
				return ((Component)c).GetComponentInParent<WearNTear>();
			}

			internal bool <ActivateRepair>b__246_1(WearNTear w)
			{
				if ((Object)(object)w != (Object)null)
				{
					return (Object)(object)((Component)w).GetComponent<Piece>() != (Object)null;
				}
				return false;
			}

			internal void <RegisterStructureRitualRPC>b__249_0(long sender, ZPackage pkg)
			{
				//IL_0015: 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)
				int num = pkg.ReadInt();
				List<Vector3> list = new List<Vector3>(num);
				for (int i = 0; i < num; i++)
				{
					list.Add(pkg.ReadVector3());
				}
				float duration = pkg.ReadSingle();
				int seHash = pkg.ReadInt();
				float fireDamage = pkg.ReadSingle();
				string vfxPrefabName = pkg.ReadString();
				float vfxScale = pkg.ReadSingle();
				string vfxPrefabName2 = pkg.ReadString();
				Color tint = default(Color);
				((Color)(ref tint))..ctor(pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle());
				float lightMult = pkg.ReadSingle();
				float smokeInterval = pkg.ReadSingle();
				((MonoBehaviour)plugin).StartCoroutine(StructureRitualTick(list, duration, seHash, fireDamage, vfxPrefabName, null, null, null, vfxScale, tint, lightMult, vfxPrefabName2, smokeInterval));
			}

			internal WearNTear <ActivateStructureRitual>b__259_0(Collider c)
			{
				return ((Component)c).GetComponentInParent<WearNTear>();
			}

			internal GameObject <ActivateStructureRitual>b__259_2(WearNTear w)
			{
				return ((Component)w).gameObject;
			}

			internal void <RegisterClearMistRPC>b__265_0(long _, Vector3 pos, float duration)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				SpawnDemisterLocal(pos, duration);
			}

			internal WearNTear <ActivateTreeStand>b__271_0(Collider c)
			{
				return ((Component)c).GetComponentInParent<WearNTear>();
			}

			internal Vector3 <ActivateTreeStand>b__271_2(WearNTear w)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				return ProjectToTerrain(((Component)w).transform.position);
			}

			internal ZNetView <ActivateTreeStand>b__271_3(WearNTear w)
			{
				return ((Component)w).GetComponent<ZNetView>();
			}

			internal bool <ActivateTreeStand>b__271_4(ZNetView zv)
			{
				if ((Object)(object)zv != (Object)null)
				{
					return zv.IsValid();
				}
				return false;
			}

			internal ZDOID <ActivateTreeStand>b__271_5(ZNetView zv)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				return zv.GetZDO().m_uid;
			}

			internal string <ActivateTreeStand>b__271_6(ZDOID id)
			{
				return $"{((ZDOID)(ref id)).UserID}:{((ZDOID)(ref id)).ID}";
			}

			internal string <ActivateTreeStand>b__271_7(Vector3 p)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				return $"{p.x:F2},{p.y:F2},{p.z:F2}";
			}

			internal WearNTear <ActivateRockStand>b__272_0(Collider c)
			{
				return ((Component)c).GetComponentInParent<WearNTear>();
			}

			internal Vector3 <ActivateRockStand>b__272_2(WearNTear w)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				return ProjectToTerrain(((Component)w).transform.position);
			}

			internal ZNetView <ActivateRockStand>b__272_3(WearNTear w)
			{
				return ((Component)w).GetComponent<ZNetView>();
			}

			internal bool <ActivateRockStand>b__272_4(ZNetView zv)
			{
				if ((Object)(object)zv != (Object)null)
				{
					return zv.IsValid();
				}
				return false;
			}

			internal ZDOID <ActivateRockStand>b__272_5(ZNetView zv)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				return zv.GetZDO().m_uid;
			}

			internal string <ActivateRockStand>b__272_6(ZDOID id)
			{
				return $"{((ZDOID)(ref id)).UserID}:{((ZDOID)(ref id)).ID}";
			}

			internal string <ActivateRockStand>b__272_7(Vector3 p)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				return $"{p.x:F2},{p.y:F2},{p.z:F2}";
			}

			internal bool <ActivateLegendaryWeapon>b__278_0(StatusEffect s)
			{
				return ((Object)s).name == "SE_LegendaryWeapon";
			}

			internal bool <FinishLegendarySwapBack>b__281_0(ItemData i)
			{
				GameObject dropPrefab = i.m_dropPrefab;
				return ((dropPrefab != null) ? ((Object)dropPrefab).name : null) == _legendaryActivePrefab;
			}

			internal bool <RelinquishAll>b__283_0(StatusEffect s)
			{
				return s is SE_Shield;
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass188_0
		{
			public Player player;

			internal float <RegisterCommands>b__30(WearNTear w)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				return Vector3.Distance(((Component)w).transform.position, ((Component)player).transform.position);
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass188_1
		{
			public string pattern;

			internal bool <RegisterCommands>b__34(GameObject g)
			{
				if ((Object)(object)g != (Object)null)
				{
					if (!string.IsNullOrEmpty(pattern))
					{
						return ((Object)g).name.ToLower().Contains(pattern);
					}
					return true;
				}
				return false;
			}
		}

		internal static Plugin plugin = null;

		internal static ManualLogSource Log = null;

		internal static EnvScheduler? Scheduler;

		internal static SE_GuidingWind? GuidingWindSE;

		internal static SE_WaterWalk? WaterWalkSE;

		internal static SE_Giant? GiantSE;

		internal static SE_Burden? BurdenSE;

		internal static SE_LegendaryWeapon? LegendarySE;

		internal static SE_Shield? ShieldBubbleSE;

		internal static Material? WardSphereMat;

		internal static PilgrimConfig Cfg = PilgrimConfig.Default();

		private static bool _cfgDirty = false;

		private static FileSystemWatcher? _cfgWatcher;

		internal static readonly Dictionary<string, string> TreeStandSeeds = new Dictionary<string, string>
		{
			{ "FirCone", "FirTree" },
			{ "PineCone", "Pinetree_01" },
			{ "Acorn", "Oak1" },
			{ "BeechSeeds", "Beech1" },
			{ "BirchSeeds", "Birch1" }
		};

		internal static Vector3? SeekOverrideTarget = null;

		internal static Vector3? BossSeekTarget = null;

		internal const string CratePrefabName = "PilgrimCrate";

		internal const string CrateDataKey = "pilgrim_crate";

		internal static readonly string[] CrateMetals = new string[8] { "Copper", "Tin", "Bronze", "Iron", "Silver", "BlackMetal", "Flametal", "Coins" };

		internal static GameObject? _cratePrefabGo;

		internal static bool _suppressZNetViewAwake = false;

		internal static bool _suppressContainerAwake = false;

		internal static ItemData? _crateItem;

		internal static Inventory? _crateInventory;

		internal static Container? _fakeCrateContainer;

		internal static GameObject? _fakeCrateGo;

		internal static bool _closingCrateUI = false;

		internal static bool _crateUIOpen = false;

		internal static bool _openingCrateUI = false;

		internal static bool _hidingInventory = false;

		internal static Container? _previousContainer = null;

		internal static bool _suppressSpawnSet = false;

		internal static Recipe? _crateRecipe = null;

		internal static Requirement[]? _crateCraftResources = null;

		internal static readonly (string prefab, int amount)[] CrateUpgrades = new(string, int)[6]
		{
			("", 0),
			("", 0),
			("Bronze", 5),
			("Iron", 4),
			("Silver", 6),
			("BlackMetal", 8)
		};

		private static Inventory? _closedCrateInvCache;

		private static string? _closedCrateInvCacheKey;

		internal static readonly (string Match, bool Prefix, string Key, string Display)[] RitualItemMap = new(string, bool, string, string)[46]
		{
			("BjornMeat", false, "seek_altar", "Bear Meat"),
			("Dandelion", false, "seek_bed", "Dandelion"),
			("Coins", false, "seek_trader", "Coins"),
			("Trophy", true, "seek_dungeon", "Trophy"),
			("Flint", false, "seek_player", "Flint"),
			("Mushroom", true, "restore_power", "Mushroom"),
			("Feathers", false, "feather_fall", "Feathers"),
			("GreydwarfEye", false, "clear_skies", "Greydwarf Eye"),
			("Stone", false, "water_walk", "Stone"),
			("AncientSeed", false, "growth", "Ancient Seed"),
			("FirCone", false, "tree_stand", "Tree Seeds"),
			("PineCone", false, "tree_stand", "a tree seed"),
			("Acorn", false, "tree_stand", "a tree seed"),
			("BeechSeeds", false, "tree_stand", "a tree seed"),
			("BirchSeeds", false, "tree_stand", "a tree seed"),
			("WitheredBone", false, "rock_stand", "Withered Bone"),
			("Entrails", false, "prime", "Entrails"),
			("BoneFragments", false, "tame_flock", "Bone Fragments"),
			("Barley", false, "mead_ripen", "Barley"),
			("Resin", false, "kindle", "Resin"),
			("Coal", false, "repair", "Coal"),
			("YmirRemains", false, "giant", "Ymir Flesh"),
			("RawMeat", false, "burden", "Boar Meat"),
			("Amber", false, "ward_bubble", "Amber"),
			("AmberPearl", false, "campfire_ward", "Amber Pearl"),
			("Obsidian", false, "tar_moat", "Obsidian"),
			("Chitin", false, "seek_corpse", "Chitin"),
			("Wisp", false, "clear_mist", "Wisp"),
			("Ruby", false, "fire_wall", "Ruby"),
			("DeerHide", false, "seek_deer", "Deer Hide"),
			("LeatherScraps", false, "seek_boar", "Leather Scraps"),
			("BjornHide", false, "seek_bear", "Bear Hide"),
			("TrollHide", false, "seek_troll", "Troll Hide"),
			("Root", false, "seek_abomination", "Root"),
			("SerpentScale", false, "seek_serpent", "Serpent Scale"),
			("WolfPelt", false, "seek_wolf", "Wolf Pelt"),
			("LoxPelt", false, "seek_lox", "Lox Pelt"),
			("HareMeat", false, "seek_misthare", "Hare Meat"),
			("AskHide", false, "seek_asksvin", "Asksvin Hide"),
			("SurtlingCore", false, "flaming_sword", "Surtling Core"),
			("Ooze", false, "jotun_bane", "Ooze"),
			("Copper", false, "krom", "Copper"),
			("Iron", false, "slayer", "Iron"),
			("Bloodbag", false, "skull_splittur", "Blood Bag"),
			("Tin", false, "himminafl", "Tin"),
			("Crystal", false, "mistwalker", "Crystal")
		};

		internal static readonly HuntDef[] HuntDefs = new HuntDef[10]
		{
			new HuntDef
			{
				Key = "seek_deer",
				Prefab = "Deer",
				DefaultIngredient = "DeerHide",
				Biome = (Biome)1,
				Scale = 1.8f,
				DefaultHoverText = "Hunt the deer",
				DefaultMessage = "He thinks he's alone.",
				DefaultDistance = 150f
			},
			new HuntDef
			{
				Key = "seek_boar",
				Prefab = "Boar",
				DefaultIngredient = "LeatherScraps",
				Biome = (Biome)1,
				Scale = 1.8f,
				DefaultHoverText = "Hunt the boar",
				DefaultMessage = "The boar roots nearby.",
				DefaultDistance = 150f
			},
			new HuntDef
			{
				Key = "seek_bear",
				Prefab = "Bjorn",
				DefaultIngredient = "BjornHide",
				Biome = (Biome)8,
				Scale = 1.8f,
				DefaultHoverText = "Hunt the bear",
				DefaultMessage = "A great shadow waits in the trees.",
				DefaultDistance = 150f
			},
			new HuntDef
			{
				Key = "seek_troll",
				Prefab = "Troll",
				DefaultIngredient = "TrollHide",
				Biome = (Biome)8,
				Scale = 1.8f,
				DefaultHoverText = "Hunt the troll",
				DefaultMessage = "The earth shudders.",
				DefaultDistance = 150f
			},
			new HuntDef
			{
				Key = "seek_abomination",
				Prefab = "Abomination",
				DefaultIngredient = "Root",
				Biome = (Biome)2,
				Scale = 1.8f,
				DefaultHoverText = "Hunt the abomination",
				DefaultMessage = "Something ancient stirs in the roots.",
				DefaultDistance = 150f
			},
			new HuntDef
			{
				Key = "seek_wolf",
				Prefab = "Wolf",
				DefaultIngredient = "WolfPelt",
				Biome = (Biome)4,
				Scale = 1.8f,
				DefaultHoverText = "Hunt the wolf",
				DefaultMessage = "The pack circles.",
				DefaultDistance = 150f
			},
			new HuntDef
			{
				Key = "seek_lox",
				Prefab = "Lox",
				DefaultIngredient = "LoxPelt",
				Biome = (Biome)16,
				Scale = 1.8f,
				DefaultHoverText = "Hunt the lox",
				DefaultMessage = "The plains tremble beneath it.",
				DefaultDistance = 150f
			},
			new HuntDef
			{
				Key = "seek_misthare",
				Prefab = "Hare",
				DefaultIngredient = "HareMeat",
				Biome = (Biome)512,
				Scale = 1.8f,
				DefaultHoverText = "Hunt the hare",
				DefaultMessage = "It darts through the mist.",
				DefaultDistance = 150f
			},
			new HuntDef
			{
				Key = "seek_asksvin",
				Prefab = "Asksvin",
				DefaultIngredient = "AskHide",
				Biome = (Biome)32,
				Scale = 1.8f,
				DefaultHoverText = "Hunt the asksvin",
				DefaultMessage = "Ash and ember — it hungers.",
				DefaultDistance = 150f
			},
			new HuntDef
			{
				Key = "seek_serpent",
				Prefab = "Serpent",
				DefaultIngredient = "SerpentScale",
				Biome = (Biome)256,
				Scale = 1.8f,
				DefaultHoverText = "Hunt the serpent",
				DefaultMessage = "Something vast stirs beneath the waves.",
				DefaultDistance = 150f
			}
		};

		internal static readonly LegendaryDef[] LegendaryDefs = new LegendaryDef[7]
		{
			new LegendaryDef
			{
				Key = "flaming_sword",
				Prefab = "SwordIronFire",
				DefaultIngredient = "SurtlingCore",
				SkillType = (SkillType)1,
				SkillLabel = "sword",
				DefaultActivateMsg = "Dyrnwyn answers. Let it burn.",
				DefaultDeactivateMsg = "The flame fades."
			},
			new LegendaryDef
			{
				Key = "jotun_bane",
				Prefab = "AxeJotunBane",
				DefaultIngredient = "Ooze",
				SkillType = (SkillType)7,
				SkillLabel = "axe",
				DefaultActivateMsg = "Jotun Bane answers the call.",
				DefaultDeactivateMsg = "The axe rests."
			},
			new LegendaryDef
			{
				Key = "krom",
				Prefab = "THSwordKrom",
				DefaultIngredient = "Copper",
				SkillType = (SkillType)1,
				SkillLabel = "sword",
				DefaultActivateMsg = "Krom rises from the deep.",
				DefaultDeactivateMsg = "Krom is stilled."
			},
			new LegendaryDef
			{
				Key = "slayer",
				Prefab = "THSwordSlayer",
				DefaultIngredient = "Iron",
				SkillType = (SkillType)1,
				SkillLabel = "sword",
				DefaultActivateMsg = "Slayer hungers.",
				DefaultDeactivateMsg = "The slayer rests."
			},
			new LegendaryDef
			{
				Key = "skull_splittur",
				Prefab = "BattleaxeSkullSplittur",
				DefaultIngredient = "Bloodbag",
				SkillType = (SkillType)7,
				SkillLabel = "axe",
				DefaultActivateMsg = "Skull Splittur demands a reckoning.",
				DefaultDeactivateMsg = "The axe is sated."
			},
			new LegendaryDef
			{
				Key = "himminafl",
				Prefab = "AtgeirHimminAfl",
				DefaultIngredient = "Tin",
				SkillType = (SkillType)4,
				SkillLabel = "polearm",
				DefaultActivateMsg = "Himminafl crackles with thunder.",
				DefaultDeactivateMsg = "The thunder fades."
			},
			new LegendaryDef
			{
				Key = "mistwalker",
				Prefab = "SwordMistwalker",
				DefaultIngredient = "Crystal",
				SkillType = (SkillType)1,
				SkillLabel = "sword",
				DefaultActivateMsg = "Mistwalker parts the veil.",
				DefaultDeactivateMsg = "The mist returns."
			}
		};

		internal static readonly string[] CampfirePrefabs = new string[5] { "fire_pit", "fire_pit_iron", "hearth", "bonfire", "piece_brazier" };

		internal static float RitualCooldownRemaining = 0f;

		internal static float FeatherRitualExpiry = 0f;

		internal static bool FeatherJumpActive = false;

		internal const float FeatherJumpMult = 1.5f;

		internal static float ClearSkiesExpiry = 0f;

		internal static float RainExpiry = 0f;

		internal static float GiantRainExpiry = 0f;

		internal static float WaterWalkExpiry = 0f;

		internal static float SeekEnvExpiry = 0f;

		internal static float DungeonEnvExpiry = 0f;

		internal static float HomeEnvExpiry = 0f;

		internal static bool GrowthBlessingActive = false;

		internal static bool ShowHintsEnabled = true;

		internal static int HintPage = 0;

		internal const int HintPageSize = 15;

		internal static bool TameBlessingActive = false;

		internal static bool MeadBlessingActive = false;

		internal const string TreeStandKey = "ath_tree_stand_positions";

		internal const string TreeStandPiecesKey = "ath_tree_stand_pieces";

		internal const string RockStandKey = "ath_rock_stand_positions";

		internal const string RockStandPiecesKey = "ath_rock_stand_pieces";

		internal const string PrimeDayKey = "pilgrim_prime_day";

		internal static float FlamingSwordExpiry = 0f;

		internal static LegendaryDef _activeLegendaryDef;

		internal static ItemData? _legendaryActiveItem = null;

		internal static string? _legendaryActivePrefab = null;

		private static ItemData? _legendaryOrigItem = null;

		internal static float GiantExpiry = 0f;

		internal static float BurdenExpiry = 0f;

		internal static float ShieldBubbleExpiry = 0f;

		internal static float CampfireWardExpiry = 0f;

		internal static Coroutine? ActiveStructureRitual = null;

		internal static Action? ActiveStructureRitualCleanup = null;

		internal static GameObject? ActiveCampfireWard = null;

		internal static Renderer? ActiveCampfireWardRend = null;

		internal static float GiantTargetScale = 1f;

		internal const float GiantCarryBonus = 300f;

		internal const float GiantScale = 3f;

		internal const float GiantWalkMult = 1.5f;

		internal const float GiantRunMult = 2.5f;

		internal const float GiantJumpMult = 1.2f;

		internal static bool GiantSpeedApplied = false;

		private static DamageTypes _origUnarmedDmg;

		private static short _origUnarmedTier;

		private static float _origAttackRange;

		private static float _origAttackHeight;

		private static float _origAttackOffset;

		private static float _origAutoPickupRange;

		private static float _origSwimDepth;

		internal static readonly Dictionary<string, string> TrophyToPower = new Dictionary<string, string>
		{
			{ "TrophyEikthyr", "GP_Eikthyr" },
			{ "TrophyTheElder", "GP_TheElder" },
			{ "TrophyBonemass", "GP_Bonemass" },
			{ "TrophyDragonQueen", "GP_Moder" },
			{ "TrophyGoblinKing", "GP_Yagluth" },
			{ "TrophySeekerQueen", "GP_Queen" },
			{ "TrophyFader", "GP_Fader" }
		};

		private static readonly Random Rng = new Random();

		private static string? _seekPendingBossName;

		private static string? _seekPendingMessage;

		private static float _seekPendingMult;

		private static Terminal? _seekPendingCtx;

		private static string? _seekPendingIngredient;

		private static readonly string[] DungeonLocations = new string[16]
		{
			"Crypt2", "Crypt3", "Crypt4", "TrollCave02", "SunkenCrypt4", "MountainCave02", "GoblinCamp2", "Hildir_crypt", "Hildir_cave", "Hildir_plainsfortress",
			"Mistlands_DvergrTownEntrance1", "Mistlands_DvergrTownEntrance2", "CharredFortress", "MorgenHole1", "MorgenHole2", "MorgenHole3"
		};

		private static readonly string[] TraderLocations = new string[3] { "Vendor_BlackForest", "Hildir_camp", "BogWitch_Camp" };

		private const string TraderMetPrefix = "pilgrim_met_";

		private static MethodInfo? _isExploredMethod;

		internal static Action<Dictionary<string, List<Vector3>>>? _pendingLocationsCallback;

		internal const string ShieldBubbleRPC = "Pilgrim_ShieldBubble";

		private static Material? s_wardSphereMat;

		internal const string CampfireWardRPC = "Pilgrim_CampfireWard";

		internal const string CampfireWardCancelRPC = "Pilgrim_CampfireWardCancel";

		internal const float CampfireWardRadius = 10f;

		internal const string StructureRitualRPC = "Pilgrim_StructureRitual";

		internal static readonly HashSet<string> StructureRitualKeys = new HashSet<string> { "tar_moat", "fire_wall" };

		internal const bool StructureRitualDebug = true;

		private static GameObject? s_smokePrefab;

		internal const string ClearMistRPC = "Pilgrim_ClearMist";

		internal const float ClearMistRadius = 100f;

		internal static Action<Vector3>? _pendingCorpseCallback;

		private static Dictionary<ZDOID, ZDO>? _zdoManObjects;

		private static readonly (string boss, string prefab)[] BossChain = new(string, string)[7]
		{
			("Eikthyr", "Eikthyrnir"),
			("The Elder", "GDKing"),
			("Bonemass", "Bonemass"),
			("Moder", "Dragonqueen"),
			("Yagluth", "GoblinKing"),
			("The Queen", "Mistlands_DvergrBossEntrance1"),
			("Fader", "FaderLocation")
		};

		private static readonly string[] BossKeys = new string[7] { "defeated_eikthyr", "defeated_gdking", "defeated_bonemass", "defeated_dragon", "defeated_goblinking", "defeated_queen", "defeated_fader" };

		private static readonly string[] BossTrophies = new string[7] { "TrophyEikthyr", "TrophyTheElder", "TrophyBonemass", "TrophyDragonQueen", "TrophyGoblinKing", "TrophySeekerQueen", "TrophyFader" };

		internal static string ConfigPath => Path.Combine(Paths.ConfigPath, "Pilgrim.yaml");

		internal static string SeekFood => Cfg.Rituals.Items.GetValueOrDefault("seek_altar")?.Item ?? "RawMeat";

		internal static string HomeFood => Cfg.Rituals.Items.GetValueOrDefault("seek_bed")?.Item ?? "Dandelion";

		internal static string FeatherFood => Cfg.Rituals.Items.GetValueOrDefault("feather_fall")?.Item ?? "Feathers";

		internal static string TraderFood => Cfg.Rituals.Items.GetValueOrDefault("seek_trader")?.Item ?? "Coins";

		internal static string GrowthFood => Cfg.Rituals.Items.GetValueOrDefault("growth")?.Item ?? "AncientSeed";

		internal static string PlayerSeekFood => Cfg.Rituals.Items.GetValueOrDefault("seek_player")?.Item ?? "Flint";

		internal static string KindleFood => Cfg.Rituals.Items.GetValueOrDefault("kindle")?.Item ?? "Resin";

		internal static string TameFood => Cfg.Rituals.Items.GetValueOrDefault("tame_flock")?.Item ?? "BoneFragments";

		internal static string MeadFood => Cfg.Rituals.Items.GetValueOrDefault("mead_ripen")?.Item ?? "Barley";

		internal static string GiantFood => Cfg.Rituals.Items.GetValueOrDefault("giant")?.Item ?? "YmirRemains";

		internal static string BurdenFood => Cfg.Rituals.Items.GetValueOrDefault("burden")?.Item ?? "RawMeat";

		internal static string WardFood => Cfg.Rituals.Items.GetValueOrDefault("ward_bubble")?.Item ?? "Ruby";

		internal static string CampfireWardFood => Cfg.Rituals.Items.GetValueOrDefault("campfire_ward")?.Item ?? "AmberPearl";

		internal static string RepairFood => Cfg.Rituals.Items.GetValueOrDefault("repair")?.Item ?? "Coal";

		internal static string TarMoatFood => Cfg.Rituals.Items.GetValueOrDefault("tar_moat")?.Item ?? "Obsidian";

		internal static string FireWallFood => Cfg.Rituals.Items.GetValueOrDefault("fire_wall")?.Item ?? "FlametalNew";

		internal static string CorpseFood => Cfg.Rituals.Items.GetValueOrDefault("seek_corpse")?.Item ?? "Chitin";

		internal static string MistFood => Cfg.Rituals.Items.GetValueOrDefault("clear_mist")?.Item ?? "Wisp";

		internal static string TreeStandFood => Cfg.Rituals.Items.GetValueOrDefault("tree_stand")?.Item ?? "FirCone";

		internal static string PrimeFood => Cfg?.Rituals?.Items?.GetValueOrDefault("prime")?.Item ?? "Entrails";

		internal static float RitualCooldownDuration => Cfg.Rituals.Cooldown;

		internal static float ClearSkiesDuration => Cfg.Rituals.Items.GetValueOrDefault("clear_skies")?.Duration ?? 900f;

		internal static float RainDuration => Cfg.Rituals.Items.GetValueOrDefault("restore_power")?.Duration ?? 600f;

		internal static float WaterWalkDuration => Cfg.Rituals.Items.GetValueOrDefault("water_walk")?.Duration ?? 60f;

		internal static float SeekEnvDuration => 60f;

		internal static float DungeonEnvDuration => 60f;

		internal static float HomeEnvDuration => 60f;

		internal static float LegendaryExpiry => FlamingSwordExpiry;

		internal static float BurdenCarryBonus => Cfg?.Rituals?.Items?.GetValueOrDefault("burden")?.CarryBonus ?? 1000f;

		internal static void LoadConfig()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Expected O, but got Unknown
			try
			{
				if (!File.Exists(ConfigPath))
				{
					string contents = ((BuilderSkeleton<SerializerBuilder>)new SerializerBuilder()).WithNamingConvention(UnderscoredNamingConvention.Instance).Build().Serialize((object)PilgrimConfig.Default());
					File.WriteAllText(ConfigPath, contents);
					Log.LogInfo((object)("[Pilgrim] Wrote default config to " + ConfigPath));
				}
				Cfg = ((BuilderSkeleton<DeserializerBuilder>)new DeserializerBuilder()).WithNamingConvention(UnderscoredNamingConvention.Instance).IgnoreUnmatchedProperties().Build()
					.Deserialize<PilgrimConfig>(File.ReadAllText(ConfigPath));
				PilgrimConfig pilgrimConfig = PilgrimConfig.Default();
				bool flag = false;
				foreach (var (key, value) in pilgrimConfig.Rituals.Items)
				{
					if (!Cfg.Rituals.Items.ContainsKey(key))
					{
						Cfg.Rituals.Items[key] = value;
						flag = true;
					}
				}
				if (flag)
				{
					string contents2 = ((BuilderSkeleton<SerializerBuilder>)new SerializerBuilder()).WithNamingConvention(UnderscoredNamingConvention.Instance).Build().Serialize((object)Cfg);
					File.WriteAllText(ConfigPath, contents2);
					Log.LogInfo((object)"[Pilgrim] Backfilled missing ritual config keys.");
				}
				Log.LogInfo((object)"[Pilgrim] Config loaded.");
			}
			catch (Exception ex)
			{
				Log.LogError((object)("[Pilgrim] Config load failed: " + ex.Message + " — using defaults."));
				Cfg = PilgrimConfig.Default();
			}
		}

		internal static string HuntIngredient(HuntDef def)
		{
			return Cfg.Rituals.Items.GetValueOrDefault(def.Key)?.Item ?? def.DefaultIngredient;
		}

		internal static string? LegendaryIngredientMatch(string prefab)
		{
			LegendaryDef[] legendaryDefs = LegendaryDefs;
			for (int i = 0; i < legendaryDefs.Length; i++)
			{
				LegendaryDef legendaryDef = legendaryDefs[i];
				if (prefab == (Cfg.Rituals.Items.GetValueOrDefault(legendaryDef.Key)?.Item ?? legendaryDef.DefaultIngredient))
				{
					return legendaryDef.Key;
				}
			}
			return null;
		}

		internal static string EnsureCrateId(ItemData item)
		{
			if (string.IsNullOrEmpty(item.m_crafterName) || !item.m_crafterName.StartsWith("PC_"))
			{
				item.m_crafterName = "PC_" + Guid.NewGuid().ToString("N").Substring(0, 8);
			}
			return item.m_crafterName;
		}

		internal static string CratePlayerKey(ItemData item)
		{
			return "pilgrim_crate_" + EnsureCrateId(item);
		}

		internal static void WriteCrate(Player player, ItemData item, string b64)
		{
			item.m_customData["pilgrim_crate"] = b64;
			player.m_customData[CratePlayerKey(item)] = b64;
		}

		internal static string? ReadCrate(Player player, ItemData item)
		{
			if (item.m_customData.TryGetValue("pilgrim_crate", out var value) && !string.IsNullOrEmpty(value))
			{
				return value;
			}
			player.m_customData.TryGetValue(CratePlayerKey(item), out var value2);
			return value2;
		}

		internal static string CrateMetalSeenKey(string prefab)
		{
			return "pilgrim_metal_" + prefab.ToLower();
		}

		internal static bool IsCrateMetalSeen(Player p, string prefab)
		{
			return p.m_customData.ContainsKey(CrateMetalSeenKey(prefab));
		}

		internal static ItemData? FindCacheItem(Player player)
		{
			if (player == null)
			{
				return null;
			}
			return ((IEnumerable<ItemData>)((Humanoid)player).GetInventory().GetAllItems()).FirstOrDefault((Func<ItemData, bool>)((ItemData i) => i.m_shared.m_name == "Pilgrim's Cache"));
		}

		internal static Inventory? GetCrateInvForRead(Player player)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_006f: Expected O, but got Unknown
			if (_crateInventory != null)
			{
				return _crateInventory;
			}
			ItemData val = FindCacheItem(player);
			if (val == null)
			{
				_closedCrateInvCache = null;
				_closedCrateInvCacheKey = null;
				return null;
			}
			string text = ReadCrate(player, val);
			if (_closedCrateInvCache != null && _closedCrateInvCacheKey == text)
			{
				return _closedCrateInvCache;
			}
			Inventory val2 = new Inventory("tmp", (Sprite)null, 6, val.m_quality * 2);
			DeserializeCrate(val2, text);
			_closedCrateInvCache = val2;
			_closedCrateInvCacheKey = text;
			return val2;
		}

		internal static void SaveCrateInvIfClosed(Player player, Inventory inv)
		{
			if (_crateInventory != null)
			{
				return;
			}
			ItemData val = FindCacheItem(player);
			if (val != null)
			{
				string text = SerializeCrate(inv);
				WriteCrate(player, val, text);
				_closedCrateInvCache = inv;
				_closedCrateInvCacheKey = text;
				float num = inv.GetAllItems().Sum((ItemData i) => (float)i.m_stack * i.m_shared.m_weight);
				val.m_customData["pilgrim_crate_weight"] = num.ToString(CultureInfo.InvariantCulture);
			}
		}

		internal static string SerializeCrate(Inventory inv)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			ZPackage val = new ZPackage();
			List<ItemData> allItems = inv.GetAllItems();
			val.Write(allItems.Count);
			foreach (ItemData item in allItems)
			{
				val.Write(ItemUtil.PrefabName(item));
				val.Write(item.m_stack);
				val.Write(item.m_quality);
				val.Write(item.m_gridPos.x);
				val.Write(item.m_gridPos.y);
			}
			return Convert.ToBase64String(val.GetArray());
		}

		internal static void DeserializeCrate(Inventory inv, string? b64)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(b64))
			{
				return;
			}
			try
			{
				ZPackage val = new ZPackage(Convert.FromBase64String(b64));
				int num = val.ReadInt();
				int width = inv.GetWidth();
				int height = inv.GetHeight();
				for (int i = 0; i < num; i++)
				{
					string text = val.ReadString();
					int num2 = val.ReadInt();
					int num3 = val.ReadInt();
					int num4 = Mathf.Clamp(val.ReadInt(), 0, width - 1);
					int num5 = Mathf.Clamp(val.ReadInt(), 0, height - 1);
					if (!string.IsNullOrEmpty(text) && num2 > 0)
					{
						ItemData val2 = inv.AddItem(text, num2, num3, 0, 0L, "", false);
						if (val2 != null)
						{
							val2.m_gridPos = new Vector2i(num4, num5);
						}
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("[Pilgrim] Crate deserialize failed: " + ex.Message));
			}
		}

		internal static void RegisterCrateItem(ObjectDB db)
		{
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			if (db.m_items.Any((GameObject g) => (Object)(object)g != (Object)null && ((Object)g).name == "PilgrimCrate"))
			{
				return;
			}
			GameObject itemPrefab = db.GetItemPrefab("Coins");
			if ((Object)(object)itemPrefab == (Object)null)
			{
				Log.LogWarning((object)"[Pilgrim] Crate: Coins template not found");
				return;
			}
			_suppressZNetViewAwake = true;
			GameObject val = Object.Instantiate<GameObject>(itemPrefab);
			_suppressZNetViewAwake = false;
			((Object)val).name = "PilgrimCrate";
			Object.DontDestroyOnLoad((Object)(object)val);
			_cratePrefabGo = val;
			ItemDrop component = val.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_name = "Pilgrim's Cache";
			component.m_itemData.m_shared.m_description = "Holds a little bit of everything. Right-click to open.";
			component.m_itemData.m_shared.m_weight = 5f;
			component.m_itemData.m_shared.m_maxStackSize = 1;
			component.m_itemData.m_shared.m_value = 0;
			component.m_itemData.m_shared.m_itemType = (ItemType)1;
			component.m_itemData.m_shared.m_maxQuality = 5;
			component.m_itemData.m_dropPrefab = val;
			component.m_autoPickup = false;
			db.m_items.Add(val);
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
			if (typeof(ObjectDB).GetField("m_itemByHash", bindingAttr)?.GetValue(db) is Dictionary<int, GameObject> dictionary)
			{
				dictionary[StringExtensionMethods.GetStableHashCode(((Object)val).name)] = val;
			}
			if (typeof(ObjectDB).GetField("m_itemByData", bindingAttr)?.GetValue(db) is Dictionary<SharedData, GameObject> dictionary2)
			{
				dictionary2[component.m_itemData.m_shared] = val;
			}
			AddCrateToZNetScene(val);
			Log.LogInfo((object)"[Pilgrim] Registered PilgrimCrate");
		}

		internal static void RegisterCrateRecipe(ObjectDB db, ZNetScene zns)
		{
			//IL_00ec: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			//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_012c: 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_013b: Expected O, but got Unknown
			if (!(Cfg?.Cache?.Enabled ?? true))
			{
				return;
			}
			if ((Object)(object)db != (Object)null && !db.m_recipes.Any((Recipe r) => (Object)(object)r != (Object)null && ((Object)r).name == "Recipe_PilgrimCrate"))
			{
				GameObject? cratePrefabGo = _cratePrefabGo;
				ItemDrop val = ((cratePrefabGo != null) ? cratePrefabGo.GetComponent<ItemDrop>() : null);
				if ((Object)(object)val == (Object)null)
				{
					Log.LogWarning((object)"[Pilgrim] Recipe: _cratePrefabGo null");
					return;
				}
				Recipe val2 = ScriptableObject.CreateInstance<Recipe>();
				((Object)val2).name = "Recipe_PilgrimCrate";
				val2.m_item = val;
				val2.m_amount = 1;
				val2.m_minStationLevel = 1;
				val2.m_craftingStation = null;
				val2.m_resources = (Requirement[])(object)new Requirement[2]
				{
					new Requirement
					{
						m_resItem = Res("Copper"),
						m_amount = 10,
						m_amountPerLevel = 0
					},
					new Requirement
					{
						m_resItem = Res("LeatherScraps"),
						m_amount = 6,
						m_amountPerLevel = 0
					}
				};
				_crateRecipe = val2;
				_crateCraftResources = val2.m_resources;
				db.m_recipes.Add(val2);
				Log.LogInfo((object)"[Pilgrim] Registered Recipe_PilgrimCrate");
			}
			if ((Object)(object)zns != (Object)null && (Object)(object)_crateRecipe != (Object)null && (Object)(object)_crateRecipe.m_craftingStation == (Object)null)
			{
				GameObject prefab = zns.GetPrefab("forge");
				CraftingStation val3 = ((prefab != null) ? prefab.GetComponent<CraftingStation>() : null);
				_crateRecipe.m_craftingStation = val3;
				Log.LogInfo((object)$"[Pilgrim] Recipe: forge station={(Object)(object)val3 != (Object)null}");
			}
			ItemDrop Res(string name)
			{
				GameObject itemPrefab = db.GetItemPrefab(name);
				ItemDrop obj = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
				if ((Object)(object)obj == (Object)null)
				{
					Log.LogWarning((object)("[Pilgrim] Recipe: ingredient '" + name + "' not found"));
				}
				return obj;
			}
		}

		internal static void AddCrateToZNetScene(GameObject go)
		{
			ZNetScene instance = ZNetScene.instance;
			if (!((Object)(object)instance == (Object)null))
			{
				BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
				if (typeof(ZNetScene).GetField("m_namedPrefabs", bindingAttr)?.GetValue(instance) is Dictionary<int, GameObject> dictionary)
				{
					dictionary[StringExtensionMethods.GetStableHashCode(((Object)go).name)] = go;
				}
				if (!instance.m_prefabs.Contains(go))
				{
					instance.m_prefabs.Add(go);
				}
				SetupCrateVisuals(instance, go);
			}
		}

		internal static void SetupCrateVisuals(ZNetScene zns, GameObject go)
		{
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = zns.GetPrefab("piece_chest_barrel");
			if ((Object)(object)prefab == (Object)null)
			{
				Log.LogWarning((object)"[Pilgrim] piece_chest_barrel prefab not found");
				return;
			}
			ItemDrop component = go.GetComponent<ItemDrop>();
			MeshFilter componentInChildren = prefab.GetComponentInChildren<MeshFilter>();
			MeshFilter componentInChildren2 = go.GetComponentInChildren<MeshFilter>();
			MeshRenderer componentInChildren3 = go.GetComponentInChildren<MeshRenderer>();
			MeshRenderer componentInChildren4 = prefab.GetComponentInChildren<MeshRenderer>();
			Sprite val = prefab.GetComponent<Piece>()?.m_icon;
			if ((Object)(object)val != (Object)null)
			{
				component.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { val };
			}
			if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren2 != (Object)null)
			{
				componentInChildren2.sharedMesh = componentInChildren.sharedMesh;
			}
			if ((Object)(object)componentInChildren4 != (Object)null && (Object)(object)componentInChildren3 != (Object)null)
			{
				((Renderer)componentInChildren3).sharedMaterials = ((Renderer)componentInChildren4).sharedMaterials;
			}
			if ((Object)(object)componentInChildren3 != (Object)null)
			{
				((Component)componentInChildren3).transform.localScale = Vector3.one * 0.5f;
			}
			Collider[] componentsInChildren = go.GetComponentsInChildren<Collider>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren[i]);
			}
			CapsuleCollider obj = go.AddComponent<CapsuleCollider>();
			obj.radius = 0.22f;
			obj.height = 0.42f;
			obj.center = new Vector3(0f, 0.21f, 0f);
			Rigidbody component2 = go.GetComponent<Rigidbody>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.constraints = (RigidbodyConstraints)80;
				component2.angularDamping = 10f;
				component2.mass = 5f;
			}
		}

		internal static void OpenCrateUI(Player player, ItemData item)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			InventoryGui instance = InventoryGui.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			int num = 6;
			int num2 = item.m_quality * 2;
			Inventory val = new Inventory("Pilgrim's Cache", (Sprite)null, num, num2);
			DeserializeCrate(val, ReadCrate(player, item));
			if ((Object)(object)_fakeCrateGo != (Object)null)
			{
				Object.Destroy((Object)(object)_fakeCrateGo);
			}
			_fakeCrateGo = new GameObject("PilgrimCrateContainer");
			_fakeCrateGo.AddComponent<PilgrimCrateMarker>();
			_fakeCrateGo.transform.position = ((Component)player).transform.position;
			Object.DontDestroyOnLoad((Object)(object)_fakeCrateGo);
			_suppressContainerAwake = true;
			_fakeCrateContainer = _fakeCrateGo.AddComponent<Container>();
			_suppressContainerAwake = false;
			typeof(Container).GetField("m_inventory", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(_fakeCrateContainer, val);
			_crateItem = item;
			_crateInventory = val;
			_crateUIOpen = true;
			val.m_onChanged = (Action)Delegate.Combine(val.m_onChanged, (Action)delegate
			{
				if (_crateItem != null && _crateInventory != null)
				{
					float num3 = _crateInventory.GetAllItems().Sum((ItemData i) => (float)i.m_stack * i.m_shared.m_weight);
					_crateItem.m_customData["pilgrim_crate_weight"] = num3.ToString(CultureInfo.InvariantCulture);
				}
			});
			instance.Show(_fakeCrateContainer, 1);
		}

		internal static void SaveAndCloseCrateUI()
		{
			if (_closingCrateUI)
			{
				return;
			}
			_closingCrateUI = true;
			bool crateUIOpen = _crateUIOpen;
			if (_crateInventory != null && (Object)(object)Player.m_localPlayer != (Object)null)
			{
				ItemData crateItem = _crateItem;
				if (crateItem != null)
				{
					WriteCrate(Player.m_localPlayer, crateItem, SerializeCrate(_crateInventory));
					float num = _crateInventory.GetAllItems().Sum((ItemData i) => (float)i.m_stack * i.m_shared.m_weight);
					crateItem.m_customData["pilgrim_crate_weight"] = num.ToString(CultureInfo.InvariantCulture);
				}
			}
			_crateItem = null;
			_crateInventory = null;
			InventoryGui instance = InventoryGui.instance;
			if ((Object)(object)instance != (Object)null && !_hidingInventory)
			{
				typeof(InventoryGui).GetMethod("CloseContainer", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(instance, null);
			}
			_crateUIOpen = false;
			_fakeCrateContainer = null;
			if ((Object)(object)_fakeCrateGo != (Object)null)
			{
				Object.Destroy((Object)(object)_fakeCrateGo);
				_fakeCrateGo = null;
			}
			Container previousContainer = _previousContainer;
			_previousContainer = null;
			if (crateUIOpen && (Object)(object)previousContainer != (Object)null && Object.op_Implicit((Object)(object)previousContainer))
			{
				_openingCrateUI = true;
				InventoryGui instance2 = InventoryGui.instance;
				if (instance2 != null)
				{
					instance2.Show(previousContainer, 1);
				}
				_openingCrateUI = false;
			}
			_closingCrateUI = false;
		}

		internal static bool IsRitualKnown(Player player, string key)
		{
			return player.m_customData.ContainsKey("ath_known_" + key);
		}

		internal static void RecordRitualUse(Player player, string key)
		{
			string key2 = "ath_uses_" + key;
			string value;
			int result;
			int num = ((player.m_customData.TryGetValue(key2, out value) && int.TryParse(value, out result)) ? result : 0);
			player.m_customData[key2] = (num + 1).ToString();
		}

		internal static void LearnRitual(Player player, string key, string itemDisplayName)
		{
			if (!IsRitualKnown(player, key))
			{
				player.m_customData["ath_known_" + key] = "1";
				if (Cfg.Rituals.Items.TryGetValue(key, out RitualItemConfig value))
				{
					((Character)player).Message((MessageType)1, "<color=orange>Ritual discovered:</color> " + value.HoverText, 0, (Sprite)null);
					string text = "<color=orange>Ritual discovered</color>\n" + value.HoverText + "\nOffer <color=yellow>" + itemDisplayName + "</color> at a burning campfire.";
					MessageHudTimerPatch.ExtendNextCenter = true;
					((Character)player).Message((MessageType)2, text, 0, (Sprite)null);
				}
			}
		}

		internal static float RitualMultiplier(Fireplace fp, Player player)
		{
			string text = ((Object)((Component)fp).gameObject).name.ToLower().Replace("(clone)", "").Trim();
			float num = 1f;
			int num2 = 0;
			foreach (KeyValuePair<string, float> fireMultiplier in Cfg.Rituals.FireMultipliers)
			{
				if (text.StartsWith(fireMultiplier.Key) && fireMultiplier.Key.Length > num2)
				{
					num2 = fireMultiplier.Key.Length;
					num = fireMultiplier.Value;
				}
			}
			float comfortPeakMultiplier = Cfg.Rituals.ComfortPeakMultiplier;
			int comfortLevel = player.GetComfortLevel();
			float num3 = 1f + (float)(comfortLevel - 1) * (comfortPeakMultiplier - 1f) / 19f;
			return num * num3;
		}

		internal static bool IsPrimed(Fireplace fp)
		{
			ZNetView component = ((Component)fp).GetComponent<ZNetView>();
			ZDO val = ((component != null) ? component.GetZDO() : null);
			if (val == null)
			{
				return false;
			}
			return !string.IsNullOrEmpty(val.GetString("pilgrim_prime_day", ""));
		}

		internal static float PrimeMultiplier(Fireplace fp)
		{
			RitualItemConfig ritualItemConfig = Cfg?.Rituals?.Items?.GetValueOrDefault("prime");
			if (ritualItemConfig == null || !ritualItemConfig.Enabled)
			{
				return 1f;
			}
			ZNetView component = ((Component)fp).GetComponent<ZNetView>();
			ZDO val = ((component != null) ? component.GetZDO() : null);
			if (val == null)
			{
				return 1f;
			}
			string text = val.GetString("pilgrim_prime_day", "");
			if (string.IsNullOrEmpty(text) || !float.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				return 1f;
			}
			float num = Mathf.Max(0f, (float)(ZNet.instance.GetTimeSeconds() / (double)EnvMan.instance.m_dayLengthSec) - result);
			float multiplierA = ritualItemConfig.MultiplierA;
			float multiplierB = ritualItemConfig.MultiplierB;
			return Mathf.Clamp(1f + multiplierA * num + multiplierB * num * num, 1f, 5f);
		}

		private void Awake()
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			plugin = this;
			Log = ((BaseUnityPlugin)this).Logger;
			LoadConfig();
			_cfgWatcher = new FileSystemWatcher(Paths.ConfigPath, "Pilgrim.yaml")
			{
				NotifyFilter = NotifyFilters.LastWrite,
				EnableRaisingEvents = true
			};
			_cfgWatcher.Changed += delegate
			{
				_cfgDirty = true;
			};
			try
			{
				new Harmony("com.ctogle.pilgrim").PatchAll();
			}
			catch (Exception ex)
			{
				Log.LogError((object)("[Pilgrim] Harmony patch failed: " + ex.Message));
			}
			RegisterCommands();
			GameObject val = new GameObject("AthScheduler");
			Object.DontDestroyOnLoad((Object)val);
			Scheduler = val.AddComponent<EnvScheduler>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Pilgrim loaded.");
		}

		internal static void BroadcastBird(Vector3 direction, float speed = 10f)
		{
			//IL_000b: 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)
			Scheduler?.SendBird(direction, speed);
			ZRoutedRpc instance = ZRoutedRpc.instance;
			if (instance != null)
			{
				instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "Pilgrim_SendBird", new object[2] { direction, speed });
			}
		}

		internal static void BroadcastVfx(Vector3 pos, string prefabName, float destroyDelay = 4f, Quaternion? rot = null)
		{
			//IL_0014: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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)
			Quaternion val = (Quaternion)(((??)rot) ?? Quaternion.identity);
			ZNetScene instance = ZNetScene.instance;
			GameObject val2 = ((instance != null) ? instance.GetPrefab(prefabName) : null);
			if ((Object)(object)val2 != (Object)null)
			{
				SpawnVfxLocal(val2, pos, val, destroyDelay);
			}
			ZRoutedRpc instance2 = ZRoutedRpc.instance;
			if (instance2 != null)
			{
				instance2.InvokeRoutedRPC(ZRoutedRpc.Everybody, "Pilgrim_SpawnVfx", new object[4] { pos, val, prefabName, destroyDelay });
			}
		}

		internal static void SpawnVfxLocal(GameObject prefab, Vector3 pos, Quaternion rot, float destroyDelay)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			prefab.SetActive(false);
			GameObject val = Object.Instantiate<GameObject>(prefab, pos, rot);
			prefab.SetActive(true);
			string[] array = new string[5] { "ZNetView", "ZSyncTransform", "ZSyncAnimation", "ZSFX", "TimedDestruction" };
			MonoBehaviour[] componentsInChildren = val.GetComponentsInChildren<MonoBehaviour>(true);
			foreach (MonoBehaviour val2 in componentsInChildren)
			{
				if ((Object)(object)val2 != (Object)null && Array.IndexOf(array, ((object)val2).GetType().Name) >= 0)
				{
					Object.DestroyImmediate((Object)(object)val2);
				}
			}
			val.SetActive(true);
			if (destroyDelay > 0f)
			{
				Object.Destroy((Object)(object)val, destroyDelay);
			}
		}

		internal static void BroadcastEnv(string name, string vanillaFallback = "")
		{
			SetDebugEnvSafe(name, vanillaFallback);
			ZRoutedRpc instance = ZRoutedRpc.instance;
			if (instance != null)
			{
				instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "Pilgrim_SetEnv", new object[2] { name, vanillaFallback });
			}
		}

		internal static void BroadcastWind(float angle, float intensity)
		{
			ApplyWind(angle, intensity);
			ZRoutedRpc instance = ZRoutedRpc.instance;
			if (instance != null)
			{
				instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "Pilgrim_SetWind", new object[2] { angle, intensity });
			}
		}

		internal static void ApplyWind(float angle, float intensity)
		{
			if (!((Object)(object)EnvMan.instance == (Object)null))
			{
				if (intensity < 0f)
				{
					EnvMan.instance.ResetDebugWind();
				}
				else
				{
					EnvMan.instance.SetDebugWind(angle, intensity);
				}
			}
		}

		private void Update()
		{
			if (_cfgDirty)
			{
				_cfgDirty = false;
				LoadConfig();
			}
		}

		private void RegisterCommands()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_006a: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_00a2: 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_0099: Expected O, but got Unknown
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0