Decompiled source of Elder Dragons v1.0.0

plugins/ElderDragons.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ElderDragons.Core;
using ElderDragons.Dev;
using ElderDragons.Gameplay;
using ElderDragons.UI;
using ElderDragons.Visual;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_utils")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ElderDragons
{
	public static class Cfg
	{
		public static ConfigEntry<float> MaturingDays;

		public static ConfigEntry<float> ElderScale;

		public static ConfigEntry<float> HealthFactor;

		public static ConfigEntry<float> DamageFactor;

		public static ConfigEntry<bool> CannotDie;

		public static ConfigEntry<bool> ButcherRelease;

		public static ConfigEntry<float> KnockoutSeconds;

		public static ConfigEntry<float> WakeHealth;

		public static ConfigEntry<string> TotemRecipe;

		public static ConfigEntry<string> TotemStation;

		public static ConfigEntry<bool> RecallStaying;

		public static ConfigEntry<bool> GrabPlayers;

		public static ConfigEntry<bool> GrabPlayersNeedsPvP;

		public static ConfigEntry<bool> GrabCreatures;

		public static ConfigEntry<bool> GrabItems;

		public static ConfigEntry<bool> GrabCarts;

		public static ConfigEntry<bool> GrabNeedsElder;

		public static ConfigEntry<bool> PlayersBreakFree;

		public static ConfigEntry<bool> CreatureFallDamage;

		public static ConfigEntry<float> GrabReach;

		public static ConfigEntry<float> MaxCreatureHeight;

		public static ConfigEntry<float> CreatureFallScale;

		public static ConfigEntry<KeyboardShortcut> GrabKey;

		public static ConfigEntry<bool> ShowHints;

		private static ConfigFile _file;

		public const double DaySeconds = 1800.0;

		public static void Bind(ConfigFile cfg)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Expected O, but got Unknown
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Expected O, but got Unknown
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Expected O, but got Unknown
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Expected O, but got Unknown
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Expected O, but got Unknown
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Expected O, but got Unknown
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Expected O, but got Unknown
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Expected O, but got Unknown
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Expected O, but got Unknown
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Expected O, but got Unknown
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Expected O, but got Unknown
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Expected O, but got Unknown
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Expected O, but got Unknown
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Expected O, but got Unknown
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Expected O, but got Unknown
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Expected O, but got Unknown
			//IL_0460: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Expected O, but got Unknown
			//IL_0481: Unknown result type (might be due to invalid IL or missing references)
			_file = cfg;
			ConfigurationManagerAttributes val = new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			};
			MaturingDays = cfg.Bind<float>("1 - Elder", "MaturingDays", 5f, new ConfigDescription("How many in-game days a dragon must live in its last growth stage (the 'Elder' of Elemental Dragons) before it awakens as an Elder Dragon. 5 days are as long as one growth stage of Elemental Dragons. 0 awakens it at once.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), new object[1] { val }));
			ElderScale = cfg.Bind<float>("1 - Elder", "ElderScale", 1.25f, new ConfigDescription("How much bigger an Elder Dragon grows when it awakens, as a factor of its size before.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 2f), new object[1] { val }));
			HealthFactor = cfg.Bind<float>("1 - Elder", "HealthFactor", 1.5f, new ConfigDescription("Maximum health of an Elder Dragon as a factor of its health before.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 5f), new object[1] { val }));
			DamageFactor = cfg.Bind<float>("1 - Elder", "DamageFactor", 1.25f, new ConfigDescription("Damage of an Elder Dragon's attacks as a factor of its damage before.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 5f), new object[1] { val }));
			CannotDie = cfg.Bind<bool>("2 - Protection", "CannotDie", true, new ConfigDescription("An Elder Dragon that loses all its health does not die: it sinks to the ground unconscious and wakes up again.", (AcceptableValueBase)null, new object[1] { val }));
			KnockoutSeconds = cfg.Bind<float>("2 - Protection", "KnockoutSeconds", 120f, new ConfigDescription("How many seconds an Elder Dragon stays unconscious.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 1800f), new object[1] { val }));
			WakeHealth = cfg.Bind<float>("2 - Protection", "WakeHealth", 0.3f, new ConfigDescription("Share of its maximum health an Elder Dragon has when it wakes up.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 1f), new object[1] { val }));
			ButcherRelease = cfg.Bind<bool>("2 - Protection", "ButcherRelease", true, new ConfigDescription("The owner can release an unconscious Elder Dragon with the butcher knife. It dies and leaves its egg, as Elemental Dragons does.", (AcceptableValueBase)null, new object[1] { val }));
			TotemRecipe = cfg.Bind<string>("3 - Totem", "TotemRecipe", "Stone:20,Crystal:4,DragonTear:2", new ConfigDescription("Cost of the Elder Totem, as 'Item:amount,Item:amount'.", (AcceptableValueBase)null, new object[1] { val }));
			TotemStation = cfg.Bind<string>("3 - Totem", "TotemStation", "piece_stonecutter", new ConfigDescription("Crafting station needed nearby to build the Elder Totem (prefab name, empty for none).", (AcceptableValueBase)null, new object[1] { val }));
			RecallStaying = cfg.Bind<bool>("3 - Totem", "RecallStaying", true, new ConfigDescription("The totem also calls Elder Dragons that were told to stay somewhere. Off: only those that follow you.", (AcceptableValueBase)null, new object[1] { val }));
			GrabNeedsElder = cfg.Bind<bool>("4 - Claws", "GrabNeedsElder", true, new ConfigDescription("Only awakened Elder Dragons can grab with their claws. Off: every rideable dragon can.", (AcceptableValueBase)null, new object[1] { val }));
			GrabPlayers = cfg.Bind<bool>("4 - Claws", "GrabPlayers", true, new ConfigDescription("The claws can grab other players.", (AcceptableValueBase)null, new object[1] { val }));
			GrabPlayersNeedsPvP = cfg.Bind<bool>("4 - Claws", "GrabPlayersNeedsPvP", false, new ConfigDescription("Only players who have player-versus-player switched on can be grabbed. Turn this on for public servers, where a dropped player can die of the fall.", (AcceptableValueBase)null, new object[1] { val }));
			PlayersBreakFree = cfg.Bind<bool>("4 - Claws", "PlayersBreakFree", true, new ConfigDescription("A carried player can break free by jumping (and falls).", (AcceptableValueBase)null, new object[1] { val }));
			GrabCreatures = cfg.Bind<bool>("4 - Claws", "GrabCreatures", true, new ConfigDescription("The claws can grab creatures, wild or tame, up to MaxCreatureHeight. Bosses never.", (AcceptableValueBase)null, new object[1] { val }));
			MaxCreatureHeight = cfg.Bind<float>("4 - Claws", "MaxCreatureHeight", 7f, new ConfigDescription("Tallest creature the claws can lift, in metres of its body, for a dragon the size of a Fire Dragon Elder before it awakens (a troll measures 6.6 m, a lox 3.5 m). Grows with the dragon's body: an awakened Fire Elder lifts 1.25 times as much, the Poison one 1.5 times, the Black one 1.9 times.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 20f), new object[1] { val }));
			CreatureFallDamage = cfg.Bind<bool>("4 - Claws", "CreatureFallDamage", true, new ConfigDescription("Creatures dropped from the claws take fall damage like players do (the game gives creatures none).", (AcceptableValueBase)null, new object[1] { val }));
			CreatureFallScale = cfg.Bind<float>("4 - Claws", "CreatureFallScale", 1f, new ConfigDescription("Fall damage of dropped creatures as a share of their maximum health at 20 m and more (vanilla players: 100 damage at 20 m).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), new object[1] { val }));
			GrabItems = cfg.Bind<bool>("4 - Claws", "GrabItems", true, new ConfigDescription("The claws can grab items lying on the ground, a whole pile at once.", (AcceptableValueBase)null, new object[1] { val }));
			GrabCarts = cfg.Bind<bool>("4 - Claws", "GrabCarts", true, new ConfigDescription("The claws can grab carts (with their load) and tree logs.", (AcceptableValueBase)null, new object[1] { val }));
			GrabReach = cfg.Bind<float>("4 - Claws", "GrabReach", 3.5f, new ConfigDescription("How far from the claws something can be grabbed, in metres, for a dragon the size of a Fire Dragon Elder before it awakens. Grows with the dragon's body like the lift height.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), new object[1] { val }));
			GrabKey = cfg.Bind<KeyboardShortcut>("5 - Client", "GrabKey", new KeyboardShortcut((KeyCode)98, Array.Empty<KeyCode>()), "Key to grab with the claws and to let go again while you ride a dragon.");
			ShowHints = cfg.Bind<bool>("5 - Client", "ShowHints", true, "Shows a small hint while you ride an Elder Dragon: what the claws can grab and which key does it.");
		}
	}
	public static class Lang
	{
		private static readonly (string key, string en, string de)[] Texts = new(string, string, string)[34]
		{
			("ed_name_fire", "Elder Fire Dragon", "Elder-Feuerdrache"),
			("ed_name_frost", "Elder Frost Dragon", "Elder-Frostdrache"),
			("ed_name_lightning", "Elder Lightning Dragon", "Elder-Blitzdrache"),
			("ed_name_poison", "Elder Poison Dragon", "Elder-Giftdrache"),
			("ed_name_black", "Elder Black Dragon", "Schwarzer Elder-Drache"),
			("ed_hover_maturing", "Matures into an Elder Dragon: {0} % · {1} days to go", "Reift zum Elder-Drachen: {0} % · noch {1} Tage"),
			("ed_hover_maturing_one", "Matures into an Elder Dragon: {0} % · 1 day to go", "Reift zum Elder-Drachen: {0} % · noch 1 Tag"),
			("ed_hover_maturing_due", "Matures into an Elder Dragon: about to awaken", "Reift zum Elder-Drachen: erwacht bald"),
			("ed_hover_elder", "Elder Dragon · cannot die", "Elder-Drache · kann nicht sterben"),
			("ed_hover_elder_mortal", "Elder Dragon", "Elder-Drache"),
			("ed_hover_ko", "Unconscious · wakes in {0}", "Bewusstlos · erwacht in {0}"),
			("ed_msg_awaken", "{0} awakens", "{0} erwacht"),
			("ed_msg_ko", "{0} has fallen unconscious – it will wake up again", "{0} ist bewusstlos – er wird wieder erwachen"),
			("ed_msg_wake", "{0} is awake again", "{0} ist wieder wach"),
			("ed_ko_noride", "{0} is unconscious", "{0} ist bewusstlos"),
			("ed_release_off", "The butcher knife cannot release an Elder Dragon here", "Das Metzgermesser kann hier keinen Elder-Drachen freigeben"),
			("ed_release_notyours", "Only its owner can release this dragon", "Nur sein Besitzer kann diesen Drachen freigeben"),
			("ed_release_awake", "{0} is awake – only an unconscious Elder Dragon can be released", "{0} ist wach – nur ein bewusstloser Elder-Drache kann freigegeben werden"),
			("ed_released", "You release {0}", "Du gibst {0} frei"),
			("ed_totem", "Elder Totem", "Elder-Totem"),
			("ed_totem_desc", "A stone pillar crowned with Moder's head. Use it to call all your Elder Dragons to it, wherever they are – awake or unconscious.", "Eine Steinsäule, gekrönt von Moders Kopf. Benutze sie, um alle deine Elder-Drachen zu dir zu rufen, wo immer sie sind – wach oder bewusstlos."),
			("ed_totem_call", "Call your Elder Dragons", "Deine Elder-Drachen rufen"),
			("ed_totem_wait", "The totem's call still echoes", "Der Ruf des Totems hallt noch nach"),
			("ed_totem_none", "No Elder Dragon answers your call", "Kein Elder-Drache folgt deinem Ruf"),
			("ed_totem_called", "Your Elder Dragons answer: {0}", "Deine Elder-Drachen folgen dem Ruf: {0}"),
			("ed_totem_called_ridden", "Your Elder Dragons answer: {0} · {1} carry a rider and stay", "Deine Elder-Drachen folgen dem Ruf: {0} · {1} tragen einen Reiter und bleiben"),
			("ed_totem_called_ridden_one", "Your Elder Dragons answer: {0} · 1 carries a rider and stays", "Deine Elder-Drachen folgen dem Ruf: {0} · 1 trägt einen Reiter und bleibt"),
			("ed_claw_grab", "Grab: {0}", "Greifen: {0}"),
			("ed_claw_letgo", "Let go: {0}", "Loslassen: {0}"),
			("ed_claw_none", "Nothing within reach of the claws", "Nichts in Reichweite der Klauen"),
			("ed_claw_nothing", "The claws grasp at nothing", "Die Klauen greifen ins Leere"),
			("ed_claw_slipped", "It slips out of the claws", "Es entgleitet den Klauen"),
			("ed_claw_caught", "{0} has you in its claws", "{0} hält dich in seinen Klauen"),
			("ed_claw_caught_free", "{0} has you in its claws – jump to break free", "{0} hält dich in seinen Klauen – spring, um dich loszureißen")
		};

		public static void Register()
		{
			CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
			(string, string, string)[] texts = Texts;
			for (int i = 0; i < texts.Length; i++)
			{
				(string, string, string) tuple = texts[i];
				string item = tuple.Item1;
				string item2 = tuple.Item2;
				string item3 = tuple.Item3;
				dictionary[item] = item2;
				dictionary2[item] = item3;
			}
			string text = "English";
			localization.AddTranslation(ref text, dictionary);
			text = "German";
			localization.AddTranslation(ref text, dictionary2);
		}

		public static string T(string token, params object[] args)
		{
			string text = ((Localization.instance != null) ? Localization.instance.Localize("$" + token) : token);
			if (args == null || args.Length == 0)
			{
				return text;
			}
			try
			{
				return string.Format(text, args);
			}
			catch (FormatException)
			{
				return text;
			}
		}

		public static string L(string token)
		{
			if (Localization.instance == null)
			{
				return token;
			}
			return Localization.instance.Localize(token);
		}
	}
	public static class Pieces
	{
		[HarmonyPatch(typeof(Game), "Start")]
		private static class ApplyOnWorldStart
		{
			private static void Postfix()
			{
				ApplyConfig();
			}
		}

		public const string TotemPrefab = "piece_eldertotem";

		private const string BasePrefab = "stone_pillar";

		private const string TrophyPrefab = "TrophyDragonQueen";

		private const float CrownWidth = 1.3f;

		public static GameObject Totem { get; private set; }

		public static void Init()
		{
			PrefabManager.OnVanillaPrefabsAvailable += Add;
			SynchronizationManager.OnConfigurationSynchronized += delegate
			{
				ApplyConfig();
			};
			Cfg.TotemRecipe.SettingChanged += delegate
			{
				ApplyConfig();
			};
			Cfg.TotemStation.SettingChanged += delegate
			{
				ApplyConfig();
			};
		}

		public static void ApplyConfig()
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			if ((Object)(object)Totem == (Object)null)
			{
				return;
			}
			try
			{
				Piece component = Totem.GetComponent<Piece>();
				List<Requirement> list = new List<Requirement>();
				foreach (RequirementConfig item in ParseRecipe(Cfg.TotemRecipe.Value))
				{
					GameObject obj = FindPrefab(item.Item);
					ItemDrop val = ((obj != null) ? obj.GetComponent<ItemDrop>() : null);
					if ((Object)(object)val == (Object)null)
					{
						ElderDragonsPlugin.Log.LogWarning((object)("Totem recipe: unknown item '" + item.Item + "'."));
						continue;
					}
					list.Add(new Requirement
					{
						m_resItem = val,
						m_amount = item.Amount,
						m_recover = true
					});
				}
				if (list.Count > 0)
				{
					component.m_resources = list.ToArray();
				}
				string value = Cfg.TotemStation.Value;
				if (string.IsNullOrWhiteSpace(value))
				{
					component.m_craftingStation = null;
					return;
				}
				GameObject obj2 = FindPrefab(value.Trim());
				CraftingStation val2 = ((obj2 != null) ? obj2.GetComponent<CraftingStation>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					component.m_craftingStation = val2;
				}
				else
				{
					ElderDragonsPlugin.Log.LogWarning((object)("Totem station: unknown crafting station '" + value + "'."));
				}
			}
			catch (Exception ex)
			{
				ElderDragonsPlugin.Log.LogWarning((object)("Could not apply the totem recipe: " + ex.Message));
			}
		}

		internal static GameObject FindPrefab(string name)
		{
			if (string.IsNullOrEmpty(name))
			{
				return null;
			}
			GameObject val = null;
			if ((Object)(object)ObjectDB.instance != (Object)null)
			{
				val = ObjectDB.instance.GetItemPrefab(name);
			}
			if ((Object)(object)val == (Object)null && (Object)(object)ZNetScene.instance != (Object)null)
			{
				val = ZNetScene.instance.GetPrefab(name);
			}
			if ((Object)(object)val == (Object)null)
			{
				try
				{
					val = PrefabManager.Instance.GetPrefab(name);
				}
				catch (Exception)
				{
				}
			}
			return val;
		}

		private static void Add()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_004b: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PieceConfig val = new PieceConfig
				{
					Name = "$ed_totem",
					Description = "$ed_totem_desc",
					PieceTable = "Hammer",
					Category = "Misc",
					CraftingStation = (Cfg.TotemStation.Value ?? "")
				};
				foreach (RequirementConfig item in ParseRecipe(Cfg.TotemRecipe.Value))
				{
					val.AddRequirement(item);
				}
				CustomPiece val2 = new CustomPiece("piece_eldertotem", "stone_pillar", val);
				if ((Object)(object)val2.PiecePrefab == (Object)null)
				{
					ElderDragonsPlugin.Log.LogError((object)"Cloning stone_pillar failed; no Elder Totem.");
					return;
				}
				if (string.IsNullOrWhiteSpace(Cfg.TotemStation.Value))
				{
					val2.PiecePrefab.GetComponent<Piece>().m_craftingStation = null;
				}
				Crown(val2.PiecePrefab);
				Sprite val3 = RenderIcon(val2.PiecePrefab, Quaternion.Euler(-14f, 210f, 0f));
				if ((Object)(object)val3 != (Object)null)
				{
					val2.PiecePrefab.GetComponent<Piece>().m_icon = val3;
				}
				PieceManager.Instance.AddPiece(val2);
				Totem = val2.PiecePrefab;
			}
			catch (Exception ex)
			{
				ElderDragonsPlugin.Log.LogError((object)("Could not register the Elder Totem: " + ex));
			}
			finally
			{
				PrefabManager.OnVanillaPrefabsAvailable -= Add;
			}
		}

		private static void Crown(GameObject prefab)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_009a: 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_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			Bounds val = LocalBounds(prefab);
			float num = ((((Bounds)(ref val)).size.y > 0.01f) ? ((Bounds)(ref val)).max.y : 2f);
			GameObject val2 = FindPrefab("TrophyDragonQueen");
			GameObject val3 = (((Object)(object)val2 != (Object)null) ? ItemStand.GetAttachPrefab(val2) : null);
			if ((Object)(object)val3 != (Object)null)
			{
				GameObject val4 = new GameObject("ed_totem_crown");
				val4.transform.SetParent(prefab.transform, false);
				GameObject val5 = Object.Instantiate<GameObject>(val3, val4.transform, false);
				((Object)val5).name = "head";
				val5.transform.localPosition = Vector3.zero;
				val5.transform.localRotation = Quaternion.identity;
				Collider[] componentsInChildren = val5.GetComponentsInChildren<Collider>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
				}
				ParticleSystem[] componentsInChildren2 = val5.GetComponentsInChildren<ParticleSystem>(true);
				for (int i = 0; i < componentsInChildren2.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)((Component)componentsInChildren2[i]).gameObject);
				}
				Bounds val6 = LocalBounds(val4);
				float num2 = Mathf.Max(new float[3]
				{
					((Bounds)(ref val6)).size.x,
					((Bounds)(ref val6)).size.z,
					0.01f
				});
				float num3 = Mathf.Clamp(1.3f / num2, 0.2f, 6f);
				val4.transform.localScale = Vector3.one * num3;
				val4.transform.localPosition = new Vector3(((Bounds)(ref val)).center.x - ((Bounds)(ref val6)).center.x * num3, num - ((Bounds)(ref val6)).min.y * num3 - 0.02f, ((Bounds)(ref val)).center.z - ((Bounds)(ref val6)).center.z * num3);
				SetLayer(val4, prefab.layer);
			}
			else
			{
				ElderDragonsPlugin.Log.LogWarning((object)"Moder's trophy was not found; the totem is a bare pillar.");
			}
			GameObject val7 = new GameObject("rune_light");
			val7.transform.SetParent(prefab.transform, false);
			val7.transform.localPosition = new Vector3(((Bounds)(ref val)).center.x, num * 0.75f, ((Bounds)(ref val)).max.z + 0.35f);
			Light obj = val7.AddComponent<Light>();
			obj.type = (LightType)2;
			obj.color = new Color(1f, 0.55f, 0.2f);
			obj.range = 6f;
			obj.intensity = 0.6f;
			obj.shadows = (LightShadows)0;
			WearNTear component = prefab.GetComponent<WearNTear>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_health = 1500f;
			}
			Piece component2 = prefab.GetComponent<Piece>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.m_noInWater = true;
			}
			prefab.AddComponent<ElderTotem>();
		}

		private static Bounds LocalBounds(GameObject go)
		{
			//IL_0002: 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)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			Bounds result = default(Bounds);
			bool flag = false;
			MeshRenderer[] componentsInChildren = go.GetComponentsInChildren<MeshRenderer>(true);
			Vector3 val2 = default(Vector3);
			foreach (MeshRenderer val in componentsInChildren)
			{
				MeshFilter component = ((Component)val).GetComponent<MeshFilter>();
				if ((Object)(object)component == (Object)null || (Object)(object)component.sharedMesh == (Object)null)
				{
					continue;
				}
				Bounds bounds = component.sharedMesh.bounds;
				for (int j = 0; j < 8; j++)
				{
					((Vector3)(ref val2))..ctor(((j & 1) == 0) ? ((Bounds)(ref bounds)).min.x : ((Bounds)(ref bounds)).max.x, ((j & 2) == 0) ? ((Bounds)(ref bounds)).min.y : ((Bounds)(ref bounds)).max.y, ((j & 4) == 0) ? ((Bounds)(ref bounds)).min.z : ((Bounds)(ref bounds)).max.z);
					Vector3 val3 = go.transform.InverseTransformPoint(((Component)val).transform.TransformPoint(val2));
					if (!flag)
					{
						((Bounds)(ref result))..ctor(val3, Vector3.zero);
						flag = true;
					}
					else
					{
						((Bounds)(ref result)).Encapsulate(val3);
					}
				}
			}
			return result;
		}

		private static void SetLayer(GameObject go, int layer)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			go.layer = layer;
			foreach (Transform item in go.transform)
			{
				SetLayer(((Component)item).gameObject, layer);
			}
		}

		internal static Sprite RenderIcon(GameObject prefab, Quaternion rotation)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			if (GUIManager.IsHeadless())
			{
				return null;
			}
			try
			{
				return RenderManager.Instance.Render(new RenderRequest(prefab)
				{
					Rotation = rotation,
					Width = 128,
					Height = 128,
					ParticleSimulationTime = -1f,
					UseCache = false
				});
			}
			catch (Exception ex)
			{
				ElderDragonsPlugin.Log.LogWarning((object)("Icon rendering failed: " + ex.Message));
				return null;
			}
		}

		public static List<RequirementConfig> ParseRecipe(string recipe)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			List<RequirementConfig> list = new List<RequirementConfig>();
			if (string.IsNullOrWhiteSpace(recipe))
			{
				return list;
			}
			string[] array = recipe.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
			foreach (string text in array)
			{
				string[] array2 = text.Split(new char[1] { ':' });
				if (array2.Length == 2 && int.TryParse(array2[1].Trim(), out var result) && result > 0 && array2[0].Trim().Length > 0)
				{
					list.Add(new RequirementConfig(array2[0].Trim(), result, 0, true));
				}
				else
				{
					ElderDragonsPlugin.Log.LogWarning((object)("Ignoring invalid recipe entry '" + text + "'."));
				}
			}
			return list;
		}
	}
	[BepInPlugin("zap.elderdragons", "Elder Dragons", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class ElderDragonsPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "zap.elderdragons";

		public const string PluginName = "Elder Dragons";

		public const string PluginVersion = "1.0.0";

		public const string ElementalDragonsGuid = "Ygg.ElementalDragons";

		public const string BetterRidingGuid = "Ygg.BetterRiding";

		private Harmony _harmony;

		public static ElderDragonsPlugin Instance { get; private set; }

		public static string PluginDir { get; private set; }

		public static ManualLogSource Log { get; private set; }

		public static string AssetPath(string fileName)
		{
			return Path.Combine(PluginDir ?? "", "Assets", fileName);
		}

		private void Awake()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			PluginDir = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			Cfg.Bind(((BaseUnityPlugin)this).Config);
			Lang.Register();
			Pieces.Init();
			_harmony = new Harmony("zap.elderdragons");
			_harmony.PatchAll(typeof(ElderDragonsPlugin).Assembly);
			Patches.PatchSoftDependencies(_harmony);
			SelfTest.TryStart(((Component)this).gameObject);
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}
namespace ElderDragons.Visual
{
	public static class Fx
	{
		private class FollowCenter : MonoBehaviour
		{
			public Character Body;

			private void LateUpdate()
			{
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)Body != (Object)null && (Object)(object)Body.m_collider != (Object)null)
				{
					Transform transform = ((Component)this).transform;
					Bounds bounds = ((Collider)Body.m_collider).bounds;
					transform.position = ((Bounds)(ref bounds)).center;
				}
			}
		}

		private static readonly Dictionary<string, GameObject> s_cache = new Dictionary<string, GameObject>();

		public static string[] AwakenFx = new string[2] { "fx_Fader_Roar", "vfx_odin_despawn" };

		public static string[] AwakenGlowFx = new string[1] { "vfx_HealthUpgrade" };

		public static string[] AwakenSfx = new string[2] { "sfx_dragon_scream", "sfx_dragon_alerted" };

		public static string[] KnockoutFx = new string[2] { "fx_shield_start", "fx_StaffShield_Hit" };

		public static string[] KnockoutSfx = new string[1] { "sfx_dragon_hurt" };

		public static string[] ShieldFx = new string[1] { "vfx_StaffShield" };

		public static string[] WakeFx = new string[2] { "fx_StaffShield_Break", "vfx_odin_despawn" };

		public static string[] WakeSfx = new string[1] { "sfx_dragon_alerted" };

		public static string[] ArrivalFx = new string[2] { "vfx_odin_despawn", "vfx_spawn_large" };

		public static string[] ArrivalSfx = new string[2] { "sfx_OpenPortal", "sfx_spawn" };

		public static string[] GrabSfx = new string[2] { "sfx_dragon_melee_hit", "sfx_dragon_melee_start" };

		public static string[] TotemFx = new string[2] { "vfx_Place_portal", "vfx_odin_despawn" };

		public static string[] TotemSfx = new string[2] { "sfx_dragon_alerted", "sfx_dragon_scream" };

		public static Color ColorOf(Element e)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(e switch
			{
				Element.Fire => new Color(1f, 0.45f, 0.12f), 
				Element.Frost => new Color(0.45f, 0.75f, 1f), 
				Element.Lightning => new Color(1f, 0.72f, 0.25f), 
				Element.Poison => new Color(0.45f, 0.95f, 0.3f), 
				Element.Black => new Color(0.65f, 0.35f, 1f), 
				_ => Color.white, 
			});
		}

		private static GameObject Prefab(string name)
		{
			if (string.IsNullOrEmpty(name) || (Object)(object)ZNetScene.instance == (Object)null)
			{
				return null;
			}
			if (s_cache.TryGetValue(name, out var value))
			{
				return value;
			}
			value = ZNetScene.instance.GetPrefab(name);
			if ((Object)(object)value != (Object)null && (Object)(object)value.GetComponent<ZNetView>() != (Object)null)
			{
				value = null;
			}
			s_cache[name] = value;
			return value;
		}

		public static GameObject Play(string[] names, Vector3 at, Quaternion rot, float scale = 1f)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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)
			if (GUIManagerHeadless())
			{
				return null;
			}
			for (int i = 0; i < names.Length; i++)
			{
				GameObject val = Prefab(names[i]);
				if (!((Object)(object)val == (Object)null))
				{
					GameObject val2 = Object.Instantiate<GameObject>(val, at, rot);
					if (scale != 1f)
					{
						Transform transform = val2.transform;
						transform.localScale *= scale;
					}
					return val2;
				}
			}
			return null;
		}

		private static bool GUIManagerHeadless()
		{
			return GUIManager.IsHeadless();
		}

		public static void Awakening(Elder e)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			if (GUIManagerHeadless() || (Object)(object)e == (Object)null)
			{
				return;
			}
			Vector3 position = ((Component)e).transform.position;
			Play(AwakenFx, position, Quaternion.identity, Mathf.Max(1f, e.Scale));
			Play(AwakenGlowFx, position, Quaternion.identity, Mathf.Max(1f, e.Scale) * 2f);
			if ((Object)(object)Play(AwakenSfx, position, Quaternion.identity) == (Object)null && (Object)(object)e.AI != (Object)null)
			{
				((BaseAI)e.AI).m_alertedEffects.Create(position, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID));
			}
			((MonoBehaviour)e).StartCoroutine(Glow(e, 9.5f, 6f));
			if ((Object)(object)Player.m_localPlayer != (Object)null && Vector3.Distance(((Component)Player.m_localPlayer).transform.position, position) < 60f)
			{
				((Character)Player.m_localPlayer).Message((MessageType)2, Lang.T("ed_msg_awaken", e.Character.GetHoverName()), 0, (Sprite)null, false);
				GameCamera instance = GameCamera.instance;
				if (instance != null)
				{
					instance.AddShake(position, 60f, 1.2f, false);
				}
			}
		}

		private static IEnumerator Glow(Elder e, float seconds, float peak)
		{
			GameObject go = new GameObject("ed_glow");
			go.transform.SetParent(((Component)e).transform, false);
			go.transform.localPosition = Vector3.up * 3f;
			Light l = go.AddComponent<Light>();
			l.type = (LightType)2;
			l.color = ColorOf(e.Element);
			l.range = 18f * Mathf.Max(1f, e.Scale);
			l.shadows = (LightShadows)0;
			float t0 = Time.time;
			while ((Object)(object)go != (Object)null && Time.time - t0 < seconds)
			{
				float num = (Time.time - t0) / seconds;
				l.intensity = peak * Mathf.Sin(num * (float)Math.PI) * (0.85f + 0.15f * Mathf.Sin(Time.time * 9f));
				yield return null;
			}
			if ((Object)(object)go != (Object)null)
			{
				Object.Destroy((Object)(object)go);
			}
		}

		public static void KnockedOut(Elder e)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (!GUIManagerHeadless() && !((Object)(object)e == (Object)null))
			{
				Play(KnockoutFx, e.Character.GetCenterPoint(), Quaternion.identity, e.Scale);
				Play(KnockoutSfx, e.Character.GetCenterPoint(), Quaternion.identity);
			}
		}

		public static void WakeUp(Elder e)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			if (!GUIManagerHeadless() && !((Object)(object)e == (Object)null))
			{
				Play(WakeFx, e.Character.GetCenterPoint(), Quaternion.identity, e.Scale * 2f);
				Play(WakeSfx, ((Component)e).transform.position, Quaternion.identity);
				((MonoBehaviour)e).StartCoroutine(Glow(e, 2.5f, 3f));
			}
		}

		public static GameObject Shield(Elder e)
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: 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)
			if (GUIManagerHeadless() || (Object)(object)e == (Object)null)
			{
				return null;
			}
			GameObject val = null;
			string[] shieldFx = ShieldFx;
			for (int i = 0; i < shieldFx.Length; i++)
			{
				if ((Object)(object)(val = Prefab(shieldFx[i])) != (Object)null)
				{
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return ShieldBubble.Create(e);
			}
			Bounds val2 = (Bounds)(((Object)(object)e.Character.m_collider != (Object)null) ? ((Collider)e.Character.m_collider).bounds : new Bounds(((Component)e).transform.position + Vector3.up * 2f, Vector3.one * 4f));
			GameObject val3 = Object.Instantiate<GameObject>(val, ((Bounds)(ref val2)).center, Quaternion.identity);
			TimedDestruction[] componentsInChildren = val3.GetComponentsInChildren<TimedDestruction>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren[i]);
			}
			Bounds val4 = RenderBounds(val3);
			float num = Mathf.Max(new float[3]
			{
				((Bounds)(ref val2)).size.x,
				((Bounds)(ref val2)).size.y,
				((Bounds)(ref val2)).size.z
			}) * 1.15f;
			float num2 = Mathf.Max(0.1f, Mathf.Max(new float[3]
			{
				((Bounds)(ref val4)).size.x,
				((Bounds)(ref val4)).size.y,
				((Bounds)(ref val4)).size.z
			}));
			Transform transform = val3.transform;
			transform.localScale *= Mathf.Clamp(num / num2, 0.5f, 30f);
			val3.transform.SetParent(((Component)e).transform, true);
			val3.AddComponent<FollowCenter>().Body = e.Character;
			return val3;
		}

		private static Bounds RenderBounds(GameObject go)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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)
			Bounds bounds = default(Bounds);
			((Bounds)(ref bounds))..ctor(go.transform.position, Vector3.one);
			bool flag = false;
			Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (!(val is ParticleSystemRenderer))
				{
					if (!flag)
					{
						bounds = val.bounds;
						flag = true;
					}
					else
					{
						((Bounds)(ref bounds)).Encapsulate(val.bounds);
					}
				}
			}
			return bounds;
		}

		public static void Grab(Elder e)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (!GUIManagerHeadless() && !((Object)(object)e == (Object)null))
			{
				Play(GrabSfx, e.ClawPoint, Quaternion.identity);
			}
		}

		public static void Arrival(Vector3 at)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (!GUIManagerHeadless())
			{
				Play(ArrivalFx, at + Vector3.up, Quaternion.identity, 2.5f);
				Play(ArrivalSfx, at, Quaternion.identity);
			}
		}

		public static void TotemCall(Vector3 at)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (!GUIManagerHeadless())
			{
				Play(TotemSfx, at, Quaternion.identity);
				Play(TotemFx, at + Vector3.up * 0.2f, Quaternion.identity, 1.5f);
			}
		}
	}
	public class ShieldBubble : MonoBehaviour
	{
		private const int Segments = 64;

		private Transform[] _rings;

		private Light _light;

		private Elder _elder;

		public static GameObject Create(Elder e)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			GameObject val = new GameObject("ed_shield");
			val.transform.SetParent(((Component)e).transform, false);
			val.AddComponent<ShieldBubble>().Build(e);
			return val;
		}

		private void Build(Elder e)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Expected O, but got Unknown
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: 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)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			_elder = e;
			Color val = Fx.ColorOf(e.Element);
			Shader val2 = Shader.Find("Sprites/Default");
			Bounds val3 = (Bounds)(((Object)(object)e.Character.m_collider != (Object)null) ? ((Collider)e.Character.m_collider).bounds : new Bounds(((Component)e).transform.position + Vector3.up * 2f, Vector3.one * 4f));
			((Component)this).transform.position = ((Bounds)(ref val3)).center;
			float num = Mathf.Max(new float[3]
			{
				((Bounds)(ref val3)).extents.x,
				((Bounds)(ref val3)).extents.z,
				((Bounds)(ref val3)).extents.y
			}) * 1.05f / Mathf.Max(0.01f, ((Component)e).transform.lossyScale.x);
			_rings = (Transform[])(object)new Transform[3];
			for (int i = 0; i < 3; i++)
			{
				GameObject val4 = new GameObject("ring" + i);
				val4.transform.SetParent(((Component)this).transform, false);
				val4.transform.localRotation = Quaternion.Euler(60f * (float)i, 30f * (float)i, 0f);
				LineRenderer val5 = val4.AddComponent<LineRenderer>();
				val5.useWorldSpace = false;
				val5.loop = true;
				val5.positionCount = 64;
				val5.widthMultiplier = 0.12f * ((Component)e).transform.lossyScale.x;
				((Renderer)val5).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)val5).receiveShadows = false;
				if ((Object)(object)val2 != (Object)null)
				{
					((Renderer)val5).material = new Material(val2);
				}
				Gradient val6 = new Gradient();
				val6.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
				{
					new GradientColorKey(val, 0f),
					new GradientColorKey(Color.Lerp(val, Color.white, 0.5f), 0.5f),
					new GradientColorKey(val, 1f)
				}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
				{
					new GradientAlphaKey(0.15f, 0f),
					new GradientAlphaKey(0.75f, 0.5f),
					new GradientAlphaKey(0.15f, 1f)
				});
				val5.colorGradient = val6;
				for (int j = 0; j < 64; j++)
				{
					float num2 = (float)j * (float)Math.PI * 2f / 64f;
					val5.SetPosition(j, new Vector3(Mathf.Cos(num2), 0f, Mathf.Sin(num2)) * num);
				}
				_rings[i] = val4.transform;
			}
			_light = ((Component)this).gameObject.AddComponent<Light>();
			_light.type = (LightType)2;
			_light.color = val;
			_light.range = num * ((Component)e).transform.lossyScale.x * 2.5f;
			_light.intensity = 1.5f;
			_light.shadows = (LightShadows)0;
		}

		private void LateUpdate()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_elder == (Object)null) && !((Object)(object)_elder.Character == (Object)null))
			{
				if ((Object)(object)_elder.Character.m_collider != (Object)null)
				{
					Transform transform = ((Component)this).transform;
					Bounds bounds = ((Collider)_elder.Character.m_collider).bounds;
					transform.position = ((Bounds)(ref bounds)).center;
				}
				float time = Time.time;
				for (int i = 0; i < _rings.Length; i++)
				{
					_rings[i].Rotate(new Vector3(0f, (18f + (float)i * 9f) * Time.deltaTime, (float)(i - 1) * 6f * Time.deltaTime), (Space)1);
				}
				if ((Object)(object)_light != (Object)null)
				{
					_light.intensity = 1.2f + 0.5f * Mathf.Sin(time * 2.2f);
				}
			}
		}
	}
}
namespace ElderDragons.UI
{
	public static class ClawHud
	{
		private static GameObject _go;

