Decompiled source of TyrenheimRaven v0.18.1

plugins/TyrenheimRaven.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using JetBrains.Annotations;
using MarketStall.MarketStall;
using MarketStall.UI;
using MarketStall.Utility;
using Microsoft.CodeAnalysis;
using ServerSync;
using TMPro;
using TyrenheimRaven;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ValheimModTest")]
[assembly: AssemblyDescription("")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyProduct("ValheimModTest")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("50ba138c-bd32-434f-a5c0-d9e34e49bca4")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyCompany("")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace MBSR
{
	public class MBSR
	{
		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		public class ObjectDB_Awake_Patch
		{
			public static void Postfix(ObjectDB __instance)
			{
				PerformUnpatching();
			}
		}

		private static bool hasUnpatched = false;

		private static Dictionary<string, Tuple<Type, string, HarmonyPatchType>[]> unpatchMethods = new Dictionary<string, Tuple<Type, string, HarmonyPatchType>[]> { 
		{
			"marlthon.OdinShipPlus",
			new Tuple<Type, string, HarmonyPatchType>[1] { Tuple.Create<Type, string, HarmonyPatchType>(typeof(Player), "Update", (HarmonyPatchType)0) }
		} };

		private static void PerformUnpatching()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if (hasUnpatched)
			{
				return;
			}
			foreach (KeyValuePair<string, Tuple<Type, string, HarmonyPatchType>[]> unpatchMethod in unpatchMethods)
			{
				Tuple<Type, string, HarmonyPatchType>[] value = unpatchMethod.Value;
				foreach (Tuple<Type, string, HarmonyPatchType> tuple in value)
				{
					MethodInfo method = tuple.Item1.GetMethod(tuple.Item2, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
					if (method != null)
					{
						Mod._harmony.Unpatch((MethodBase)method, tuple.Item3, unpatchMethod.Key);
					}
				}
			}
			hasUnpatched = true;
		}
	}
}
namespace TyrenheimRaven
{
	public class Assets
	{
		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		public class ZNetScene_Awake_Patch
		{
			public static bool Prefix(ZNetScene __instance)
			{
				LoadAssets();
				foreach (GameObject allPrefab in allPrefabs)
				{
					if ((Object)(object)allPrefab.GetComponent<ZNetView>() != (Object)null)
					{
						__instance.m_prefabs.Add(allPrefab);
					}
				}
				return true;
			}

			public static void Postfix(ZNetScene __instance)
			{
				TyrRaven.SetupAssets();
				PatreonPortal.SetupAssets();
				MobTweaks.ZNS_Init(__instance);
				ShipTweaks.ZNS_Init(__instance);
				BuildPieces.Init();
				TraderTweaks.ZNS_Init(__instance);
			}
		}

		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		public class ObjectDB_Awake_Patch
		{
			public static void Postfix(ObjectDB __instance)
			{
				LoadAssets();
				foreach (GameObject allPrefab in allPrefabs)
				{
					if ((Object)(object)allPrefab.GetComponent<ItemDrop>() != (Object)null)
					{
						__instance.m_items.Add(allPrefab);
						__instance.m_itemByHash.Add(StringExtensionMethods.GetStableHashCode(((Object)allPrefab).name), allPrefab);
					}
				}
				InvStrip.Init();
			}
		}

		[HarmonyPatch(typeof(Player), "OnSpawned")]
		public static class Player_Awake_Patch
		{
			public static void Postfix(Player __instance)
			{
				foreach (GameObject hammerPrefab in hammerPrefabs)
				{
					if ((Object)(object)hammerPrefab != (Object)null)
					{
						AddToHammer(hammerPrefab);
					}
				}
			}
		}

		private static bool assetsLoaded = false;

		public static string portalBundle = "patreonportal";

		public static string askiaBundle = "askia";

		public static string capesBundle = "patreoncapes";

		public static string denariusBundle = "denarius";

		public static string merchantTokenBundle = "merchanttoken";

		public static List<GameObject> allPrefabs = new List<GameObject>();

		public static List<Material> capeMaterials = new List<Material>();

		public static List<GameObject> hammerPrefabs = new List<GameObject>();

		private static AssetBundle GetAssetBundleFromResources(string filename)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(filename));
			return AssetBundle.LoadFromStream(executingAssembly.GetManifestResourceStream(name));
		}

		public static void LoadAssets()
		{
			if (assetsLoaded)
			{
				return;
			}
			AssetBundle assetBundleFromResources = GetAssetBundleFromResources(portalBundle);
			if ((Object)(object)assetBundleFromResources == (Object)null)
			{
				Debug.Log((object)("Failed to load AssetBundle " + portalBundle));
				return;
			}
			GameObject[] array = assetBundleFromResources.LoadAllAssets<GameObject>();
			Debug.Log((object)$"Loaded {array.Length} prefabs from AssetBundle {portalBundle}");
			GameObject[] array2 = array;
			foreach (GameObject item in array2)
			{
				allPrefabs.Add(item);
			}
			assetBundleFromResources.Unload(false);
			AssetBundle assetBundleFromResources2 = GetAssetBundleFromResources(askiaBundle);
			if ((Object)(object)assetBundleFromResources2 == (Object)null)
			{
				Debug.Log((object)("Failed to load AssetBundle " + askiaBundle));
				return;
			}
			GameObject[] array3 = assetBundleFromResources2.LoadAllAssets<GameObject>();
			Debug.Log((object)$"Loaded {array3.Length} prefabs from AssetBundle {askiaBundle}");
			array2 = array3;
			foreach (GameObject item2 in array2)
			{
				allPrefabs.Add(item2);
			}
			assetBundleFromResources2.Unload(false);
			AssetBundle assetBundleFromResources3 = GetAssetBundleFromResources(denariusBundle);
			if ((Object)(object)assetBundleFromResources3 == (Object)null)
			{
				Debug.Log((object)("Failed to load AssetBundle " + denariusBundle));
				return;
			}
			GameObject[] array4 = assetBundleFromResources3.LoadAllAssets<GameObject>();
			Debug.Log((object)$"Loaded {array4.Length} prefabs from AssetBundle {denariusBundle}");
			array2 = array4;
			foreach (GameObject val in array2)
			{
				allPrefabs.Add(val);
				if ((Object)(object)val.GetComponent<Piece>() != (Object)null)
				{
					hammerPrefabs.Add(val);
				}
			}
			assetBundleFromResources3.Unload(false);
			AssetBundle assetBundleFromResources4 = GetAssetBundleFromResources(merchantTokenBundle);
			if ((Object)(object)assetBundleFromResources4 == (Object)null)
			{
				Debug.Log((object)("Failed to load AssetBundle " + merchantTokenBundle));
				return;
			}
			GameObject[] array5 = assetBundleFromResources4.LoadAllAssets<GameObject>();
			Debug.Log((object)$"Loaded {array5.Length} prefabs from AssetBundle {merchantTokenBundle}");
			array2 = array5;
			foreach (GameObject val2 in array2)
			{
				allPrefabs.Add(val2);
				if ((Object)(object)val2.GetComponent<Piece>() != (Object)null)
				{
					hammerPrefabs.Add(val2);
				}
			}
			assetBundleFromResources4.Unload(false);
			assetsLoaded = true;
		}

		public static void AddToHammer(GameObject prefab)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			PieceTable val = null;
			Object[] array = Resources.FindObjectsOfTypeAll(typeof(PieceTable));
			for (int i = 0; i < array.Length; i++)
			{
				PieceTable val2 = (PieceTable)array[i];
				if (((Object)((Component)val2).gameObject).name.Contains("_HammerPieceTable"))
				{
					val = val2;
					break;
				}
			}
			if (val != null && !val.m_pieces.Contains(prefab))
			{
				prefab.GetComponent<Piece>();
				val.m_pieces.Add(prefab);
			}
		}
	}
	public class BossWorthiness
	{
		public static string worthyVFX = "vfx_offering";

		public static void RegisterRPC()
		{
			ZRoutedRpc.instance.Register<string, Vector3>("MakeWorthy", (Action<long, string, Vector3>)RPC_MakeWorthy);
		}

		public static string WorthyKey(string bossName)
		{
			return "tyr_" + bossName + "_worthy";
		}

		public static bool IsWorthy(Player p, string bossName)
		{
			return p.m_uniques.Contains(WorthyKey(bossName));
		}

		public static void MakeWorthy(Player p, string bossName)
		{
			if (!((Humanoid)p).HaveUniqueKey(WorthyKey(bossName)))
			{
				p.m_uniques.Add(WorthyKey(bossName));
			}
		}

		public static string PowerNameToBossName(string powerName)
		{
			return powerName.Split(new char[1] { '_' })[1];
		}

		public static string BossEventToBossName(string bossEventName)
		{
			return bossEventName.Split(new char[1] { '_' })[1].Replace("goblinking", "yagluth").Replace("gdking", "theelder").Replace("dragon", "moder");
		}

		public static void RPC_MakeWorthy(long sender, string bossName, Vector3 bossPosition)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			float num = 150f;
			if ((Object)(object)Player.m_localPlayer != (Object)null && Vector3.Distance(((Component)Player.m_localPlayer).transform.position, bossPosition) < num)
			{
				MakeWorthy(Player.m_localPlayer, bossName);
			}
		}
	}
	[HarmonyPatch(typeof(Character), "OnDeath")]
	public class Boss_Death_Patch
	{
		public static bool Prefix(Character __instance)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.IsBoss() && !string.IsNullOrEmpty(__instance.m_bossEvent))
			{
				string text = BossWorthiness.BossEventToBossName(__instance.m_bossEvent);
				Vector3 position = ((Component)__instance).transform.position;
				BossWorthiness.RPC_MakeWorthy(0L, text, position);
				ZRoutedRpc.instance.InvokeRoutedRPC(ZNetView.Everybody, "MakeWorthy", new object[2] { text, position });
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(ItemStand), "DelayedPowerActivation")]
	public class PowerActivationPatch
	{
		public static bool Prefix(ItemStand __instance)
		{
			if ((Object)(object)Player.m_localPlayer != (Object)null && !BossWorthiness.IsWorthy(Player.m_localPlayer, BossWorthiness.PowerNameToBossName(__instance.m_guardianPower.m_name)))
			{
				((Character)Player.m_localPlayer).Message((MessageType)2, "The spirit of " + __instance.m_guardianPower.m_name + " does not find you worthy", 0, (Sprite)null);
				TyrRaven.Message(Messages.notWorthy);
				return false;
			}
			return true;
		}
	}
	public class BuildExclusion
	{
		public static ConfigEntry<float> _bossSummonExclusionRadius;

		public static ConfigEntry<float> _bossHookExclusionRadius;

		public static ConfigEntry<float> _dungeonExclusionRadius;

		public static ConfigEntry<float> _JCWorldBossExclusionRadius;

		public static void SetupConfig(Mod instance)
		{
			_bossSummonExclusionRadius = instance.SyncedConfig("BuildExclusion", "Boss Summon Exclusion Radius", 75f, "Build exclusion zone around Boss Summoners (Offering Bowls)");
			_bossHookExclusionRadius = instance.SyncedConfig("BuildExclusion", "Boss Hook Exclusion Radius", 75f, "Build exclusion zone around Boss Trophy Hooks");
			_dungeonExclusionRadius = instance.SyncedConfig("BuildExclusion", "Dungeon Exclusion Radius", 20f, "Build exclusion zone around dungeons (Crypts, Burial Chambers, etc.)");
			_JCWorldBossExclusionRadius = instance.SyncedConfig("BuildExclusion", "JC WorldBoss Exclusion Radius", 30f, "Build exclusion zone around Jewelcrafting WorldBoss events");
		}

		public static void SetupBuildExclusion(GameObject go, float radius)
		{
			Location component = go.GetComponent<Location>();
			if ((Object)(object)component == (Object)null)
			{
				component = go.AddComponent<Location>();
				component.m_exteriorRadius = Math.Max(0f, radius);
				component.m_noBuild = true;
				component.m_clearArea = false;
				component.m_applyRandomDamage = false;
				component.m_hasInterior = false;
			}
			else
			{
				component.m_exteriorRadius = Math.Max(component.m_exteriorRadius, radius);
				component.m_noBuild = true;
			}
		}
	}
	public class BuildPieces
	{
		public static void Init()
		{
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			PieceTable hammerPieceTable = GetHammerPieceTable();
			ZNetScene.instance.GetPrefab("turf_roof").GetComponent<Piece>().m_name = "Turf Roof";
			AddToPieceTable(ZNetScene.instance.GetPrefab("turf_roof"), hammerPieceTable);
			ZNetScene.instance.GetPrefab("turf_roof_top").GetComponent<Piece>().m_name = "Turf Roof Top";
			AddToPieceTable(ZNetScene.instance.GetPrefab("turf_roof_top"), hammerPieceTable);
			ZNetScene.instance.GetPrefab("turf_roof_wall").GetComponent<Piece>().m_name = "Turf Roof Wall";
			AddToPieceTable(ZNetScene.instance.GetPrefab("turf_roof_wall"), hammerPieceTable);
			ZNetScene.instance.GetPrefab("ArmorStand_Male").GetComponent<Piece>().m_name = "ArmorStand Male";
			AddToPieceTable(ZNetScene.instance.GetPrefab("ArmorStand_Male"), hammerPieceTable);
			ZNetScene.instance.GetPrefab("ArmorStand_Female").GetComponent<Piece>().m_name = "ArmorStand Female";
			AddToPieceTable(ZNetScene.instance.GetPrefab("ArmorStand_Female"), hammerPieceTable);
			GameObject prefab = ZNetScene.instance.GetPrefab("stone_floor");
			prefab.GetComponent<Piece>().m_resources = (Requirement[])(object)new Requirement[1]
			{
				new Requirement
				{
					m_resItem = GetItemDrop("Stone"),
					m_amount = 12,
					m_recover = true
				}
			};
			AddToPieceTable(prefab, hammerPieceTable);
		}

		private static ItemDrop GetItemDrop(string prefabName)
		{
			GameObject prefab = ZNetScene.instance.GetPrefab(prefabName);
			ItemDrop obj = ((prefab != null) ? prefab.GetComponent<ItemDrop>() : null);
			if ((Object)(object)obj == (Object)null)
			{
				Debug.Log((object)("ERROR: Failed to find ItemDrop for " + prefabName));
			}
			return obj;
		}

		private static PieceTable GetHammerPieceTable()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			Object[] array = Resources.FindObjectsOfTypeAll(typeof(PieceTable));
			for (int i = 0; i < array.Length; i++)
			{
				PieceTable val = (PieceTable)array[i];
				if (((Object)((Component)val).gameObject).name.Contains("_HammerPieceTable"))
				{
					return val;
				}
			}
			return null;
		}

		private static void AddToPieceTable(GameObject prefab, PieceTable table)
		{
			if (!((Object)(object)table == (Object)null) && !((Object)(object)prefab == (Object)null) && !table.m_pieces.Contains(prefab))
			{
				table.m_pieces.Add(prefab);
			}
		}
	}
	public class ChatTweaks
	{
		[HarmonyPatch(typeof(UserInfo), "GetDisplayName")]
		public static class Chat_DisplayName_Patch
		{
			public static bool Prefix(UserInfo __instance, ref string __result)
			{
				if ((Object)(object)Player.m_localPlayer != (Object)null && !((Character)Player.m_localPlayer).InGodMode())
				{
					__result = CensorShittyWords.FilterUGC(__instance.Name, (UGCType)2, "", 0L);
					return false;
				}
				return true;
			}
		}
	}
	public class RuneStone_Receiver : TextReceiver
	{
		public string GetText()
		{
			return "";
		}

		public void SetText(string text)
		{
			RuneStonePatch.SetText(text);
		}
	}
	[HarmonyPatch(typeof(RuneStone), "Interact")]
	public class RuneStonePatch
	{
		public static RuneStone s_queuedStone;

		public static RuneStone_Receiver s_receiver = new RuneStone_Receiver();

		public static void SetText(string text)
		{
			if ((Object)(object)s_queuedStone != (Object)null)
			{
				s_queuedStone.m_label = "";
				s_queuedStone.m_locationName = "";
				s_queuedStone.m_randomTexts.Clear();
				s_queuedStone.m_text = text;
				s_queuedStone = null;
			}
		}

		public static bool Prefix(RuneStone __instance, Humanoid character, bool hold, bool alt)
		{
			if (!((Character)Player.m_localPlayer).InGodMode() || !alt)
			{
				return true;
			}
			s_queuedStone = __instance;
			TextInput.instance.RequestText((TextReceiver)(object)s_receiver, "$piece_portal_tag", 10);
			return false;
		}
	}
	public class DeathMessages
	{
		public static Dictionary<HitType, string[]> s_environmentDeathMessages = new Dictionary<HitType, string[]>
		{
			{
				(HitType)3,
				new string[3] { "PLAYER_NAME hit the ground... and didn't bounce.", "The earth broke PLAYER_NAME's fall. A little too firmly.", "PLAYER_NAME fell like a stone. And landed, like a stone. A dead stone." }
			},
			{
				(HitType)4,
				new string[3] { "PLAYER_NAME went swimming a little too far from shore.", "PLAYER_NAME tried to gargle the ocean.", "The deep waters accepted PLAYER_NAME in its cold, dark embrace." }
			},
			{
				(HitType)5,
				new string[3] { "PLAYER_NAME burnt oh so brightly, but all too briefly.", "The beacon is lit! Oh no, that was just PLAYER_NAME.", "PLAYER_NAME used themselves as kindling." }
			},
			{
				(HitType)6,
				new string[3] { "PLAYER_NAME couldn't keep out the cold.", "PLAYER_NAME should have wrapped up warmer.", "PLAYER_NAME has a cold cold heart. Frozen, in fact." }
			},
			{
				(HitType)7,
				new string[1] { "PLAYER_NAME's body couldn't withstand the poison." }
			},
			{
				(HitType)8,
				new string[1] { "PLAYER_NAME went swimming a little too far from shore." }
			},
			{
				(HitType)9,
				new string[1] { "PLAYER_NAME prepared some well-smoked meat. Viking meat." }
			},
			{
				(HitType)10,
				new string[1] { "PLAYER_NAME ventured off the edge of the unknown." }
			},
			{
				(HitType)11,
				new string[1] { "PLAYER_NAME took a hit like a warrior. A dead warrior." }
			},
			{
				(HitType)13,
				new string[1] { "PLAYER_NAME discovered the dangers of lumberjacking." }
			},
			{
				(HitType)14,
				new string[1] { "PLAYER_NAME decided to end it all." }
			},
			{
				(HitType)16,
				new string[1] { "PLAYER_NAME provided excellent target practice." }
			},
			{
				(HitType)17,
				new string[2] { "PLAYER_NAME failed their attempt to water-ski.", "PLAYER_NAME should not be allowed near boats." }
			},
			{
				(HitType)18,
				new string[1] { "PLAYER_NAME was skewered from above." }
			},
			{
				(HitType)19,
				new string[1] { "PLAYER_NAME provided excellent target practice." }
			},
			{
				(HitType)20,
				new string[1] { "PLAYER_NAME was caught in the rain. Firey rain. Burny firey rain." }
			},
			{
				(HitType)21,
				new string[2] { "PLAYER_NAME made a rather tasty hot soup.", "PLAYER_NAME was broiled alive beneath the steaming waters." }
			}
		};

		public static Dictionary<string, string[]> s_mobDeathMessages = new Dictionary<string, string[]>
		{
			{
				"$enemy_neck",
				new string[1] { "PLAYER_NAME got their toes nibbled a little too hard by KILLER_NAME." }
			},
			{
				"$enemy_greyling",
				new string[1] { "PLAYER_NAME lost a staring contest with KILLER_NAME." }
			},
			{
				"$enemy_boar",
				new string[2] { "PLAYER_NAME was **boar**ed to death.", "PLAYER_NAME was gored by KILLER_NAME's tusks." }
			},
			{
				"$enemy_skeleton",
				new string[2] { "KILLER_NAME got jealous of PLAYER_NAME's flesh.", "KILLER_NAME liberated PLAYER_NAME's bones." }
			},
			{
				"$enemy_skeletonpoison",
				new string[2] { "KILLER_NAME got jealous of PLAYER_NAME's flesh.", "KILLER_NAME gave PLAYER_NAME a poisonous embrace." }
			},
			{
				"$enemy_greydwarf",
				new string[2] { "PLAYER_NAME was transfixed by the blue eyes of KILLER_NAME. Then things went black.", "KILLER_NAME harvested PLAYER_NAME's eyes for its collection." }
			},
			{
				"$enemy_greydwarfbrute",
				new string[2] { "PLAYER_NAME held negotiations with KILLER_NAME. They went badly.", "KILLER_NAME showed PLAYER_NAME their place in the world. Face down in the dirt." }
			},
			{
				"$enemy_ghost",
				new string[3] { "PLAYER_NAME was haunted by KILLER_NAME.", "KILLER_NAME dragged PLAYER_NAME across the veil.", "PLAYER_NAME is taking haunting lessons from KILLER_NAME." }
			},
			{
				"$enemy_troll",
				new string[2] { "KILLER_NAME offered PLAYER_NAME a tree. As a hat.", "KILLER_NAME threw PLAYER_NAME around like a ragdoll." }
			},
			{
				"$enemy_wraith",
				new string[2] { "KILLER_NAME just wanted a hug from PLAYER_NAME.", "PLAYER_NAME tried to rattle KILLER_NAME's chains. Bad idea." }
			},
			{
				"$enemy_leech",
				new string[2] { "PLAYER_NAME fulfilled their dream of swimming with KILLER_NAME.", "PLAYER_NAME made a generous blood donation to KILLER_NAME." }
			},
			{
				"$enemy_draugr",
				new string[3] { "PLAYER_NAME was hunted down by KILLER_NAME.", "KILLER_NAME wouldn't let PLAYER_NAME escape.", "KILLER_NAME stalked PLAYER_NAME through the mist." }
			},
			{
				"$enemy_draugrelite",
				new string[3] { "PLAYER_NAME was hunted down by KILLER_NAME.", "KILLER_NAME wouldn't let PLAYER_NAME escape.", "KILLER_NAME stalked PLAYER_NAME through the mist." }
			},
			{
				"$enemy_blob",
				new string[2] { "PLAYER_NAME got slimed by KILLER_NAME.", "PLAYER_NAME's body was dissolved by KILLER_NAME." }
			},
			{
				"$enemy_blobelite",
				new string[2] { "PLAYER_NAME got slimed by KILLER_NAME.", "PLAYER_NAME's body was dissolved by KILLER_NAME." }
			},
			{
				"$enemy_abomination",
				new string[3] { "PLAYER_NAME got crushed into the ground by KILLER_NAME.", "PLAYER_NAME's mangled body is being absorbed by KILLER_NAME's roots.", "KILLER_NAME pounded PLAYER_NAME's body into the ground." }
			},
			{
				"$enemy_surtling",
				new string[1] { "PLAYER_NAME was torched alive by KILLER_NAME." }
			},
			{
				"$enemy_wolf",
				new string[3] { "KILLER_NAME tore hungrily into the flesh of PLAYER_NAME.", "KILLER_NAME sank its teeth into PLAYER_NAME.", "PLAYER_NAME didn't heed KILLER_NAME's warning." }
			},
			{
				"$enemy_stonegolem",
				new string[2] { "PLAYER_NAME hit a stone wall. In the form of KILLER_NAME.", "PLAYER_NAME was mercilessly crushed by KILLER_NAME." }
			},
			{
				"$enemy_drake",
				new string[2] { "PLAYER_NAME succumbed to the icy breath of KILLER_NAME.", "The last sound PLAYER_NAME heard was the shriek of KILLER_NAME." }
			},
			{
				"$enemy_fenring",
				new string[3] { "PLAYER_NAME failed to outrun KILLER_NAME.", "PLAYER_NAME faced the dark form of KILLER_NAME, and didn't live to tell the tale.", "KILLER_NAME brutally shredded PLAYER_NAME's body." }
			},
			{
				"$enemy_goblin",
				new string[2] { "PLAYER_NAME was stalked by KILLER_NAME.", "KILLER_NAME cackled over PLAYER_NAME's lifeless body." }
			},
			{
				"$enemy_lox",
				new string[3] { "PLAYER_NAME failed to tame an angry **Lox**.", "PLAYER_NAME wore a Lox cape. But the **Lox** was still alive.", "PLAYER_NAME was hopelessly crushed underfoot by KILLER_NAME." }
			},
			{
				"$enemy_deathsquito",
				new string[2] { "KILLER_NAME gave PLAYER_NAME a nasty sting.", "KILLER_NAME drew an extensive blood sample from PLAYER_NAME." }
			},
			{
				"$enemy_blobtar",
				new string[1] { "KILLER_NAME put PLAYER_NAME in a sticky situation." }
			},
			{
				"$enemy_eikthyr",
				new string[2] { "PLAYER_NAME faced the thunder of KILLER_NAME. And lost.", "KILLER_NAME trampled the helpless PLAYER_NAME beneath his thundrous hooves." }
			},
			{
				"$enemy_gdking",
				new string[2] { "KILLER_NAME was unperturbed by PLAYER_NAME's challenge.", "KILLER_NAME banished PLAYER_NAME's from his realm." }
			},
			{
				"$enemy_bonemass",
				new string[2] { "PLAYER_NAME foolishly disturbed the slumber of KILLER_NAME.", "PLAYER_NAME's mangled corpse is being absorbed by KILLER_NAME." }
			},
			{
				"$enemy_dragon",
				new string[2] { "KILLER_NAME wrought her revenge upon PLAYER_NAME.", "KILLER_NAME shed no tears for PLAYER_NAME." }
			},
			{
				"$enemy_goblinking",
				new string[3] { "KILLER_NAME rent the soul of PLAYER_NAME from their body, and cast it into unholy fire.", "PLAYER_NAME could now withstand the unholy fury of KILLER_NAME.", "KILLER_NAME claimed PLAYER_NAME's soul as a trophy." }
			}
		};

		public static string[] s_genericMobDeathMessages = new string[5] { "PLAYER_NAME was brutally disemboweled by KILLER_NAME.", "PLAYER_NAME tangled too closely with KILLER_NAME.", "PLAYER_NAME didn't quite manage to dodge KILLER_NAME.", "PLAYER_NAME couldn't outrun KILLER_NAME.", "PLAYER_NAME should have been friendlier to KILLER_NAME." };

		public static string SelectMessage(HitType hit, string killer)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			if ((int)hit != 1)
			{
				if ((int)hit == 2)
				{
					return "";
				}
				return s_environmentDeathMessages[hit][Random.Range(0, s_environmentDeathMessages[hit].Length)];
			}
			if (s_mobDeathMessages.ContainsKey(killer))
			{
				return s_mobDeathMessages[killer][Random.Range(0, s_mobDeathMessages[killer].Length)];
			}
			return s_genericMobDeathMessages[Random.Range(0, s_genericMobDeathMessages.Length)];
		}
	}
	public class DeathMessaging
	{
		[HarmonyPatch(typeof(Player), "OnDeath")]
		public static class Player_OnDeath_Patch
		{
			public static void Postfix(Player __instance)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Expected O, but got Unknown
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Expected I4, but got Unknown
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Invalid comparison between Unknown and I4
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Invalid comparison between Unknown and I4
				ZPackage val = new ZPackage();
				val.Write(__instance.GetPlayerName());
				val.Write((byte)(int)((Character)__instance).m_lastHit.m_hitType);
				if (((int)((Character)__instance).m_lastHit.m_hitType == 1 || (int)((Character)__instance).m_lastHit.m_hitType == 2) && Object.op_Implicit((Object)(object)((Character)__instance).m_lastHit.GetAttacker()))
				{
					val.Write(((Character)__instance).m_lastHit.GetAttacker().m_name);
					val.Write(((Character)__instance).m_lastHit.GetAttacker().IsBoss());
				}
				ZRoutedRpc.instance.InvokeRoutedRPC("DeathNotify", new object[1] { val });
			}
		}

		private const string webhookFilename = "deathreport_webhook.txt";

		private static string webhookFilePath
		{
			get
			{
				string configPath = Paths.ConfigPath;
				char directorySeparatorChar = Path.DirectorySeparatorChar;
				return configPath + directorySeparatorChar + "deathreport_webhook.txt";
			}
		}

		private static string readWebhookURL()
		{
			return File.ReadAllLines(webhookFilePath)[0];
		}

		public static string AddPronounAndBold(string s)
		{
			if ("aeiouAEIOU".IndexOf(s[0]) < 0)
			{
				return "a **" + s + "**";
			}
			return "an **" + s + "**";
		}

		public static string InitialUpper(string s)
		{
			if (string.IsNullOrEmpty(s))
			{
				return string.Empty;
			}
			char[] array = s.ToCharArray();
			array[0] = char.ToUpper(array[0]);
			return new string(array);
		}

		public static void RPC_DeathNotify(long sender, ZPackage data)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if (!Mod.IsAdminRPC(ZNet.instance.GetPeer(sender)))
			{
				string text = data.ReadString();
				HitType val = (HitType)data.ReadByte();
				string text2 = "";
				bool flag = false;
				if ((int)val == 1 || (int)val == 2)
				{
					text2 = data.ReadString();
					flag = data.ReadBool();
				}
				string text3 = DeathMessages.SelectMessage(val, text2).Replace("PLAYER_NAME", "**" + text + "**");
				if (!Utility.IsNullOrWhiteSpace(text2))
				{
					text3 = text3.Replace("KILLER_NAME", flag ? ("**" + Localization.instance.Localize(text2) + "**") : (AddPronounAndBold(Localization.instance.Localize(text2)) ?? ""));
				}
				text3 = InitialUpper(text3);
				string json = "{ \"content\": null, \"embeds\" : [ { \"title\" : \"A bell tolls...\", \"description\" : \"" + text3 + "\"} ] }";
				if (File.Exists(webhookFilePath))
				{
					Webhook.SendJSON(readWebhookURL(), json);
				}
			}
		}

		public static void RegisterRPC()
		{
			ZRoutedRpc.instance.Register<ZPackage>("DeathNotify", (Action<long, ZPackage>)RPC_DeathNotify);
		}
	}
	public class Webhook
	{
		public static void SendJSON(string webhookURL, string json)
		{
			if (string.IsNullOrEmpty(webhookURL))
			{
				Debug.Log((object)"Webook request to empty URL");
				return;
			}
			Debug.Log((object)("Sending POST to webhook: " + webhookURL));
			byte[] bytes = Encoding.UTF8.GetBytes(json);
			WebRequest webRequest = WebRequest.Create(webhookURL);
			webRequest.Method = "POST";
			webRequest.ContentType = "application/json";
			webRequest.ContentLength = bytes.Length;
			Stream requestStream = webRequest.GetRequestStream();
			requestStream.Write(bytes, 0, bytes.Length);
			requestStream.Close();
			webRequest.GetResponse().Close();
		}
	}
	public class Graverobbing
	{
		[HarmonyPatch(typeof(Container), "SetInUse")]
		public static class Container_SetInUse_Patch
		{
			public static void Postfix(Container __instance, bool inUse)
			{
				if (!inUse && __instance.GetInventory() == trackedInventory)
				{
					ProduceReport(__instance);
				}
			}
		}

		private const string webhookFilename = "graverobbing_webhook.txt";

		private const string logFilename = "graverobbing.log";

		private static Dictionary<string, int> priorInventory;

		private static Inventory trackedInventory;

		private static string logFilePath
		{
			get
			{
				string bepInExRootPath = Paths.BepInExRootPath;
				char directorySeparatorChar = Path.DirectorySeparatorChar;
				return bepInExRootPath + directorySeparatorChar + "graverobbing.log";
			}
		}

		private static string webhookFilePath
		{
			get
			{
				string configPath = Paths.ConfigPath;
				char directorySeparatorChar = Path.DirectorySeparatorChar;
				return configPath + directorySeparatorChar + "graverobbing_webhook.txt";
			}
		}

		private static string readWebhookURL()
		{
			return File.ReadAllLines(webhookFilePath)[0];
		}

		public static Dictionary<string, int> ContentsOfInventory(Inventory i)
		{
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			foreach (ItemData item in i.m_inventory)
			{
				string name = item.m_shared.m_name;
				dictionary[name] = (dictionary.ContainsKey(name) ? dictionary[name] : 0) + item.m_stack;
			}
			return dictionary;
		}

		public static string StringifyContents(Dictionary<string, int> contents)
		{
			string text = string.Empty;
			foreach (KeyValuePair<string, int> content in contents)
			{
				text += $"{Localization.instance.Localize(content.Key)} x {content.Value}\n";
			}
			return text;
		}

		public static void TombstoneInteract(Player p, TombStone t)
		{
			trackedInventory = ((Component)t).GetComponent<Container>().GetInventory();
			priorInventory = ContentsOfInventory(trackedInventory);
		}

		public static ZPackage SerializeData(string looter, string tombOwner, Vector3 location, Dictionary<string, int> added, Dictionary<string, int> removed)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			ZPackage val = new ZPackage();
			val.Write(looter);
			val.Write(tombOwner);
			val.Write(location);
			val.Write(added.Count);
			foreach (KeyValuePair<string, int> item in added)
			{
				val.Write(item.Key);
				val.Write(item.Value);
			}
			val.Write(removed.Count);
			foreach (KeyValuePair<string, int> item2 in removed)
			{
				val.Write(item2.Key);
				val.Write(item2.Value);
			}
			return val;
		}

		public static void DeserializeData(ZPackage data, out string looter, out string tombOwner, out Vector3 location, out Dictionary<string, int> added, out Dictionary<string, int> removed)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			looter = data.ReadString();
			tombOwner = data.ReadString();
			location = data.ReadVector3();
			int num = data.ReadInt();
			added = new Dictionary<string, int>();
			for (int i = 0; i < num; i++)
			{
				string key = data.ReadString();
				int value = data.ReadInt();
				added[key] = value;
			}
			int num2 = data.ReadInt();
			removed = new Dictionary<string, int>();
			for (int j = 0; j < num2; j++)
			{
				string key2 = data.ReadString();
				int value2 = data.ReadInt();
				removed[key2] = value2;
			}
		}

		public static void ProduceReport(Container cont)
		{
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<string, int> dictionary = ContentsOfInventory(trackedInventory);
			Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
			Dictionary<string, int> dictionary3 = new Dictionary<string, int>();
			foreach (KeyValuePair<string, int> item in priorInventory)
			{
				int value;
				int num = (dictionary.TryGetValue(item.Key, out value) ? value : 0);
				if (num < item.Value)
				{
					dictionary2[item.Key] = item.Value - num;
				}
			}
			foreach (KeyValuePair<string, int> item2 in dictionary)
			{
				int value2;
				int num2 = (priorInventory.TryGetValue(item2.Key, out value2) ? value2 : 0);
				if (num2 < item2.Value)
				{
					dictionary3[item2.Key] = item2.Value - num2;
				}
			}
			ZPackage val = SerializeData(Game.instance.GetPlayerProfile().GetName(), cont.m_nview.GetZDO().GetString("ownerName", ""), ((Component)cont).transform.position, dictionary3, dictionary2);
			ZRoutedRpc.instance.InvokeRoutedRPC("InventoryLog", new object[1] { val });
		}

		public static string CreateJsonReport(string looter, string owner, Vector3 location, Dictionary<string, int> added, Dictionary<string, int> removed)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			string text = $"{{ \"content\": null, \"embeds\" : [ {{ \"title\" : \"Graverobber Report\", \"description\" : \"**{looter}** opened tombstone owned by **{owner}**\\n*{DateTime.UtcNow.ToString()}* UTC\\n*Tombstone location: {location}*\"";
			if (added.Count > 0 || removed.Count > 0)
			{
				text += ", \"fields\" : [";
				if (removed.Count > 0)
				{
					text += "{ \"name\" : \"Items Removed\", \"value\" : \"";
					foreach (KeyValuePair<string, int> item in removed)
					{
						text += $"- {Localization.instance.Localize(item.Key)} x {item.Value}\\n";
					}
					text += "\"}";
				}
				if (added.Count > 0)
				{
					if (removed.Count > 0)
					{
						text += ",";
					}
					text += "{ \"name\" : \"Items Added\", \"value\" : \"";
					foreach (KeyValuePair<string, int> item2 in added)
					{
						text += $"- {Localization.instance.Localize(item2.Key)} x {item2.Value}\\n";
					}
					text += "\"}";
				}
				text += "]";
			}
			return text + "} ] }";
		}

		public static string CreateRawReport(string looter, string owner, Vector3 location, Dictionary<string, int> added, Dictionary<string, int> removed)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			return string.Concat(string.Concat(string.Concat(string.Concat(string.Concat("=== [" + looter + "] opened tombstone owned by [" + owner + "] ===\n", "Timestamp (UTC): ", DateTime.UtcNow.ToString(), "\n"), $"Tombstone Location: {location}\n"), "--- Items removed ---\n", StringifyContents(removed)), "--- Items added --- \n", StringifyContents(added)), "===============================================\n");
		}

		public static void RPC_WriteLog(long sender, ZPackage data)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (ZNet.instance.IsServer())
			{
				DeserializeData(data, out var looter, out var tombOwner, out var location, out var added, out var removed);
				File.AppendAllText(logFilePath, CreateRawReport(looter, tombOwner, location, added, removed));
				if (File.Exists(webhookFilePath) && (added.Count > 0 || removed.Count > 0))
				{
					Webhook.SendJSON(readWebhookURL(), CreateJsonReport(looter, tombOwner, location, added, removed));
				}
			}
		}

		public static void RegisterRPC()
		{
			ZRoutedRpc.instance.Register<ZPackage>("InventoryLog", (Action<long, ZPackage>)RPC_WriteLog);
		}
	}
	public class FirstSpawnOverride
	{
	}
	public class ObjectTracking
	{
		[HarmonyPatch(typeof(DungeonGenerator), "Awake")]
		private static class DungeonGenerator_Awake_Patch
		{
			private static void Postfix(DungeonGenerator __instance)
			{
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				dungeons.Add(__instance);
				if (((Enum)__instance.m_themes).HasFlag((Enum)(object)(Theme)1) || ((Enum)__instance.m_themes).HasFlag((Enum)(object)(Theme)8) || ((Enum)__instance.m_themes).HasFlag((Enum)(object)(Theme)2) || ((Enum)__instance.m_themes).HasFlag((Enum)(object)(Theme)4))
				{
					BuildExclusion.SetupBuildExclusion(((Component)__instance).gameObject, BuildExclusion._dungeonExclusionRadius.Value);
				}
			}
		}

		[HarmonyPatch(typeof(DungeonGenerator), "Clear")]
		private static class DungeonGenerator_Clear_Patch
		{
			private static void Postfix(DungeonGenerator __instance)
			{
				dungeons.Remove(__instance);
			}
		}

		[HarmonyPatch(typeof(OfferingBowl), "Awake")]
		private static class OfferingBowl_Awake_Patch
		{
			private static void Postfix(OfferingBowl __instance)
			{
				offeringBowls.Add(__instance);
				BuildExclusion.SetupBuildExclusion(((Component)__instance).gameObject, BuildExclusion._bossSummonExclusionRadius.Value);
			}
		}

		[HarmonyPatch(typeof(BossStone), "Start")]
		private static class BossStone_Start_Patch
		{
			private static void Postfix(BossStone __instance)
			{
				bossStones.Add(__instance);
				BuildExclusion.SetupBuildExclusion(((Component)__instance).gameObject, BuildExclusion._bossHookExclusionRadius.Value);
			}
		}

		[HarmonyPatch(typeof(Destructible), "Start")]
		private static class Destructible_Start_Patch
		{
			private static List<int> JCBossPrefabHashes = new List<int>
			{
				StringExtensionMethods.GetStableHashCode("Crystal_Soul_Reaper_Cage"),
				StringExtensionMethods.GetStableHashCode("Crystal_Flame_Reaper_Cage"),
				StringExtensionMethods.GetStableHashCode("Crystal_Frost_Reaper_Cage")
			};

			private static void Postfix(Destructible __instance)
			{
				if (__instance.m_nview.IsValid() && __instance.m_nview.GetZDO() != null)
				{
					int prefab = __instance.m_nview.GetZDO().GetPrefab();
					if (JCBossPrefabHashes.Contains(prefab))
					{
						BuildExclusion.SetupBuildExclusion(((Component)__instance).gameObject, BuildExclusion._JCWorldBossExclusionRadius.Value);
					}
				}
			}
		}

		[HarmonyPatch(typeof(LocationProxy), "Awake")]
		private static class LocationProxy_Awake_Patch
		{
			private static List<int> proxyHashes = new List<int>
			{
				StringExtensionMethods.GetStableHashCode("DrakeNest01"),
				StringExtensionMethods.GetStableHashCode("Mistlands_DvergrBossEntrance1"),
				StringExtensionMethods.GetStableHashCode("Mistlands_DvergrTownEntrance1"),
				StringExtensionMethods.GetStableHashCode("Mistlands_DvergrTownEntrance2"),
				StringExtensionMethods.GetStableHashCode("MountainCave02")
			};

			private static void Postfix(LocationProxy __instance)
			{
				if (!((Object)(object)__instance.m_nview == (Object)null) && __instance.m_nview.IsValid() && __instance.m_nview.GetZDO() != null)
				{
					int @int = __instance.m_nview.GetZDO().GetInt(ZDOVars.s_location, 0);
					if (proxyHashes.Contains(@int))
					{
						BuildExclusion.SetupBuildExclusion(((Component)__instance).gameObject, BuildExclusion._dungeonExclusionRadius.Value);
					}
				}
			}
		}

		public static ISet<DungeonGenerator> dungeons = new HashSet<DungeonGenerator>();

		public static ISet<OfferingBowl> offeringBowls = new HashSet<OfferingBowl>();

		public static ISet<BossStone> bossStones = new HashSet<BossStone>();
	}
	[HarmonyPatch(typeof(Game), "ShowIntro")]
	public class Game_ShowText_Patch
	{
		private static readonly string s_introTopic = "Darkness Stirs...";

		private static readonly string s_introText = "A shudder ripples through the fabric of the realm, stirring the oceans, and once again clearing away the mists of time. The Allfather's foes are reaskening, their avatars once again eagerly seek to breach their exile.\r\n\r\nBrave ancestral warriors fought and died to defeat new foes amongst frigid wastes and scorched ash. However, whilst one now remains <color=#00eeee>pristine</color>, a testament to their valour, the other is <color=#F8B21C>ablaze</color> with ever more fury..\r\n\r\nNervous birdsong speaks of flaming skies, and whispers on the wind speak of dark structures wrought from charred stone rising eagerly from the ground to meet them. <color=#500505>Fire and ash</color>, it seems, have found new allies - more twisted still than those who dwelt before.\r\n\r\n<color=#cdcdcd>Tyr's</color> call once again reverberates through the spirit world, demanding that you prove your worth. A great wind rouses you from your deathly slumber, as great wings begin to carry you on your journey.\r\n\r\nHarken PLAYER_NAME! Life, death, destiny and fame await you...\r\n\r\n... in <color=#ff0000>Tyrenheim</color>!";

		public static bool Prefix(Game __instance)
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			string newValue;
			try
			{
				newValue = "<color=yellow>" + Game.instance.GetPlayerProfile().GetName() + "</color>";
			}
			catch
			{
				newValue = "warrior";
			}
			__instance.m_introTopic = s_introTopic;
			__instance.m_introText = s_introText.Replace("PLAYER_NAME", newValue);
			TextViewer.instance.m_introText.fontSizeMin = 6f;
			TextViewer.instance.m_introText.richText = true;
			TMP_Text introText = TextViewer.instance.m_introText;
			introText.maxVisibleLines *= 2;
			TextViewer.instance.m_introText.rectTransform.SetSizeWithCurrentAnchors((Axis)1, 1150f);
			RectTransform rectTransform = TextViewer.instance.m_introText.rectTransform;
			rectTransform.anchoredPosition += new Vector2(0f, -100f);
			return true;
		}
	}
	public class InvStrip
	{
		[HarmonyPatch(typeof(Inventory), "Changed")]
		public class Inventory_Changed_Patch
		{
			public static void Prefix(Inventory __instance)
			{
				RunStrip(__instance);
			}
		}

		private static List<string> s_stripItemPrefabs = new List<string> { "WindBelt" };

		private static List<string> s_stripItemNames = new List<string>();

		public static void Init()
		{
			foreach (string s_stripItemPrefab in s_stripItemPrefabs)
			{
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(s_stripItemPrefab);
				if ((Object)(object)itemPrefab != (Object)null)
				{
					ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
					if ((Object)(object)component != (Object)null)
					{
						s_stripItemNames.Add(component.m_itemData.m_shared.m_name);
					}
				}
			}
		}

		public static void RunStrip(Inventory inv)
		{
			foreach (string itemName in s_stripItemNames)
			{
				inv.m_inventory.RemoveAll((ItemData x) => x.m_shared.m_name == itemName);
			}
		}
	}
	public class Test
	{
		[HarmonyPatch]
		public class MarketStallPatchClass
		{
			public static int s_smallMarketItemLimit = 8;

			public static int s_marketItemLimit = 20;

			public static int s_smallMarketHash = StringExtensionMethods.GetStableHashCode("MarketStall_Small");

			public static int s_marketHash = StringExtensionMethods.GetStableHashCode("MarketStall");

			private static FieldInfo s_locals2Field = null;

			private static FieldInfo s_innerContextField = null;

			private static FieldInfo s_contextZNVField = null;

			private static FieldInfo s_contextUserField = null;

			private static bool s_hasSetup = false;

			public static void PerformSetup(Type t)
			{
				if (!s_hasSetup)
				{
					s_locals2Field = t.GetField("CS$<>8__locals2", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					s_innerContextField = s_locals2Field.FieldType.GetField("CS$<>8__locals1", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					s_contextZNVField = s_innerContextField.FieldType.GetField("znv", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					s_contextUserField = s_innerContextField.FieldType.GetField("user", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					s_hasSetup = true;
				}
			}

			private static object GetContext(object instance)
			{
				return s_innerContextField.GetValue(s_locals2Field.GetValue(instance));
			}

			private static MethodBase TargetMethod()
			{
				Type[] nestedTypes = typeof(Marketplace).GetNestedTypes(BindingFlags.NonPublic);
				for (int i = 0; i < nestedTypes.Length; i++)
				{
					MethodInfo method = nestedTypes[i].GetMethod("<UpdateSellMarket>b__0", BindingFlags.Instance | BindingFlags.NonPublic);
					if (method != null)
					{
						return method;
					}
				}
				return null;
			}

			public static void Test(Type displayClassType)
			{
				Debug.Log((object)"============= TESTING =============");
				FieldInfo[] fields = displayClassType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (FieldInfo fieldInfo in fields)
				{
					Debug.Log((object)("############## Field: " + fieldInfo.Name + "  #################"));
					Type fieldType = fieldInfo.FieldType;
					if (fieldType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Length == 0)
					{
						continue;
					}
					FieldInfo[] fields2 = fieldType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					foreach (FieldInfo fieldInfo2 in fields2)
					{
						Debug.Log((object)("############## Inner Field: " + fieldInfo2.Name + "  #################"));
						if (fieldInfo2.Name.Contains("znv"))
						{
							Debug.Log((object)"############## FOUND INNER ZNV FIELD  #################");
						}
						Type fieldType2 = fieldInfo2.FieldType;
						if (fieldType2.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Length != 0)
						{
							FieldInfo[] fields3 = fieldType2.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
							foreach (FieldInfo fieldInfo3 in fields3)
							{
								Debug.Log((object)("############## Inner Inner Field: " + fieldInfo3.Name + "  #################"));
							}
						}
					}
				}
			}

			private static bool Prefix(object __instance)
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Expected O, but got Unknown
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Expected O, but got Unknown
				PerformSetup(__instance.GetType());
				object context = GetContext(__instance);
				ZNetView val = (ZNetView)(s_contextZNVField?.GetValue(context));
				Humanoid val2 = (Humanoid)(s_contextUserField?.GetValue(context));
				if ((Object)(object)val != (Object)null)
				{
					int prefab = val.GetZDO().GetPrefab();
					int count = Market.GetMarketData(val).Count;
					int num = ((prefab == s_smallMarketHash) ? s_smallMarketItemLimit : s_marketItemLimit);
					if (count >= num)
					{
						Methods.ShowMessage(val2, "<color=red>$maximum_items</color>", (Sprite)null);
						return false;
					}
				}
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(Character), "RPC_Damage")]
	public class Character_RPC_Damage_Patch
	{
		public static void Postfix(Character __instance, HitData hit)
		{
			if (__instance.IsPlayer() || !(__instance.GetHealth() <= 0f) || __instance.IsDead())
			{
				return;
			}
			Character attacker = hit.GetAttacker();
			if (((Object)(object)attacker == (Object)null && __instance.GetSEMan().HaveStatusEffect(SEMan.s_statusEffectBurning)) || ((Object)(object)attacker != (Object)null && !attacker.IsPlayer() && !attacker.IsTamed()))
			{
				CharacterDrop[] componentsInChildren = ((Component)__instance).gameObject.GetComponentsInChildren<CharacterDrop>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].SetDropsEnabled(false);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Ragdoll), "Setup")]
	public class Ragdoll_SaveLootList_Patch
	{
		public static void Prefix(Ragdoll __instance, ref CharacterDrop characterDrop)
		{
			if ((Object)(object)characterDrop != (Object)null && (Object)(object)characterDrop.m_character != (Object)null && !characterDrop.m_character.IsPlayer() && !characterDrop.m_dropsEnabled)
			{
				characterDrop = null;
			}
		}
	}
	public static class NetworkDialog_Tweaks
	{
		[HarmonyPatch(typeof(ConnectPanel), "Update")]
		public class ConnectPanel_Patch
		{
			public static void Postfix(ConnectPanel __instance)
			{
				if ((Object)(object)Player.m_localPlayer != (Object)null && ((Character)Player.m_localPlayer).InGodMode())
				{
					return;
				}
				foreach (GameObject playerListElement in __instance.m_playerListElements)
				{
					Text component = ((Component)playerListElement.transform.Find("hostname")).GetComponent<Text>();
					if ((Object)(object)component != (Object)null)
					{
						component.text = "";
					}
				}
			}
		}

		private const string hostnameReplacement = "";
	}
	public static class OrientationFixes
	{
		[HarmonyPatch(typeof(Smelter), "UpdateSmoke")]
		public class Smelter_Patch
		{
			public static void Postfix(Smelter __instance)
			{
				if (!checkTransform(((Component)__instance).gameObject.transform, (float)Math.PI / 4f))
				{
					__instance.m_blockedSmoke = true;
				}
			}
		}

		[HarmonyPatch(typeof(Fireplace), "IsBurning")]
		public class Fireplace_Patch
		{
			public static void Postfix(Fireplace __instance, ref bool __result)
			{
				if (!checkTransform(((Component)__instance).gameObject.transform, (float)Math.PI / 4f))
				{
					__result = false;
				}
			}
		}

		[HarmonyPatch(typeof(CookingStation), "UpdateCooking")]
		public class CookingStation_Patch
		{
			public static bool Prefix(CookingStation __instance)
			{
				if (!__instance.m_nview.IsValid())
				{
					return false;
				}
				if (!checkTransform(((Component)__instance).gameObject.transform, (float)Math.PI / 4f))
				{
					__instance.UpdateVisual(false);
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Bed), "CheckExposure")]
		public class Bed_ExposurePatch
		{
			public static void Postfix(Bed __instance, Player human, ref bool __result)
			{
				if (!checkTransform(((Component)__instance).gameObject.transform, (float)Math.PI / 6f))
				{
					((Character)human).Message((MessageType)2, "Bed is not at a suitable orientation", 0, (Sprite)null);
					__result = false;
				}
			}
		}

		[HarmonyPatch(typeof(Bed), "IsCurrent")]
		public class Bed_CurrentPatch
		{
			public static void Postfix(Bed __instance, ref bool __result)
			{
				if (!checkTransform(((Component)__instance).gameObject.transform, (float)Math.PI / 6f))
				{
					__result = false;
				}
			}
		}

		[HarmonyPatch(typeof(CraftingStation), "CheckUsable")]
		public class CraftingStation_CheckUsablePatch
		{
			public static void Postfix(CraftingStation __instance, Player player, bool showMessage, ref bool __result)
			{
				if (!checkTransform(((Component)__instance).gameObject.transform, (float)Math.PI / 6f))
				{
					if (showMessage)
					{
						((Character)player).Message((MessageType)2, "Crafting station is not at a suitable orientation", 0, (Sprite)null);
					}
					__result = false;
				}
			}
		}

		[HarmonyPatch(typeof(CraftingStation), "HaveBuildStationInRange")]
		public class CraftingStation_BuildStationInRangePatch
		{
			public static bool Prefix(string name, Vector3 point, ref CraftingStation __result)
			{
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				__result = null;
				foreach (CraftingStation allStation in CraftingStation.m_allStations)
				{
					if (!(allStation.m_name != name))
					{
						float stationBuildRange = allStation.GetStationBuildRange();
						point.y = ((Component)allStation).transform.position.y;
						if (Vector3.Distance(((Component)allStation).transform.position, point) < stationBuildRange && checkTransform(((Component)allStation).transform, (float)Math.PI / 6f))
						{
							__result = allStation;
						}
					}
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(StationExtension), "FindExtensions")]
		public class StationExtension_FindExtensionsPatch
		{
			public static void Postfix(CraftingStation station, List<StationExtension> extensions)
			{
				extensions.RemoveAll((StationExtension e) => !checkTransform(((Component)e).gameObject.transform, (float)Math.PI / 6f));
			}
		}

		[HarmonyPatch(typeof(Beehive), "UpdateBees")]
		public class Beehive_UpdatePatch
		{
			public static bool Prefix(Beehive __instance)
			{
				if (!checkTransform(((Component)__instance).gameObject.transform, (float)Math.PI / 4f))
				{
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Beehive), "Interact")]
		public class Beehive_InteractPatch
		{
			public static bool Prefix(Beehive __instance, Humanoid character)
			{
				if (!checkTransform(((Component)__instance).gameObject.transform, (float)Math.PI / 4f))
				{
					((Character)character).Message((MessageType)2, "The bees are disoriented", 0, (Sprite)null);
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Beehive), "RPC_Extract")]
		public class Beehive_ExtractPatch
		{
			public static bool Prefix(Beehive __instance)
			{
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: 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_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0085: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: 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)
				int honeyLevel = __instance.GetHoneyLevel();
				Vector3 val = __instance.m_spawnPoint.position - ((Component)__instance).gameObject.transform.up * 2.4f;
				if (honeyLevel > 0)
				{
					__instance.m_spawnEffect.Create(val, Quaternion.identity, (Transform)null, 1f, -1);
					for (int i = 0; i < honeyLevel; i++)
					{
						Vector2 val2 = Random.insideUnitCircle * 0.5f;
						Vector3 val3 = val + new Vector3(val2.x, -0.25f * (float)i, val2.y);
						ItemDrop component = ((Component)Object.Instantiate<ItemDrop>(__instance.m_honeyItem, val3, Quaternion.identity)).GetComponent<ItemDrop>();
						if (component != null)
						{
							component.SetStack(Game.instance.ScaleDrops(__instance.m_honeyItem.m_itemData, 1));
						}
					}
					__instance.ResetLevel();
				}
				return false;
			}
		}

		private const float maxAngleRadsGeneral = (float)Math.PI / 4f;

		private const float maxAngleRadsCrafting = (float)Math.PI / 6f;

		private const float maxAngleRadsBed = (float)Math.PI / 6f;

		private static bool checkTransform(Transform t, float thresholdRads)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return Mathf.Acos(t.up.y) < thresholdRads;
		}
	}
	public class PatreonPortal : MonoBehaviour
	{
		public static string patreonPortalPrefabName = "PatreonPortal";

		public static string patreonActivateFXName = "vfx_GodExplosion";

		public static Vector3 patreonSkin = new Vector3(0f, 1f, 1f) * 6f;

		public static string patreonKey = "tyrenheim_patreon_skin";

		public static string patreonMessage = "A powerful energy causes your skin to shift and tingle";

		public static GameObject patreonPortalPrefab;

		public static GameObject patreonFXPrefab;

		public static void SetupAssets()
		{
			patreonPortalPrefab = ZNetScene.instance.GetPrefab(patreonPortalPrefabName);
			patreonFXPrefab = ZNetScene.instance.GetPrefab(patreonActivateFXName);
			Transform val = patreonPortalPrefab.transform.Find("trigger");
			if ((Object)(object)val != (Object)null)
			{
				((Component)val).gameObject.AddComponent<PatreonPortal>();
			}
			else
			{
				Debug.Log((object)("Failed to add PatreonPortal component to object " + ((Object)val).name));
			}
		}

		private static void SetPatreon(Player p)
		{
			p.m_uniques.Add(patreonKey);
		}

		private static bool HasPatreonSkin(Player p)
		{
			return p.m_uniques.Contains(patreonKey);
		}

		public void Awake()
		{
		}

		private void OnTriggerEnter(Collider collider)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			Player component = ((Component)collider).GetComponent<Player>();
			if ((Object)(object)component != (Object)null && (Object)(object)Player.m_localPlayer == (Object)(object)component && !HasPatreonSkin(component))
			{
				component.SetSkinColor(patreonSkin);
				SetPatreon(component);
				Object.Instantiate<GameObject>(patreonFXPrefab, ((Component)component).transform.position, ((Component)component).transform.rotation);
				((Character)component).Message((MessageType)2, patreonMessage, 0, (Sprite)null);
			}
		}
	}
	public class PlayerSummon
	{
		[HarmonyPatch(typeof(Terminal), "InitTerminal")]
		public static class Terminal_Patch
		{
			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static ConsoleEvent <>9__0_0;

				public static ConsoleEvent <>9__0_1;

				internal void <Postfix>b__0_0(ConsoleEventArgs args)
				{
					SummonCommand(args.Args);
				}

				internal void <Postfix>b__0_1(ConsoleEventArgs args)
				{
					DismissCommand(args.Args);
				}
			}

			public static void Postfix()
			{
				//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
				object obj = <>c.<>9__0_0;
				if (obj == null)
				{
					ConsoleEvent val = delegate(ConsoleEventArgs args)
					{
						SummonCommand(args.Args);
					};
					<>c.<>9__0_0 = val;
					obj = (object)val;
				}
				new ConsoleCommand("summon", "", (ConsoleEvent)obj, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				object obj2 = <>c.<>9__0_1;
				if (obj2 == null)
				{
					ConsoleEvent val2 = delegate(ConsoleEventArgs args)
					{
						DismissCommand(args.Args);
					};
					<>c.<>9__0_1 = val2;
					obj2 = (object)val2;
				}
				new ConsoleCommand("dismiss", "", (ConsoleEvent)obj2, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			}
		}

		public static Dictionary<string, Vector3> returnLocations = new Dictionary<string, Vector3>();

		public static void RPC_RequestDismiss(long sender, string target)
		{
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			if (!ZNet.instance.IsServer())
			{
				return;
			}
			ZNetPeer peer = ZNet.instance.GetPeer(sender);
			if (!Mod.IsAdminRPC(peer))
			{
				ZNet.instance.RemotePrint(peer.m_rpc, "You are not admin");
				return;
			}
			ZNetPeer val = null;
			foreach (ZNetPeer peer2 in ZNet.instance.m_peers)
			{
				if (peer2.IsReady() && peer2.m_playerName.ToLower() == target.ToLower())
				{
					val = peer2;
					break;
				}
			}
			if (val == null)
			{
				ZNet.instance.RemotePrint(peer.m_rpc, "Could not find player: " + target);
				return;
			}
			if (val == peer)
			{
				ZNet.instance.RemotePrint(peer.m_rpc, "Don't be silly, now");
				return;
			}
			if (!returnLocations.ContainsKey(val.m_playerName))
			{
				ZNet.instance.RemotePrint(peer.m_rpc, "No return location found for " + val.m_playerName);
				return;
			}
			ZRoutedRpc.instance.InvokeRoutedRPC(val.m_uid, "BeDismissed", new object[1] { returnLocations[val.m_playerName] });
			returnLocations.Remove(val.m_playerName);
		}

		public static void RPC_RequestSummon(long sender, string target, Vector3 destination)
		{
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			if (!ZNet.instance.IsServer())
			{
				return;
			}
			ZNetPeer peer = ZNet.instance.GetPeer(sender);
			if (!Mod.IsAdminRPC(peer))
			{
				ZNet.instance.RemotePrint(peer?.m_rpc, "You are not admin");
				return;
			}
			ZNetPeer val = null;
			foreach (ZNetPeer peer2 in ZNet.instance.m_peers)
			{
				if (peer2.IsReady() && peer2.m_playerName.ToLower() == target.ToLower())
				{
					val = peer2;
					break;
				}
			}
			if (val == null)
			{
				ZNet.instance.RemotePrint(peer?.m_rpc, "Could not find player: " + target);
				return;
			}
			if (val == peer)
			{
				ZNet.instance.RemotePrint(peer.m_rpc, "Ah, you lonely soul");
				return;
			}
			returnLocations[val.m_playerName] = ZDOMan.instance.GetZDO(val.m_characterID).m_position;
			ZNet.instance.RemotePrint(peer?.m_rpc, "Summoning Player: " + val.m_playerName);
			ZRoutedRpc.instance.InvokeRoutedRPC(val.m_uid, "BeSummoned", new object[1] { destination });
		}

		private static IEnumerator DelayedTeleport(Player p, Vector3 pos, float delay, string message)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			MessageHud.instance.ShowBiomeFoundMsg(message, true);
			Object.Instantiate<GameObject>(ZNetScene.instance.GetPrefab("fx_shaman_protect"), ((Component)p).transform.position, ((Component)p).transform.rotation);
			yield return (object)new WaitForSeconds(delay);
			((Character)p).AttachStop();
			((Character)p).TeleportTo(pos, Quaternion.identity, true);
			((Character)p).m_lastGroundTouch = 0f;
		}

		public static void RPC_BeSummoned(long sender, Vector3 destination)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)$"Player summoned to {destination}");
			((MonoBehaviour)Player.m_localPlayer).StartCoroutine(DelayedTeleport(Player.m_localPlayer, destination, 0f, "You are being summoned by the Gods"));
		}

		public static void RPC_BeDismissed(long sender, Vector3 destination)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)$"Player dismissed to {destination}");
			((MonoBehaviour)Player.m_localPlayer).StartCoroutine(DelayedTeleport(Player.m_localPlayer, destination, 3f, "The Gods dismiss you"));
		}

		public static void DismissCommand(string[] args)
		{
			string text = string.Join(" ", new ArraySegment<string>(args, 1, args.Length - 1));
			ZRoutedRpc.instance.InvokeRoutedRPC("RequestDismiss", new object[1] { text });
		}

		public static void SummonCommand(string[] args)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			string text = string.Join(" ", new ArraySegment<string>(args, 1, args.Length - 1));
			ZRoutedRpc.instance.InvokeRoutedRPC("RequestSummon", new object[2]
			{
				text,
				((Component)Player.m_localPlayer).transform.position
			});
		}

		public static void RegisterRPC()
		{
			ZRoutedRpc.instance.Register<string, Vector3>("RequestSummon", (Action<long, string, Vector3>)RPC_RequestSummon);
			ZRoutedRpc.instance.Register<string>("RequestDismiss", (Action<long, string>)RPC_RequestDismiss);
			ZRoutedRpc.instance.Register<Vector3>("BeSummoned", (Action<long, Vector3>)RPC_BeSummoned);
			ZRoutedRpc.instance.Register<Vector3>("BeDismissed", (Action<long, Vector3>)RPC_BeDismissed);
		}
	}
	[HarmonyPatch(typeof(Game), "FindRandomUnconnectedPortal")]
	public class UnconnectedPortalsPatch
	{
		public static bool Prefix(Game __instance, string tag, ref ZDO __result)
		{
			__result = null;
			return tag != "";
		}
	}
	[HarmonyPatch(typeof(TeleportWorld), "RPC_SetTag")]
	public class TeleportWorldPatch
	{
		public static bool Prefix(TeleportWorld __instance, string tag)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.m_nview.IsValid() && __instance.m_nview.IsOwner() && !(__instance.GetText() == tag))
			{
				__instance.m_nview.GetZDO().Set("target", ZDOID.None);
			}
			return true;
		}
	}
	public static class ProcreationReplacements
	{
		public static int SS_GetNrOfInstancesXZ(GameObject prefab, Vector3 center, float maxRange, bool eventCreaturesOnly = false, bool procreationOnly = false)
		{
			//IL_00fb: 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_0056: 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)
			string text = ((Object)prefab).name + "(Clone)";
			if ((Object)(object)prefab.GetComponent<BaseAI>() != (Object)null)
			{
				List<BaseAI> baseAIInstances = BaseAI.BaseAIInstances;
				int num = 0;
				{
					foreach (BaseAI item in baseAIInstances)
					{
						if (((Object)((Component)item).gameObject).name != text || (maxRange > 0f && Utils.DistanceXZ(center, ((Component)item).transform.position) > maxRange))
						{
							continue;
						}
						if (eventCreaturesOnly)
						{
							MonsterAI val = (MonsterAI)(object)((item is MonsterAI) ? item : null);
							if (Object.op_Implicit((Object)(object)val) && !val.IsEventCreature())
							{
								continue;
							}
						}
						if (procreationOnly)
						{
							Procreation component = ((Component)item).GetComponent<Procreation>();
							if (Object.op_Implicit((Object)(object)component) && !component.ReadyForProcreation())
							{
								continue;
							}
						}
						num++;
					}
					return num;
				}
			}
			GameObject[] array = GameObject.FindGameObjectsWithTag("spawned");
			int num2 = 0;
			GameObject[] array2 = array;
			foreach (GameObject val2 in array2)
			{
				if (((Object)val2).name.StartsWith(text) && (!(maxRange > 0f) || !(Vector3.Distance(center, val2.transform.position) > maxRange)))
				{
					num2++;
				}
			}
			return num2;
		}

		public static void ProcreateReplace(Procreation __instance)
		{
			//IL_009d: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			if (!__instance.m_nview.IsValid() || !__instance.m_nview.IsOwner() || !__instance.m_character.IsTamed())
			{
				return;
			}
			if ((Object)(object)__instance.m_offspringPrefab == (Object)null)
			{
				string prefabName = Utils.GetPrefabName(__instance.m_offspring);
				__instance.m_offspringPrefab = ZNetScene.instance.GetPrefab(prefabName);
				int prefab = __instance.m_nview.GetZDO().GetPrefab();
				__instance.m_myPrefab = ZNetScene.instance.GetPrefab(prefab);
			}
			if (__instance.IsPregnant())
			{
				if (__instance.IsDue())
				{
					__instance.ResetPregnancy();
					GameObject val = Object.Instantiate<GameObject>(__instance.m_offspringPrefab, ((Component)__instance).transform.position - ((Component)__instance).transform.forward * __instance.m_spawnOffset, Quaternion.LookRotation(-((Component)__instance).transform.forward, Vector3.up));
					Character component = val.GetComponent<Character>();
					if (Object.op_Implicit((Object)(object)component))
					{
						component.SetTamed(__instance.m_character.IsTamed());
						component.SetLevel(Mathf.Max(__instance.m_minOffspringLevel, __instance.m_character.GetLevel()));
					}
					__instance.m_birthEffects.Create(val.transform.position, Quaternion.identity, (Transform)null, 1f, -1);
				}
			}
			else
			{
				if (Random.value <= __instance.m_pregnancyChance || __instance.m_baseAI.IsAlerted() || __instance.m_tameable.IsHungry())
				{
					return;
				}
				int num = SS_GetNrOfInstancesXZ(__instance.m_myPrefab, ((Component)__instance).transform.position, __instance.m_totalCheckRange);
				int num2 = SS_GetNrOfInstancesXZ(__instance.m_offspringPrefab, ((Component)__instance).transform.position, __instance.m_totalCheckRange);
				if (num + num2 < __instance.m_maxCreatures && SpawnSystem.GetNrOfInstances(__instance.m_myPrefab, ((Component)__instance).transform.position, __instance.m_partnerCheckRange, false, true) >= 2)
				{
					__instance.m_loveEffects.Create(((Component)__instance).transform.position, ((Component)__instance).transform.rotation, (Transform)null, 1f, -1);
					int @int = __instance.m_nview.GetZDO().GetInt("lovePoints", 0);
					@int++;
					__instance.m_nview.GetZDO().Set("lovePoints", @int);
					if (@int >= __instance.m_requiredLovePoints)
					{
						__instance.m_nview.GetZDO().Set("lovePoints", 0);
						__instance.MakePregnant();
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(Procreation), "Procreate")]
	public class ProcreationPatch
	{
		public static bool Prefix(Procreation __instance)
		{
			ProcreationReplacements.ProcreateReplace(__instance);
			return false;
		}
	}
	public class Messages
	{
		private static Dictionary<string, TyrRaven.TutorialText> buildPieceTutorials = new Dictionary<string, TyrRaven.TutorialText>();

		public static List<Triggers.LocationBasedMessage> locationBasedMessages = new List<Triggers.LocationBasedMessage>();

		public static HashSet<string> huginBlockKeys = new HashSet<string>();

		public static TyrRaven.TutorialText welcomeText = new TyrRaven.TutorialText("Tyrenheim_Welcome", "Welcome to Tyrenheim", "Hail brave wanderer, and welcome to Tyrenheim!\nThis realm is reborn, washed clean by the great waters and winds - however, once again dark threats stir beyond the veil, and threaten this realm. Mighty Tyr beseeches you to venture forth into this realm to contain his great foes, and turn the land and its fruits to your needs and desires.\n\nI am <color=white>Askia</color>, confidante and herald of the Allfather Odin - tasked with watching and helping to guide your efforts in your onward journey, along with my lesser companion Hugin.");

		public static TyrRaven.TutorialText sacrificialStones = new TyrRaven.TutorialText("Tyrenheim_Sacrificial_Stones", "Forsaken Powers", "The dark magic of the foes you seek can be harnessed by attuning to their sacrificial monoliths. However, Odin has cast these great stones out amidst the world, hidden from all but the bravest of souls.\nBe wary, as one needs to bear witness to the death of one of their incarnations to attain their power.");

		public static TyrRaven.TutorialText nonOwnedTombstone = new TyrRaven.TutorialText("Tyrenheim_Unowned_Tombstone", "Grave Consequences", "Should a fellow Viking fall, you should leave their belongings in place as a tribute to their adventure - unless they have sought your aid.\n\nViolating the body of another will not be tolerated. The Gods are watching.");

		public static TyrRaven.TutorialText notWorthy = new TyrRaven.TutorialText("Tyrenheim_Not_Worthy", "A Worthy Vessel", "The powers of these dark spirits can only be claimed by those who have defeated their incarnation. Seek them out, and rend them from this land.");

		public static TyrRaven.TutorialText wardCryptProximity = new TyrRaven.TutorialText("Tyrenheim_Ward_Crypt", "Undead Interference", "Careful wanderer - a dark force in a nearby crypt is causing undead to rise.\n\nWhatever twisted energies emanate from within are causing nearby wardstones to shatter.");

		public static TyrRaven.TutorialText wardCaveProximity = wardCryptProximity;

		public static TyrRaven.TutorialText wardBossProximity = new TyrRaven.TutorialText("Tyrenheim_Ward_Boss", "Planar Disjunction", "I sense a powerful artifact nearby, capable of channelling one of the great, dark spirits.\n\nThe ethereal fury spilling through the veil is causing nearby wardstones to shatter!");

		public TyrRaven.TutorialText reachTheGods = new TyrRaven.TutorialText("Tyrenheim_Reach_Gods", "Call through the Veil", "");

		public static void loadBuildPieceTutorials()
		{
		}

		public static void loadLocationTutorials()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			locationBasedMessages.Add(new Triggers.LocationBasedMessage(new Vector3(126f, 33f, 1f), 15f, welcomeText));
			locationBasedMessages.Add(new Triggers.LocationBasedMessage(new Vector3(126f, 33f, 1f), 15f, sacrificialStones));
		}

		public static void loadHuginBlocks()
		{
			huginBlockKeys.Add("temple1");
			huginBlockKeys.Add("temple2");
			huginBlockKeys.Add("temple4");
		}
	}
	public static class TyrRaven
	{
		public class TutorialText
		{
			public string m_tutorialKey;

			public string m_topic;

			public string m_text;

			public TutorialText(string key, string topic, string text)
			{
				m_tutorialKey = key;
				m_topic = topic;
				m_text = text;
			}
		}

		public static Raven r = null;

		public static GameObject landOn = null;

		private static List<RavenText> messageQueue = new List<RavenText>();

		public static GameObject s_askiaPrefab;

		public static void SetupAssets()
		{
			foreach (GameObject allPrefab in Assets.allPrefabs)
			{
				if ((Object)(object)allPrefab.GetComponent<Raven>() != (Object)null)
				{
					s_askiaPrefab = allPrefab;
					CreateAskia();
				}
			}
		}

		public static void CreateAskia()
		{
			//IL_0014: 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)
			r = Object.Instantiate<GameObject>(s_askiaPrefab, new Vector3(0f, 0f, 0f), Quaternion.identity).GetComponent<Raven>();
			if ((Object)(object)r != (Object)null)
			{
				SetupRaven(r);
			}
		}

		private static void SetupRaven(Raven raven)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			raven.m_name = "Askia";
			raven.m_spawnDistance = 10f;
			raven.m_textCullDistance = 15f;
			((Component)raven).gameObject.transform.localScale = new Vector3(3f, 2.6f, 3.6f);
			r.m_randomTextsImportant.Clear();
			r.m_randomTextsImportant.Add("Wanderer, I would speak with you!");
			r.m_randomTextsImportant.Add("Wanderer, a moment, please!");
		}

		public static RavenText GetText()
		{
			if (r.m_hasTalked)
			{
				messageQueue.RemoveAll((RavenText txt) => txt == r.m_currentText);
			}
			messageQueue.RemoveAll((RavenText txt) => Player.m_localPlayer.HaveSeenTutorial(txt.m_key));
			if (messageQueue.Count == 0)
			{
				return null;
			}
			return messageQueue[0];
		}

		public static void Message(TutorialText text)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			if (string.IsNullOrEmpty(text.m_tutorialKey) || !messageQueue.Exists((RavenText t) => t.m_key == text.m_tutorialKey))
			{
				RavenText val = new RavenText();
				val.m_static = false;
				val.m_munin = true;
				val.m_key = text.m_tutorialKey;
				val.m_topic = text.m_topic;
				val.m_text = text.m_text;
				messageQueue.Add(val);
			}
		}
	}
	[HarmonyPatch(typeof(Raven), "Awake")]
	internal static class Raven_Awake_Patch
	{
		private static bool Prefix(Raven __instance)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.m_name == TyrRaven.s_askiaPrefab.GetComponent<Raven>().m_name)
			{
				((Component)__instance).transform.position = new Vector3(0f, 100000f, 0f);
				__instance.m_animator = __instance.m_visual.GetComponentInChildren<Animator>();
				__instance.m_collider = ((Component)__instance).gameObject.GetComponent<Collider>();
				((MonoBehaviour)__instance).InvokeRepeating("IdleEffect", Random.Range(__instance.m_idleEffectIntervalMin, __instance.m_idleEffectIntervalMax), Random.Range(__instance.m_idleEffectIntervalMin, __instance.m_idleEffectIntervalMax));
				((MonoBehaviour)__instance).InvokeRepeating("CheckSpawn", 1f, 1f);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Raven), "CheckSpawn")]
	internal static class Raven_CheckSpawn_Patch
	{
		private static bool Prefix(Raven __instance)
		{
			if ((Object)(object)__instance == (Object)(object)TyrRaven.r)
			{
				Triggers.CheckLocationTriggers();
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Raven), "GetBestText")]
	internal static class Raven_GetBestText_Patch
	{
		private static bool Prefix(Raven __instance, ref RavenText __result)
		{
			if ((Object)(object)__instance == (Object)(object)TyrRaven.r)
			{
				__result = TyrRaven.GetText();
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Raven), "FindSpawnPoint")]
	internal static class Raven_FindSpawnPoint_Patch
	{
		private static bool Prefix(Raven __instance, ref bool __result, ref Vector3 point, ref GameObject landOn)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)(object)TyrRaven.r)
			{
				float num = 5000f;
				Vector3 position = ((Component)Player.m_localPlayer).transform.position;
				Vector3 forward = ((Component)Utils.GetMainCamera()).transform.forward;
				forward.y = 0f;
				((Vector3)(ref forward)).Normalize();
				point = new Vector3(0f, -999f, 0f);
				landOn = null;
				bool flag = false;
				float num2 = default(float);
				Vector3 val3 = default(Vector3);
				GameObject val4 = default(GameObject);
				for (int i = 0; i < 20; i++)
				{
					Vector3 val = Quaternion.Euler(0f, (float)Random.Range(-30, 30), 0f) * forward;
					Vector3 val2 = position + val * Random.Range(__instance.m_spawnDistance - 5f, __instance.m_spawnDistance);
					if (ZoneSystem.instance.GetSolidHeight(val2, ref num2, ref val3, ref val4) && num2 > ZoneSystem.instance.m_waterLevel && num2 > point.y && num2 < num && val3.y > 0.5f && Mathf.Abs(num2 - position.y) < 2f)
					{
						val2.y = num2;
						point = val2;
						landOn = val4;
						flag = true;
					}
				}
				__result = flag;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Raven), "RegisterStaticText")]
	internal static class Raven_RegisterStaticText_Patch
	{
		private static bool Prefix(RavenText text)
		{
			if (Messages.huginBlockKeys.Contains(text.m_key))
			{
				return false;
			}
			return true;
		}
	}
	public class ShipTweaks
	{
		private static List<string> nonAshlandsReadyShips = new List<string>
		{
			"CargoCaravel", "CargoShipPlus", "BigCargoShipPlus", "HugeCargoShip", "FastShipSkuldelev", "Skuldelev", "RowingCanoe", "DoubleRowingCanoe", "GoblinShip", "LittleBoat",
			"MercantShip", "WarShip", "HerculeShip", "TaurusWarShip"
		};

		public static void ZNS_Init(ZNetScene instance)
		{
			foreach (string nonAshlandsReadyShip in nonAshlandsReadyShips)
			{
				GameObject prefab = ZNetScene.instance.GetPrefab(nonAshlandsReadyShip);
				if (!((Object)(object)prefab == (Object)null) && !((Object)(object)prefab.GetComponent<Ship>() == (Object)null))
				{
					prefab.GetComponent<Ship>().m_ashlandsReady = false;
				}
			}
		}
	}
	public class ShipMod
	{
		public static ConfigEntry<float> _shipDamageInterval;

		public static ConfigEntry<float> _shipDamage;

		public static ConfigEntry<float> _shipMinDamageForce;

		public static void SetupConfig(Mod instance)
		{
			_shipDamageInterval = instance.SyncedConfig("ShipDamage", "Ship Damage Min Interval (secs)", 2f, "Minimum time interval between ship damage occurrences due to water");
			_shipDamage = instance.SyncedConfig("ShipDamage", "Ship Damage", 10f, "Damage applied to ships from water forces");
			_shipMinDamageForce = instance.SyncedConfig("ShipDamage", "Ship Damage Min Force", 2.5f, "Minimum water force required before damage is applied");
		}
	}
	[HarmonyPatch(typeof(ShipControlls), "RPC_RequestControl")]
	public class ShipControlsPatch
	{
		public static bool Prefix(ShipControlls __instance)
		{
			if ((Object)(object)__instance.m_ship != (Object)null)
			{
				__instance.m_ship.m_minWaterImpactInterval = Math.Max(0.1f, ShipMod._shipDamageInterval.Value);
				__instance.m_ship.m_waterImpactDamage = Math.Max(0f, ShipMod._shipDamage.Value);
				__instance.m_ship.m_minWaterImpactForce = Math.Max(0f, ShipMod._shipMinDamageForce.Value);
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Ship), "TakeAshlandsDamage")]
	public class AshlandsDamagePatch
	{
		public static bool Prefix(Ship __instance, float dt)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Expected O, but got Unknown
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.m_ashlandsReady)
			{
				return false;
			}
			float ashlandsOceanGradient = WorldGenerator.GetAshlandsOceanGradient(((Component)__instance).gameObject.transform.position);
			if (ashlandsOceanGradient < 0f)
			{
				if (Object.op_Implicit((Object)(object)__instance.m_ashdamageEffects))
				{
					__instance.m_ashdamageEffects.SetActive(false);
					foreach (AudioSource item in __instance.m_ashlandsFxAudio)
					{
						item.Stop();
					}
				}
				return false;
			}
			if (Object.op_Implicit((Object)(object)__instance.m_ashdamageEffects))
			{
				__instance.m_ashdamageEffects.SetActive(true);
			}
			if (__instance.m_ashDamageMsgTimer <= 0f && Object.op_Implicit((Object)(object)ZoneSystem.instance) && Object.op_Implicit((Object)(object)Player.m_localPlayer))
			{
				ZoneSystem.instance.SetGlobalKey((GlobalKeys)41);
				__instance.m_ashDamageMsgTimer = __instance.m_ashDamageMsgTime;
			}
			else
			{
				__instance.m_ashDamageMsgTimer -= Time.fixedDeltaTime;
			}
			__instance.m_ashlandsDmgTimer += dt;
			if (!((double)__instance.m_ashlandsDmgTimer <= 1.0))
			{
				__instance.m_ashlandsDmgTimer = 0f;
				ashlandsOceanGradient = Mathf.Clamp(ashlandsOceanGradient, 0f, 3f);
				HitData val = new HitData();
				val.m_damage.m_blunt = Mathf.Floor(Mathf.Lerp(1f, 30f, ashlandsOceanGradient));
				val.m_hitType = (HitType)21;
				val.m_point = ((Component)__instance).gameObject.transform.position;
				val.m_dir = Vector3.up;
				__instance.m_destructible.Damage(val);
			}
			return false;
		}
	}
	public class MobTweaks
	{
		public static void ZNS_Init(ZNetScene instance)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = ZNetScene.instance.GetPrefab("Surtling");
			prefab.GetComponent<Character>().m_tolerateWater = true;
			prefab.GetComponent<BaseAI>().m_avoidWater = false;
			ZNetScene.instance.GetPrefab("BlobTar").GetComponent<Character>().m_faction = (Faction)7;
		}
	}
	public class TagItems
	{
		[HarmonyPatch(typeof(Player), "OnInventoryChanged")]
		public class PlayerInventoryPatch
		{
			public static void Postfix(Player __instance)
			{
				bool flag = false;
				foreach (ItemData item in ((Humanoid)__instance).m_inventory.m_inventory)
				{
					if (item.m_shared.m_name.Contains("Quest") && ((Character)__instance).IsPlayer() && item.m_crafterID == 0L)
					{
						item.m_crafterName = __instance.GetPlayerName();
						item.m_crafterID = __instance.GetPlayerID();
						flag = true;
					}
				}
				if (flag)
				{
					((Humanoid)__instance).m_inventory.Changed();
				}
			}
		}
	}
	public class TraderTweaks
	{
		public static string traderPrefabName = "Haldor";

		public static Dictionary<string, int> priceRemap = new Dictionary<string, int> { { "Thunderstone", 500 } };

		public static void ZNS_Init(ZNetScene instance)
		{
			GameObject prefab = instance.GetPrefab(traderPrefabName);
			Trader val = ((prefab != null) ? prefab.GetComponent<Trader>() : null);
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			foreach (KeyValuePair<string, int> item in priceRemap)
			{
				GameObject prefab2 = instance.GetPrefab(item.Key);
				ItemDrop val2 = ((prefab2 != null) ? prefab2.GetComponent<ItemDrop>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					dictionary[val2.m_itemData.m_shared.m_name] = item.Value;
				}
			}
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			foreach (TradeItem item2 in val.m_items)
			{
				item2.m_price = (dictionary.TryGetValue(item2.m_prefab.m_itemData.m_shared.m_name, out var value) ? value : item2.m_price);
			}
		}
	}
	public static class Triggers
	{
		public class LocationBasedMessage
		{
			public Vector3 location;

			public float radius;

			public TyrRaven.TutorialText text;

			public LocationBasedMessage(Vector3 loc, float r, TyrRaven.TutorialText txt)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				location = loc;
				radius = r;
				text = txt;
			}
		}

		[HarmonyPatch(typeof(TombStone), "Interact")]
		private static class TombStone_Interact_Patch
		{
			private static void Postfix(TombStone __instance, Humanoid character)
			{
				if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && !__instance.IsOwner())
				{
					Graverobbing.TombstoneInteract(Player.m_localPlayer, __instance);
					TyrRaven.Message(Messages.nonOwnedTombstone);
				}
			}
		}

		public static Incinerator incineratorPrefab;

		public static GameObject lightningPrefab;

		public static void CheckLocationTriggers()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			foreach (LocationBasedMessage locationBasedMessage in Messages.locationBasedMessages)
			{
				if (Vector3.Distance(locationBasedMessage.location, ((Component)localPlayer).transform.position) < locationBasedMessage.radius)
				{
					TyrRaven.Message(locationBasedMessage.text);
				}
			}
		}
	}
	[BepInPlugin("tyrenheim.tyrenheimcustom", "Tyrenheim_Raven", "0.18.1")]
	public class Mod : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(ZNet), "Awake")]
		public static class ZNetAwakePatch
		{
			public static void Postfix(ZNet __instance)
			{
				Ravencast.RegisterRPC();
				Graverobbing.RegisterRPC();
				PlayerSummon.RegisterRPC();
				BossWorthiness.RegisterRPC();
				DeathMessaging.RegisterRPC();
			}
		}

		private const string AuthorName = "JoeOsborne";

		private const string ModName = "Tyrenheim_Raven";

		private const string ModVer = "0.18.1";

		private const string ModGuid = "tyrenheim.tyrenheimcustom";

		private readonly ConfigSync configSync = new ConfigSync("Tyrenheim_Raven")
		{
			DisplayName = "Tyrenheim_Raven",
			CurrentVersion = "0.18.1",
			MinimumRequiredVersion = "0.18.1"
		};

		public static ConfigEntry<bool> _configLocked;

		public static Harmony _harmony;

		private void Awake()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			ShipMod.SetupConfig(this);
			BuildExclusion.SetupConfig(this);
			_configLocked = SyncedConfig("General", "Force Server Config", defaultVal: true, "Force Server Config");
			configSync.AddLockingConfigEntry<bool>(_configLocked);
			SetupWatcher();
			_harmony = new Harmony("tyrenheim.tyrenheimcustom");
			_harmony.PatchAll();
			Messages.loadBuildPieceTutorials();
			Messages.loadLocationTutorials();
			Messages.loadHuginBlocks();
		}

		private void SetupWatcher()
		{
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath);
			fileSystemWatcher.Changed += ReadConfigValues;
			fileSystemWatcher.Created += ReadConfigValues;
			fileSystemWatcher.Renamed += ReadConfigValues;
			fileSystemWatcher.IncludeSubdirectories = true;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		private void ReadConfigValues(object sender, FileSystemEventArgs e)
		{
			if (File.Exists(((BaseUnityPlugin)this).Config.ConfigFilePath))
			{
				((BaseUnityPlugin)this).Config.Reload();
			}
		}

		public ConfigEntry<T> SyncedConfig<T>(string group, string name, T defaultVal, string desc)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, defaultVal, new ConfigDescription(desc, (AcceptableValueBase)null, Array.Empty<object>()));
			configSync.AddConfigEntry<T>(val).SynchronizedConfig = true;
			return val;
		}

		public static bool IsAdminRPC(ZNetPeer peer)
		{
			if (ZNet.instance.m_adminList != null && peer != null && peer.m_rpc != null && peer.m_rpc.GetSocket() != null && ZNet.instance.m_adminList.Contains(peer.m_rpc.GetSocket().GetHostName()))
			{
				ZNet.instance.RemotePrint(peer.m_rpc, "You are not admin");
				return true;
			}
			return false;
		}
	}
	public static class Ravencast
	{
		[HarmonyPatch(typeof(Terminal), "InitTerminal")]
		public static class Terminal_Patch
		{
			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static ConsoleEvent <>9__0_0;

				public static ConsoleEvent <>9__0_1;

				public static ConsoleEvent <>9__0_2;

				internal void <Postfix>b__0_0(ConsoleEventArgs args)
				{
					RavencastAppend(args.Context, args.Args);
				}

				internal void <Postfix>b__0_1(ConsoleEventArgs args)
				{
					RavencastSend(args.Context, args.Args);
				}

				internal void <Postfix>b__0_2(ConsoleEventArgs args)
				{
					RavencastClear();
				}
			}

			public static void Postfix()
			{
				//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
				object obj = <>c.<>9__0_0;
				if (obj == null)
				{
					ConsoleEvent val = delegate(ConsoleEventArgs args)
					{
						RavencastAppend(args.Context, args.Args);
					};
					<>c.<>9__0_0 = val;
					obj = (object)val;
				}
				new ConsoleCommand("ravencast", "", (ConsoleEvent)obj, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				object obj2 = <>c.<>9__0_1;
				if (obj2 == null)
				{
					ConsoleEvent val2 = delegate(ConsoleEventArgs args)
					{
						RavencastSend(args.Context, args.Args);
					};
					<>c.<>9__0_1 = val2;
					obj2 = (object)val2;
				}
				new ConsoleCommand("ravencast_send", "", (ConsoleEvent)obj2, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				object obj3 = <>c.<>9__0_2;
				if (obj3 == null)
				{
					ConsoleEvent val3 = delegate
					{
						RavencastClear();
					};
					<>c.<>9__0_2 = val3;
					obj3 = (object)val3;
				}
				new ConsoleCommand("ravencast_clear", "", (ConsoleEvent)obj3, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			}
		}

		private static string messageBuffer;

		public static void RPC_RequestRavencast(long sender, string msg)
		{
			if (ZNet.instance.IsServer())
			{
				ZNetPeer peer = ZNet.instance.GetPeer(sender);
				if (!Mod.IsAdminRPC(peer))
				{
					ZNet.instance.RemotePrint(peer?.m_rpc, "You are not admin");
					return;
				}
				Debug.Log((object)("Sending Ravencast: " + msg));
				ZRoutedRpc.instance.InvokeRoutedRPC(ZNetView.Everybody, "ReceiveRavencast", new object[1] { msg });
			}
		}

		public static void RPC_ReceiveRavencast(long sender, string msg)
		{
			if (!ZNet.instance.IsServer() || !ZNet.instance.IsDedicated())
			{
				TyrRaven.Message(new TyrRaven.TutorialText("", "Odin's Herald", "Adventurer! I bring information from the Powers That Be:\n\n <color=yellow>" + msg + "</color>"));
			}
		}

		private static void RavencastAppend(Terminal terminal, string[] args)
		{
			string text = string.Join(" ", new ArraySegment<string>(args, 1, args.Length - 1));
			messageBuffer = messageBuffer + " " + text.Replace("\\n", "\n");
			terminal.AddString($">> Ravencast message length is now {messageBuffer.Length} chars.");
		}

		private static void RavencastClear()
		{
			messageBuffer = "";
		}

		private static void RavencastSend(Terminal terminal, string[] args)
		{
			ZRoutedRpc.instance.InvokeRoutedRPC("RequestRavencast", new object[1] { messageBuffer });
			RavencastClear();
		}

		public static void RegisterRPC()
		{
			ZRoutedRpc.instance.Register<string>("RequestRavencast", (Action<long, string>)RPC_RequestRavencast);
			ZRoutedRpc.instance.Register<string>("ReceiveRavencast", (Action<long, string>)RPC_ReceiveRavencast);
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	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;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[Microsoft.CodeAnalysis.Embedded]
	[CompilerGenerated]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	[Microsoft.CodeAnalysis.Embedded]
	[CompilerGenerated