		private static Text _text;

		private static float _nextLook;

		private static string _line = "";

		public static void Show(Elder e)
		{
			if (!((Object)(object)e != (Object)null) || !e.CanGrab || !Cfg.ShowHints.Value || GUIManager.IsHeadless() || !((Object)(object)Hud.instance != (Object)null) || Hud.IsUserHidden())
			{
				if ((Object)(object)_go != (Object)null && _go.activeSelf)
				{
					_go.SetActive(false);
				}
			}
			else if (!((Object)(object)_go == (Object)null) || Build())
			{
				if (!_go.activeSelf)
				{
					_go.SetActive(true);
				}
				if (Time.time >= _nextLook)
				{
					_nextLook = Time.time + 0.2f;
					_line = Line(e);
				}
				if (_text.text != _line)
				{
					_text.text = _line;
				}
			}
		}

		private static string Line(Elder e)
		{
			//IL_000a: 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)
			string text = "<color=yellow><b>[" + ((object)Cfg.GrabKey.Value/*cast due to .constrained prefix*/).ToString() + "]</b></color> ";
			bool flag = false;
			foreach (Carried item in e.CarriedHere)
			{
				flag |= (Object)(object)item != (Object)null;
			}
			if (e.Carrying && flag)
			{
				IReadOnlyList<Carried> carriedHere = e.CarriedHere;
				string text2 = ((carriedHere.Count > 0 && (Object)(object)carriedHere[0] != (Object)null) ? Name(((Component)carriedHere[0]).gameObject) : "");
				if (carriedHere.Count > 1)
				{
					text2 = text2 + " +" + (carriedHere.Count - 1);
				}
				return text + Lang.T("ed_claw_letgo", text2);
			}
			Elder.Candidate candidate = e.FindTarget();
			if (candidate.Kind == Elder.Hold.None)
			{
				return "<color=#bbbbbb>" + Lang.T("ed_claw_none") + "</color>";
			}
			return text + Lang.T("ed_claw_grab", candidate.Name);
		}

		private static string Name(GameObject go)
		{
			Character component = go.GetComponent<Character>();
			if ((Object)(object)component != (Object)null)
			{
				return component.GetHoverName();
			}
			ItemDrop component2 = go.GetComponent<ItemDrop>();
			if ((Object)(object)component2 != (Object)null)
			{
				return Lang.L(component2.m_itemData.m_shared.m_name);
			}
			Hoverable component3 = go.GetComponent<Hoverable>();
			if (component3 == null)
			{
				return Utils.GetPrefabName(go);
			}
			return Lang.L(component3.GetHoverName());
		}

		private static bool Build()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)GUIManager.CustomGUIFront == (Object)null)
			{
				return false;
			}
			GUIManager instance = GUIManager.Instance;
			_go = instance.CreateText("", GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 190f), instance.AveriaSerifBold, 20, Color.white, true, Color.black, 700f, 32f, false);
			((Object)_go).name = "ed_claw_hint";
			_text = _go.GetComponent<Text>();
			_text.alignment = (TextAnchor)4;
			_text.supportRichText = true;
			((Graphic)_text).raycastTarget = false;
			return true;
		}
	}
}
namespace ElderDragons.Gameplay
{
	[DefaultExecutionOrder(100)]
	public class Carried : MonoBehaviour
	{
		private ZNetView _nview;

		private Character _character;

		private Player _player;

		private ItemDrop _item;

		private Rigidbody _body;

		private Vector3 _hang;

		private Quaternion _turn;

		private readonly List<(Collider a, Collider b)> _ignored = new List<(Collider, Collider)>();

		private ImpactEffect[] _impacts;

		private bool _itemAutoPickup;

		private bool _released;

		private static readonly Dictionary<Character, Carried> s_byCharacter = new Dictionary<Character, Carried>();

		private static readonly HashSet<GameObject> s_objects = new HashSet<GameObject>();

		private static readonly Dictionary<(Collider, Collider), int> s_ignoreCount = new Dictionary<(Collider, Collider), int>();

		private static readonly Dictionary<ZDOID, float> s_ignoreUntil = new Dictionary<ZDOID, float>();

		private static readonly int s_groundMask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "terrain", "piece", "piece_nonsolid" });

		private static readonly RaycastHit[] s_hits = (RaycastHit[])(object)new RaycastHit[16];

		public ZDOID Id { get; private set; }

		public Elder By { get; private set; }

		public Elder.Hold Kind { get; private set; }

		private bool Owns
		{
			get
			{
				if ((Object)(object)_nview != (Object)null && _nview.IsValid())
				{
					return _nview.IsOwner();
				}
				return false;
			}
		}

		public static bool IsCarried(GameObject go)
		{
			if (s_objects.Count > 0)
			{
				return s_objects.Contains(go);
			}
			return false;
		}

		public static Carried For(Character c)
		{
			if (!((Object)(object)c != (Object)null) || !s_byCharacter.TryGetValue(c, out var value))
			{
				return null;
			}
			return value;
		}

		public static bool Ignoring(GameObject go, ZDOID dragon)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)go.GetComponent<Player>() == (Object)(object)Player.m_localPlayer && s_ignoreUntil.TryGetValue(dragon, out var value))
			{
				return Time.time < value;
			}
			return false;
		}

		public static void Ignore(ZDOID dragon, float seconds)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			s_ignoreUntil[dragon] = Time.time + seconds;
		}

		public static bool LocalPlayerCanBeTaken(Player p)
		{
			if ((Object)(object)p == (Object)null || ((Character)p).IsDead() || ((Character)p).IsAttached() || ((Character)p).IsRiding() || ((Character)p).IsTeleporting() || ((Character)p).InCutscene() || ((Character)p).InBed() || p.IsSleeping())
			{
				return false;
			}
			if (!Cfg.GrabPlayers.Value)
			{
				return false;
			}
			if (Cfg.GrabPlayersNeedsPvP.Value && !((Character)p).IsPVPEnabled())
			{
				return false;
			}
			return true;
		}

		public void Setup(Elder by, ZDOID id, int slot)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: 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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			By = by;
			Id = id;
			_nview = ((Component)this).GetComponent<ZNetView>();
			_character = ((Component)this).GetComponent<Character>();
			ref Player player = ref _player;
			Character character = _character;
			player = (Player)(object)((character is Player) ? character : null);
			_item = ((Component)this).GetComponent<ItemDrop>();
			_body = ((Component)this).GetComponent<Rigidbody>() ?? (((Object)(object)_character != (Object)null) ? _character.m_body : null);
			if ((Object)(object)_character != (Object)null)
			{
				s_byCharacter[_character] = this;
			}
			s_objects.Add(((Component)this).gameObject);
			Kind = (((Object)(object)_player != (Object)null) ? Elder.Hold.Player : (((Object)(object)_character != (Object)null) ? Elder.Hold.Creature : (((Object)(object)_item != (Object)null) ? Elder.Hold.Item : (((Object)(object)((Component)this).GetComponent<Vagon>() != (Object)null) ? Elder.Hold.Cart : Elder.Hold.Log))));
			float num = TopAbove();
			Vector3 val = Vector3.down * num;
			if (Kind == Elder.Hold.Player)
			{
				val = Vector3.down * 1.75f;
			}
			if (Kind == Elder.Hold.Item)
			{
				val = Vector3.down * 0.25f + Quaternion.Euler(0f, (float)slot * 137.5f, 0f) * Vector3.forward * ((slot == 0) ? 0f : 0.35f);
			}
			float y = ((Component)by).transform.eulerAngles.y;
			_hang = Quaternion.Euler(0f, 0f - y, 0f) * val;
			_turn = ((Kind == Elder.Hold.Player || Kind == Elder.Hold.Creature) ? Quaternion.identity : (Quaternion.Euler(0f, 0f - y, 0f) * ((Component)this).transform.rotation));
			Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>(true);
			foreach (Collider val2 in componentsInChildren)
			{
				if ((Object)(object)val2 == (Object)null || val2.isTrigger)
				{
					continue;
				}
				Collider[] colliders = by.Colliders;
				foreach (Collider val3 in colliders)
				{
					if ((Object)(object)val3 != (Object)null && !val3.isTrigger)
					{
						IgnorePair(val2, val3);
						_ignored.Add((val2, val3));
					}
				}
			}
			if ((Object)(object)_item != (Object)null)
			{
				_itemAutoPickup = _item.m_autoPickup;
				_item.m_autoPickup = false;
			}
			_impacts = ((Component)this).GetComponentsInChildren<ImpactEffect>(true);
			ImpactEffect[] impacts = _impacts;
			foreach (ImpactEffect obj in impacts)
			{
				((MonoBehaviour)obj).CancelInvoke("ResetHitTimer");
				obj.m_hitEffectEnabled = false;
			}
			if ((Object)(object)_player != (Object)null && (Object)(object)_player == (Object)(object)Player.m_localPlayer)
			{
				((Character)_player).Message((MessageType)2, Lang.T(Cfg.PlayersBreakFree.Value ? "ed_claw_caught_free" : "ed_claw_caught", by.Character.GetHoverName()), 0, (Sprite)null, false);
			}
			Place(Owns);
		}

		private static void IgnorePair(Collider a, Collider b)
		{
			s_ignoreCount.TryGetValue((a, b), out var value);
			s_ignoreCount[(a, b)] = value + 1;
			Physics.IgnoreCollision(a, b, true);
		}

		private float TopAbove()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			float num = 0.5f;
			bool flag = false;
			Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>();
			foreach (Collider val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null) && !val.isTrigger)
				{
					Bounds bounds = val.bounds;
					float num2 = ((Bounds)(ref bounds)).max.y - ((Component)this).transform.position.y;
					if (!flag || num2 > num)
					{
						num = num2;
						flag = true;
					}
				}
			}
			return Mathf.Clamp(num, 0.2f, 12f);
		}

		private void Place(bool physics)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)By == (Object)null || !By.Valid)
			{
				Release();
				return;
			}
			Quaternion val = Quaternion.Euler(0f, ((Component)By).transform.eulerAngles.y, 0f);
			Vector3 clawPoint = By.ClawPoint;
			Vector3 val2 = clawPoint + val * _hang;
			float num = clawPoint.y - val2.y;
			if (num > 0.05f)
			{
				int num2 = Physics.RaycastNonAlloc(clawPoint, Vector3.down, s_hits, num + 0.5f, s_groundMask, (QueryTriggerInteraction)1);
				float num3 = float.MinValue;
				for (int i = 0; i < num2; i++)
				{
					Collider collider = ((RaycastHit)(ref s_hits[i])).collider;
					if (!((Object)(object)collider == (Object)null) && !((Object)(object)((Component)collider).transform.root == (Object)(object)((Component)By).transform.root) && !((Object)(object)((Component)collider).GetComponentInParent<Carried>() != (Object)null))
					{
						num3 = Mathf.Max(num3, ((RaycastHit)(ref s_hits[i])).point.y);
					}
				}
				if (num3 > float.MinValue)
				{
					val2.y = Mathf.Max(val2.y, num3 + 0.05f);
				}
			}
			Quaternion val3 = val * _turn;
			((Component)this).transform.SetPositionAndRotation(val2, val3);
			if (physics && !((Object)(object)_body == (Object)null))
			{
				_body.position = val2;
				_body.rotation = val3;
				_body.linearVelocity = By.ClawVelocity;
				_body.angularVelocity = Vector3.zero;
				if ((Object)(object)_character != (Object)null)
				{
					_character.m_maxAirAltitude = val2.y;
				}
			}
		}

		public void OwnerStep()
		{
			if (!_released && Owns)
			{
				Place(physics: true);
			}
		}

		private void FixedUpdate()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (_released)
			{
				return;
			}
			if (!Owns)
			{
				if ((Object)(object)_body != (Object)null && !_body.isKinematic)
				{
					_body.useGravity = false;
					_body.linearVelocity = Vector3.zero;
					_body.angularVelocity = Vector3.zero;
				}
			}
			else if ((Object)(object)_player != (Object)null && (Object)(object)_player == (Object)(object)Player.m_localPlayer && !LocalPlayerCanBeTaken(_player) && !((Character)_player).IsDead())
			{
				BreakFree();
			}
			else if ((Object)(object)_character == (Object)null)
			{
				OwnerStep();
			}
		}

		private void LateUpdate()
		{
			if (!_released)
			{
				Place(physics: false);
			}
		}

		public void BreakFree()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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)
			if (!_released && !((Object)(object)By == (Object)null))
			{
				Ignore(By.NView.GetZDO().m_uid, 3f);
				if (By.NView.IsOwner())
				{
					By.ReleaseOne(Id);
				}
				else
				{
					By.NView.InvokeRPC("ED_LetGo", new object[1] { Id });
				}
				Release();
			}
		}

		public void Release()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			if (_released)
			{
				return;
			}
			_released = true;
			if ((Object)(object)_character != (Object)null)
			{
				s_byCharacter.Remove(_character);
			}
			s_objects.Remove(((Component)this).gameObject);
			Vector3 linearVelocity = (((Object)(object)By != (Object)null) ? By.ClawVelocity : Vector3.zero);
			if (_ignored.Count > 0 && (Object)(object)ElderDragonsPlugin.Instance != (Object)null)
			{
				((MonoBehaviour)ElderDragonsPlugin.Instance).StartCoroutine(RestoreCollisions(new List<(Collider, Collider)>(_ignored), 1.5f));
			}
			_ignored.Clear();
			if ((Object)(object)_item != (Object)null)
			{
				_item.m_autoPickup = _itemAutoPickup;
			}
			if (_impacts != null)
			{
				ImpactEffect[] impacts = _impacts;
				foreach (ImpactEffect val in impacts)
				{
					if ((Object)(object)val != (Object)null)
					{
						val.m_hitEffectEnabled = true;
					}
				}
			}
			if (Owns)
			{
				if ((Object)(object)_body != (Object)null)
				{
					_body.linearVelocity = linearVelocity;
					_body.WakeUp();
				}
				if ((Object)(object)_character != (Object)null)
				{
					_character.m_maxAirAltitude = ((Component)this).transform.position.y;
				}
				if ((Object)(object)_character != (Object)null && (Object)(object)_player == (Object)null && Cfg.CreatureFallDamage.Value)
				{
					FallWatch.Start(_character, ((Component)this).transform.position.y);
				}
			}
			Object.Destroy((Object)(object)this);
		}

		private static IEnumerator RestoreCollisions(List<(Collider a, Collider b)> pairs, float delay)
		{
			yield return (object)new WaitForSeconds(delay);
			foreach (var pair in pairs)
			{
				if (!s_ignoreCount.TryGetValue(pair, out var value))
				{
					continue;
				}
				if (value > 1)
				{
					s_ignoreCount[pair] = value - 1;
					continue;
				}
				s_ignoreCount.Remove(pair);
				if ((Object)(object)pair.a != (Object)null && (Object)(object)pair.b != (Object)null)
				{
					Physics.IgnoreCollision(pair.a, pair.b, false);
				}
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)_character != (Object)null)
			{
				s_byCharacter.Remove(_character);
			}
			s_objects.Remove(((Component)this).gameObject);
			if (!_released)
			{
				Release();
			}
		}
	}
	public class Elder : MonoBehaviour
	{
		public enum Hold
		{
			None,
			Player,
			Creature,
			Item,
			Cart,
			Log
		}

		public struct Candidate
		{
			public ZNetView View;

			public Hold Kind;

			public float Distance;

			public string Name;
		}

		private Transform _footL;

		private Transform _footR;

		private Vector3 _clawPoint;

		private Vector3 _lastClaw;

		private Vector3 _clawVelocity;

		private bool _clawTracked;

		private readonly List<Carried> _carried = new List<Carried>();

		private bool _grabbing;

		private bool _carryAirborne;

		private readonly Dictionary<ZDOID, float> _freedUntil = new Dictionary<ZDOID, float>();

		private static int[] s_attachBools;

		private static readonly List<ZDOID> s_none = new List<ZDOID>();

		private float _refusedAt = -99f;

		private Collider[] _colliders;

		private static readonly List<Elder> s_all = new List<Elder>();

		private static readonly Dictionary<Character, Elder> s_byCharacter = new Dictionary<Character, Elder>();

		private Vector3 _baseScale;

		private float _appliedFactor = 1f;

		private float _nextSlow;

		private bool _sceneSeen;

		private float _visualScale = 1f;

		private GameObject _shield;

		private bool _koLook;

		private bool _koLookKnown;

		private static readonly int s_floorMask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "terrain", "piece" });

		public Vector3 ClawPoint
		{
			get
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				if (!_clawTracked)
				{
					_clawPoint = ComputeClawPoint();
				}
				return _clawPoint;
			}
		}

		public Vector3 ClawVelocity => _clawVelocity;

		public bool Carrying
		{
			get
			{
				if (Valid && Zdo.GetInt(Keys.CarryCount, 0) > 0)
				{
					return ListIsCurrent();
				}
				return false;
			}
		}

		public bool CanGrab
		{
			get
			{
				if (Valid && !KnockedOut && !Character.IsDead() && (Awakened || !Cfg.GrabNeedsElder.Value) && (Object)(object)Tame != (Object)null)
				{
					return (Object)(object)Tame.m_saddle != (Object)null;
				}
				return false;
			}
		}

		public Collider[] Colliders => _colliders ?? (_colliders = ((Component)this).GetComponentsInChildren<Collider>(true));

		public IReadOnlyList<Carried> CarriedHere => _carried;

		public static IReadOnlyList<Elder> All => s_all;

		public Character Character { get; private set; }

		public ZNetView NView { get; private set; }

		public Tameable Tame { get; private set; }

		public MonsterAI AI { get; private set; }

		public Element Element { get; private set; }

		public bool ElderStage { get; private set; }

		public bool Valid
		{
			get
			{
				if ((Object)(object)NView != (Object)null && NView.IsValid())
				{
					return NView.GetZDO() != null;
				}
				return false;
			}
		}

		private ZDO Zdo => NView.GetZDO();

		public bool Awakened
		{
			get
			{
				if (Valid)
				{
					return Zdo.GetBool(Keys.Elder, false);
				}
				return false;
			}
		}

		public bool Protected
		{
			get
			{
				if (Awakened && Character.IsTamed() && Cfg.CannotDie.Value)
				{
					return !Zdo.GetBool(Keys.Released, false);
				}
				return false;
			}
		}

		public long OwnerId
		{
			get
			{
				if (!Valid)
				{
					return 0L;
				}
				long num = Zdo.GetLong(Keys.BetterRidingOwner, 0L);
				if (num == 0L)
				{
					return Zdo.GetLong(Keys.Owner, 0L);
				}
				return num;
			}
		}

		public double LivedSeconds
		{
			get
			{
				if (!Valid)
				{
					return 0.0;
				}
				long num = Zdo.GetLong(ZDOVars.s_spawnTime, 0L);
				if (num == 0L)
				{
					return 0.0;
				}
				return (ZNet.instance.GetTime() - new DateTime(num)).TotalSeconds;
			}
		}

		public static double NeededSeconds => ElderRules.MaturingSeconds(Cfg.MaturingDays.Value, 1800.0);

		public double SinceAwake
		{
			get
			{
				if (!Valid)
				{
					return -1.0;
				}
				long num = Zdo.GetLong(Keys.AwokeAt, 0L);
				if (num == 0L)
				{
					if (!Awakened)
					{
						return -1.0;
					}
					return 1000000000.0;
				}
				return (ZNet.instance.GetTime() - new DateTime(num)).TotalSeconds;
			}
		}

		public float SizeFactor => _appliedFactor;

		public float Scale => ((Component)this).transform.localScale.x * _visualScale;

		public Vector3 BaseScale => _baseScale;

		public bool KnockedOut
		{
			get
			{
				if (Valid)
				{
					return Zdo.GetLong(Keys.KnockedOut, 0L) != 0;
				}
				return false;
			}
		}

		public double KnockoutLeft
		{
			get
			{
				if (!Valid)
				{
					return 0.0;
				}
				return ElderRules.KnockoutLeft(Zdo.GetLong(Keys.KnockedOut, 0L), ZNet.instance.GetTime().Ticks);
			}
		}

		private void FindClawBones()
		{
			Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if ((Object)(object)_footL == (Object)null && ((Object)val).name == "L Foot")
				{
					_footL = val;
				}
				else if ((Object)(object)_footR == (Object)null && ((Object)val).name == "R Foot")
				{
					_footR = val;
				}
			}
		}

		private Vector3 ComputeClawPoint()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_footL != (Object)null && (Object)(object)_footR != (Object)null)
			{
				return (_footL.position + _footR.position) * 0.5f - Vector3.up * (0.25f * Scale);
			}
			return ((Component)this).transform.position + Vector3.up * (0.4f * Scale);
		}

		private void TrackClaws(float dt)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ComputeClawPoint();
			if (_clawTracked && dt > 0f)
			{
				_clawVelocity = Vector3.Lerp(_clawVelocity, (val - _lastClaw) / dt, 0.5f);
			}
			_lastClaw = val;
			_clawPoint = val;
			_clawTracked = true;
		}

		private void LateUpdate()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if (Valid)
			{
				_clawPoint = ComputeClawPoint();
			}
		}

		public List<ZDOID> CarryList()
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			if (!Valid)
			{
				return new List<ZDOID>();
			}
			if (!ListIsCurrent())
			{
				if (_carried.Count != 0)
				{
					return new List<ZDOID>();
				}
				return s_none;
			}
			int num = Mathf.Clamp(Zdo.GetInt(Keys.CarryCount, 0), 0, 8);
			if (num == 0 && _carried.Count == 0)
			{
				return s_none;
			}
			List<ZDOID> list = new List<ZDOID>(num);
			for (int i = 0; i < num; i++)
			{
				ZDOID zDOID = Zdo.GetZDOID(Keys.Carry[i]);
				if (!((ZDOID)(ref zDOID)).IsNone())
				{
					list.Add(zDOID);
				}
			}
			return list;
		}

		private bool ListIsCurrent()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			return Zdo.GetZDOID("ed_carry_self") == Zdo.m_uid;
		}

		internal void WriteCarry(List<ZDOID> ids)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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)
			int num = Mathf.Min(ids.Count, 8);
			for (int i = 0; i < 8; i++)
			{
				Zdo.Set(Keys.Carry[i], (i < num) ? ids[i] : ZDOID.None);
			}
			Zdo.Set(Keys.CarryCount, num, false);
			Zdo.Set("ed_carry_self", (num > 0) ? Zdo.m_uid : ZDOID.None);
		}

		public void ReleaseAll()
		{
			if (Valid && NView.IsOwner() && Carrying)
			{
				WriteCarry(new List<ZDOID>());
			}
		}

		public void ReleaseOne(ZDOID id)
		{
			//IL_001c: 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)
			if (Valid && NView.IsOwner())
			{
				_freedUntil[id] = Time.time + 3f;
				List<ZDOID> list = CarryList();
				if (list.Remove(id))
				{
					WriteCarry(list);
				}
			}
		}

		private void OwnerCarryChecks()
		{
			if (Carrying)
			{
				List<ZDOID> list = CarryList();
				if (list.RemoveAll((ZDOID id) => ZDOMan.instance.GetZDO(id) == null) > 0)
				{
					WriteCarry(list);
				}
				if ((!SelfTest.KeepCarry || KnockedOut) && (KnockedOut || !RiddenByLocal()))
				{
					ReleaseAll();
				}
			}
		}

		private void OwnerLandingCheck()
		{
			if (!NView.IsOwner() || !Carrying || !RiddenByLocal())
			{
				_carryAirborne = false;
			}
			else if (Character.IsFlying())
			{
				_carryAirborne = true;
			}
			else if (_carryAirborne && Character.IsOnGround())
			{
				_carryAirborne = false;
				ReleaseAll();
			}
		}

		private bool RecentlyFreed(ZNetView v)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			ZDO zDO = v.GetZDO();
			if (zDO != null && _freedUntil.TryGetValue(zDO.m_uid, out var value))
			{
				return Time.time < value;
			}
			return false;
		}

		public bool RiddenByLocal()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null && ((Character)localPlayer).IsRiding())
			{
				IDoodadController doodadController = localPlayer.GetDoodadController();
				Sadle val = (Sadle)(object)((doodadController is Sadle) ? doodadController : null);
				if (val != null)
				{
					return (Object)(object)val.GetCharacter() == (Object)(object)Character;
				}
			}
			return false;
		}

		public Candidate FindTarget()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			Candidate result = new Candidate
			{
				Kind = Hold.None,
				Distance = float.MaxValue
			};
			if (!CanGrab)
			{
				return result;
			}
			Vector3 clawPoint = ClawPoint;
			float num = ElderRules.Reach(Cfg.GrabReach.Value, Scale);
			float lift = ElderRules.LiftHeight(Cfg.MaxCreatureHeight.Value, Scale);
			Player localPlayer = Player.m_localPlayer;
			HashSet<ZNetView> hashSet = new HashSet<ZNetView>();
			Collider[] array = Physics.OverlapSphere(clawPoint, num, -1, (QueryTriggerInteraction)1);
			foreach (Collider val in array)
			{
				if ((Object)(object)val == (Object)null || (Object)(object)val.attachedRigidbody == (Object)null)
				{
					continue;
				}
				ZNetView val2 = ((Component)val.attachedRigidbody).GetComponent<ZNetView>() ?? ((Component)val).GetComponentInParent<ZNetView>();
				if ((Object)(object)val2 == (Object)null || !val2.IsValid() || (Object)(object)((Component)val2).gameObject == (Object)(object)((Component)this).gameObject || !hashSet.Add(val2) || (Object)(object)((Component)val2).GetComponent<Carried>() != (Object)null || RecentlyFreed(val2))
				{
					continue;
				}
				Hold hold = KindOf(val2, localPlayer, lift);
				if (hold != Hold.None)
				{
					float num2 = Vector3.Distance(clawPoint, val.ClosestPoint(clawPoint));
					if (hold == Hold.Item)
					{
						num2 += 0.5f;
					}
					if (num2 < result.Distance)
					{
						result = new Candidate
						{
							View = val2,
							Kind = hold,
							Distance = num2,
							Name = NameOf(val2)
						};
					}
				}
			}
			return result;
		}

		private Hold KindOf(ZNetView v, Player me, float lift)
		{
			Character component = ((Component)v).GetComponent<Character>();
			if ((Object)(object)component != (Object)null)
			{
				if (component.IsDead() || (Object)(object)component == (Object)(object)me)
				{
					return Hold.None;
				}
				Player val = (Player)(object)((component is Player) ? component : null);
				if (val != null)
				{
					if (!Cfg.GrabPlayers.Value || ((Character)val).InBed() || ((Character)val).IsAttached() || ((Character)val).InCutscene() || SeatedElsewhere(val))
					{
						return Hold.None;
					}
					if (Cfg.GrabPlayersNeedsPvP.Value && !((Character)val).IsPVPEnabled())
					{
						return Hold.None;
					}
					return Hold.Player;
				}
				if (Cfg.GrabCreatures.Value && !component.IsBoss())
				{
					Elder elder = Of((Component)(object)component);
					if (elder == null || !elder.Awakened)
					{
						Tameable component2 = ((Component)component).GetComponent<Tameable>();
						if ((Object)(object)component2 != (Object)null && (Object)(object)component2.m_saddle != (Object)null && component2.m_saddle.HaveValidUser())
						{
							return Hold.None;
						}
						if (HeightOf(component) > lift)
						{
							return Hold.None;
						}
						return Hold.Creature;
					}
				}
				return Hold.None;
			}
			if (Cfg.GrabItems.Value)
			{
				ItemDrop component3 = ((Component)v).GetComponent<ItemDrop>();
				if (component3 != null && component3.m_itemData != null)
				{
					return Hold.Item;
				}
			}
			if (Cfg.GrabCarts.Value)
			{
				Vagon component4 = ((Component)v).GetComponent<Vagon>();
				if ((Object)(object)component4 != (Object)null)
				{
					if (!CartBusy(component4))
					{
						return Hold.Cart;
					}
					return Hold.None;
				}
				if ((Object)(object)((Component)v).GetComponent<TreeLog>() != (Object)null)
				{
					return Hold.Log;
				}
			}
			return Hold.None;
		}

		public static bool SeatedElsewhere(Player pl)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Invalid comparison between Unknown and I4
			ZDO val = (((Object)(object)((Character)pl).m_nview != (Object)null) ? ((Character)pl).m_nview.GetZDO() : null);
			if (val == null || (Object)(object)((Character)pl).m_animator == (Object)null)
			{
				return false;
			}
			if (s_attachBools == null)
			{
				List<int> list = new List<int>();
				AnimatorControllerParameter[] parameters = ((Character)pl).m_animator.parameters;
				foreach (AnimatorControllerParameter val2 in parameters)
				{
					if ((int)val2.type == 4 && val2.name.StartsWith("attach"))
					{
						list.Add(val2.nameHash);
					}
				}
				if (list.Count == 0)
				{
					return false;
				}
				s_attachBools = list.ToArray();
			}
			int[] array = s_attachBools;
			foreach (int num in array)
			{
				if (val.GetInt(438569 + num, 0) != 0)
				{
					return true;
				}
			}
			return false;
		}

		public static bool CartBusy(Vagon cart)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if (cart.IsAttached() || cart.InUse())
			{
				return true;
			}
			ZNetView component = ((Component)cart).GetComponent<ZNetView>();
			if ((Object)(object)component != (Object)null && component.GetZDO() != null && component.GetZDO().GetInt(ZDOVars.s_inUse, 0) == 1)
			{
				return true;
			}
			if ((Object)(object)cart.m_chair != (Object)null && (cart.m_chair.IsInUse() || (Object)(object)Player.GetClosestPlayer(cart.m_chair.m_attachPoint.position, 0.6f) != (Object)null))
			{
				return true;
			}
			return false;
		}

		public static float HeightOf(Character ch)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			Collider collider = (Collider)(object)ch.m_collider;
			if ((Object)(object)collider == (Object)null)
			{
				return ch.GetHeight();
			}
			Bounds bounds = collider.bounds;
			return ((Bounds)(ref bounds)).size.y;
		}

		private static string NameOf(ZNetView v)
		{
			Character component = ((Component)v).GetComponent<Character>();
			if ((Object)(object)component != (Object)null)
			{
				return component.GetHoverName();
			}
			ItemDrop component2 = ((Component)v).GetComponent<ItemDrop>();
			if ((Object)(object)component2 != (Object)null)
			{
				return Lang.L(component2.m_itemData.m_shared.m_name) + ((component2.m_itemData.m_stack > 1) ? (" ×" + component2.m_itemData.m_stack) : "");
			}
			Hoverable component3 = ((Component)v).GetComponent<Hoverable>();
			if (component3 != null)
			{
				return Lang.L(component3.GetHoverName());
			}
			return Utils.GetPrefabName(((Component)v).gameObject);
		}

		public void ToggleGrab()
		{
			if (!Valid || !NView.IsOwner())
			{
				return;
			}
			if (Carrying)
			{
				List<ZDOID> list = CarryList();
				list.RemoveAll((ZDOID id) => ZDOMan.instance.GetZDO(id) == null || (Object)(object)ZNetScene.instance.FindInstance(id) == (Object)null);
				if (list.Count > 0)
				{
					ReleaseAll();
					return;
				}
				WriteCarry(new List<ZDOID>());
			}
			if (_grabbing)
			{
				return;
			}
			Candidate c = FindTarget();
			if (c.Kind == Hold.None)
			{
				Player localPlayer = Player.m_localPlayer;
				if (localPlayer != null)
				{
					((Character)localPlayer).Message((MessageType)2, Lang.T("ed_claw_nothing"), 0, (Sprite)null, false);
				}
			}
			else
			{
				((MonoBehaviour)this).StartCoroutine(Grab(c));
			}
		}

		private IEnumerator Grab(Candidate c)
		{
			_grabbing = true;
			try
			{
				List<ZNetView> views = new List<ZNetView> { c.View };
				if (c.Kind == Hold.Item)
				{
					Collider[] array = Physics.OverlapSphere(((Component)c.View).transform.position, 1.5f, LayerMask.GetMask(new string[1] { "item" }), (QueryTriggerInteraction)1);
					for (int i = 0; i < array.Length; i++)
					{
						ItemDrop componentInParent = ((Component)array[i]).GetComponentInParent<ItemDrop>();
						ZNetView val = (((Object)(object)componentInParent != (Object)null) ? ((Component)componentInParent).GetComponent<ZNetView>() : null);
						if ((Object)(object)val != (Object)null && val.IsValid() && !views.Contains(val) && (Object)(object)((Component)val).GetComponent<Carried>() == (Object)null && views.Count < 8)
						{
							views.Add(val);
						}
					}
				}
				if (c.Kind != Hold.Player)
				{
					foreach (ZNetView item in views)
					{
						TakeOver(item);
					}
				}
				float limit = Time.time + 3f;
				while (c.Kind != Hold.Player && Time.time < limit && views.Any((ZNetView v) => (Object)(object)v != (Object)null && v.IsValid() && !v.IsOwner()))
				{
					yield return null;
				}
				if (!Valid || !NView.IsOwner() || !CanGrab)
				{
					yield break;
				}
				List<ZDOID> list = (from v in views
					where (Object)(object)v != (Object)null && v.IsValid() && (c.Kind == Hold.Player || v.IsOwner())
					select v.GetZDO().m_uid).ToList();
				if (list.Count == 0)
				{
					Player localPlayer = Player.m_localPlayer;
					if (localPlayer != null)
					{
						((Character)localPlayer).Message((MessageType)2, Lang.T("ed_claw_slipped"), 0, (Sprite)null, false);
					}
				}
				else
				{
					WriteCarry(list);
					Fx.Grab(this);
				}
			}
			finally
			{
				_grabbing = false;
			}
		}

		private static void TakeOver(ZNetView v)
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)v == (Object)null) && v.IsValid() && !v.IsOwner())
			{
				ZDO zDO = v.GetZDO();
				long owner = zDO.GetOwner();
				if (owner == 0L || (ZNet.instance.IsServer() && ZNet.instance.GetPeer(owner) == null && owner != ZDOMan.GetSessionID()))
				{
					v.ClaimOwnership();
					return;
				}
				ZRoutedRpc.instance.InvokeRoutedRPC(owner, "ED_HandOver", new object[2]
				{
					zDO.m_uid,
					ZDOMan.GetSessionID()
				});
			}
		}

		private void UpdateCarryLocal()
		{
			//IL_0093: 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)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			bool flag = (Object)(object)Tame != (Object)null && (Object)(object)Tame.m_saddle != (Object)null && Tame.m_saddle.HaveValidUser();
			List<ZDOID> ids = ((flag || SelfTest.KeepCarry) ? CarryList() : s_none);
			for (int num = _carried.Count - 1; num >= 0; num--)
			{
				Carried carried = _carried[num];
				if ((Object)(object)carried == (Object)null)
				{
					_carried.RemoveAt(num);
				}
				else if (!ids.Contains(carried.Id))
				{
					carried.Release();
					_carried.RemoveAt(num);
				}
			}
			int i;
			for (i = 0; i < ids.Count; i++)
			{
				if (_carried.Any((Carried c) => (Object)(object)c != (Object)null && c.Id == ids[i]))
				{
					continue;
				}
				GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.FindInstance(ids[i]) : null);
				if ((Object)(object)val == (Object)null || !Holdable(val))
				{
					continue;
				}
				ZDOID uid = NView.GetZDO().m_uid;
				if (Carried.Ignoring(val, uid))
				{
					Refuse(ids[i]);
					continue;
				}
				if ((Object)(object)val.GetComponent<Carried>() != (Object)null)
				{
					if ((Object)(object)val.GetComponent<Player>() == (Object)(object)Player.m_localPlayer)
					{
						Refuse(ids[i]);
					}
					continue;
				}
				Player component = val.GetComponent<Player>();
				if (component != null && (Object)(object)component == (Object)(object)Player.m_localPlayer && !Carried.LocalPlayerCanBeTaken(component))
				{
					Carried.Ignore(uid, 3f);
					Refuse(ids[i]);
				}
				else
				{
					Carried carried2 = val.AddComponent<Carried>();
					carried2.Setup(this, ids[i], i);
					_carried.Add(carried2);
				}
			}
		}

		private bool Holdable(GameObject go)
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)go == (Object)(object)((Component