Decompiled source of LeviathanAxe v1.0.3

plugins/LeviathanAxe.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using HotReload;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using LeviathanAxe.Content;
using LeviathanAxe.Freeze;
using LeviathanAxe.Throwing;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("LeviathanAxe")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3")]
[assembly: AssemblyProduct("LeviathanAxe")]
[assembly: AssemblyTitle("LeviathanAxe")]
[assembly: AssemblyVersion("1.0.3.0")]
[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 HotReload
{
	public interface IModule
	{
		void Start(ModuleContext context);

		void Update();

		void Stop();
	}
	public sealed class ModuleContext
	{
		public ManualLogSource Log { get; }

		public ConfigFile Config { get; }

		public string PluginDirectory { get; }

		public int Generation { get; }

		public IDictionary<string, object> Carry { get; }

		internal ModuleContext(ManualLogSource log, ConfigFile config, string pluginDirectory, int generation, IDictionary<string, object> carry)
		{
			Log = log;
			Config = config;
			PluginDirectory = pluginDirectory;
			Generation = generation;
			Carry = carry;
		}
	}
	internal sealed class ModuleHost
	{
		private const float PollSeconds = 1f;

		private readonly string _harmonyPrefix;

		private readonly ManualLogSource _log;

		private readonly ConfigFile _config;

		private readonly string _pluginDirectory;

		private readonly Dictionary<string, object> _carry = new Dictionary<string, object>();

		private IModule _module;

		private Harmony _harmony;

		private string _name;

		private int _generation;

		private bool _updateFailed;

		internal static ModuleHost Current { get; private set; }

		internal Action Stopped { get; set; }

		internal int Generation => _generation;

		internal ModuleHost(string pluginGuid, string moduleFile, ManualLogSource log, ConfigFile config, string pluginDirectory)
		{
			_harmonyPrefix = pluginGuid + ".module.";
			_log = log;
			_config = config;
			_pluginDirectory = pluginDirectory;
			Current = this;
		}

		internal static void PatchClasses(Harmony harmony, Assembly assembly, ManualLogSource log)
		{
			Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(assembly);
			foreach (Type type in typesFromAssembly)
			{
				try
				{
					if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Length != 0)
					{
						harmony.CreateClassProcessor(type).Patch();
					}
				}
				catch (Exception arg)
				{
					log.LogError((object)$"patch {type.FullName}: {arg}");
				}
			}
		}

		internal bool Attach(IModule module, out string message)
		{
			Stopwatch stopwatch = Stopwatch.StartNew();
			Assembly assembly = module.GetType().Assembly;
			if (!TryStart(module, assembly, ++_generation, assembly.GetName().Name, out message))
			{
				_log.LogWarning((object)message);
				return false;
			}
			message = $"module {_name} started in {stopwatch.ElapsedMilliseconds} ms";
			_log.LogInfo((object)message);
			return true;
		}

		internal string Stop()
		{
			if (_module == null)
			{
				return "module: nothing to stop";
			}
			string name = _name;
			StopCurrent();
			return "module " + name + " stopped";
		}

		internal void Update()
		{
			if (_module == null)
			{
				return;
			}
			try
			{
				_module.Update();
			}
			catch (Exception arg)
			{
				if (!_updateFailed)
				{
					_updateFailed = true;
					_log.LogError((object)$"module {_name}: Update: {arg}");
				}
			}
		}

		private bool TryStart(IModule module, Assembly assembly, int generation, string name, out string message)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			Harmony val = new Harmony(_harmonyPrefix + generation);
			try
			{
				PatchClasses(val, assembly, _log);
				module.Start(new ModuleContext(_log, _config, _pluginDirectory, generation, _carry));
			}
			catch (Exception ex)
			{
				_log.LogError((object)$"module {name}: cannot start: {ex}");
				try
				{
					module.Stop();
				}
				catch (Exception arg)
				{
					_log.LogError((object)$"module {name}: stop after failure: {arg}");
				}
				val.UnpatchSelf();
				message = "module " + name + " failed to load: " + ex.GetType().Name + ": " + ex.Message;
				return false;
			}
			_module = module;
			_harmony = val;
			_name = name;
			_updateFailed = false;
			message = "module " + name + " loaded";
			return true;
		}

		private void StopCurrent()
		{
			if (_module == null)
			{
				return;
			}
			try
			{
				_module.Stop();
			}
			catch (Exception arg)
			{
				_log.LogError((object)$"module {_name}: stop: {arg}");
			}
			_harmony.UnpatchSelf();
			_module = null;
			_harmony = null;
			try
			{
				Stopped?.Invoke();
			}
			catch (Exception arg2)
			{
				_log.LogError((object)$"module {_name}: after stop: {arg2}");
			}
		}

		private int GhostPatches()
		{
			int num = 0;
			foreach (MethodBase allPatchedMethod in Harmony.GetAllPatchedMethods())
			{
				foreach (string owner in Harmony.GetPatchInfo(allPatchedMethod).Owners)
				{
					if (owner.StartsWith(_harmonyPrefix, StringComparison.Ordinal) && (_harmony == null || owner != _harmony.Id))
					{
						num++;
					}
				}
			}
			return num;
		}
	}
	public static class ModuleBridge
	{
		public static void Attach(IModule module)
		{
			if (ModuleHost.Current == null)
			{
				throw new InvalidOperationException("the base plugin of this module is not loaded");
			}
			ModuleHost.Current.Attach(module, out var _);
		}
	}
	public static class ModuleWorld
	{
		private static readonly FieldRef<ZNetScene, Dictionary<int, GameObject>> NamedPrefabs = AccessTools.FieldRefAccess<ZNetScene, Dictionary<int, GameObject>>("m_namedPrefabs");

		private static readonly FieldRef<ZNetScene, Dictionary<ZDO, ZNetView>> Instances = AccessTools.FieldRefAccess<ZNetScene, Dictionary<ZDO, ZNetView>>("m_instances");

		private static readonly FieldInfo Commands = AccessTools.Field(typeof(Terminal), "commands");

		public static void RegisterPrefab(ZNetScene scene, GameObject template)
		{
			int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)template).name);
			Dictionary<int, GameObject> obj = NamedPrefabs.Invoke(scene);
			if (obj.TryGetValue(stableHashCode, out var value) && (Object)(object)value != (Object)null && (Object)(object)value != (Object)(object)template)
			{
				scene.m_prefabs.Remove(value);
				DestroyTemplate(value);
			}
			if (!scene.m_prefabs.Contains(template))
			{
				scene.m_prefabs.Add(template);
			}
			obj[stableHashCode] = template;
		}

		public static void Release(ZNetView view)
		{
			if ((Object)(object)view == (Object)null)
			{
				return;
			}
			ZDO zDO = view.GetZDO();
			if (zDO != null)
			{
				view.ResetZDO();
				if (Object.op_Implicit((Object)(object)ZNetScene.instance))
				{
					Instances.Invoke(ZNetScene.instance).Remove(zDO);
				}
			}
			Object.Destroy((Object)(object)((Component)view).gameObject);
		}

		public static int ReleaseOthers(int prefabHash, Type component)
		{
			if (!Object.op_Implicit((Object)(object)ZNetScene.instance))
			{
				return 0;
			}
			List<ZNetView> list = new List<ZNetView>();
			foreach (ZNetView value in Instances.Invoke(ZNetScene.instance).Values)
			{
				if ((Object)(object)value != (Object)null && value.GetZDO() != null && value.GetZDO().GetPrefab() == prefabHash && (Object)(object)((Component)value).GetComponent(component) == (Object)null)
				{
					list.Add(value);
				}
			}
			foreach (ZNetView item in list)
			{
				Release(item);
			}
			return list.Count;
		}

		public static void RemoveCommand(string name)
		{
			(Commands.GetValue(null) as Dictionary<string, ConsoleCommand>)?.Remove(name.ToLowerInvariant());
		}

		private static void DestroyTemplate(GameObject template)
		{
			Transform parent = template.transform.parent;
			Object.Destroy((Object)(object)template);
			if ((Object)(object)parent != (Object)null && parent.childCount == 1)
			{
				Object.Destroy((Object)(object)((Component)parent).gameObject);
			}
		}
	}
}
namespace LeviathanAxe
{
	[BepInPlugin("grogui.LeviathanAxe", "LeviathanAxe", "1.0.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	internal sealed class LeviathanAxePlugin : BaseUnityPlugin
	{
		internal const string PluginGuid = "grogui.LeviathanAxe";

		internal const string PluginName = "LeviathanAxe";

		internal const string PluginVersion = "1.0.3";

		private const string ModuleFile = "LeviathanAxe.Module.dll";

		private ModuleHost _module;

		private void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			Settings.Bind(((BaseUnityPlugin)this).Config);
			PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailable;
			Log.Info("LeviathanAxe 1.0.3 loaded.");
			_module = new ModuleHost("grogui.LeviathanAxe", "LeviathanAxe.Module.dll", ((BaseUnityPlugin)this).Logger, ((BaseUnityPlugin)this).Config, Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location));
		}

		private void OnVanillaPrefabsAvailable()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsAvailable;
			ContentFactory.Create();
		}

		private void Update()
		{
			_module?.Update();
		}

		private void OnDestroy()
		{
			_module?.Stop();
			PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsAvailable;
			ContentFactory.Unbind();
		}
	}
	internal static class Log
	{
		private static ManualLogSource _source;

		private static readonly HashSet<string> Reported = new HashSet<string>();

		internal static void Init(ManualLogSource source)
		{
			_source = source;
		}

		internal static void Info(string message)
		{
			ManualLogSource source = _source;
			if (source != null)
			{
				source.LogInfo((object)message);
			}
		}

		internal static void Warning(string message)
		{
			ManualLogSource source = _source;
			if (source != null)
			{
				source.LogWarning((object)message);
			}
		}

		internal static void WarnOnce(string key, string message)
		{
			if (Reported.Add("w:" + key))
			{
				ManualLogSource source = _source;
				if (source != null)
				{
					source.LogWarning((object)message);
				}
			}
		}

		internal static void Error(string message)
		{
			ManualLogSource source = _source;
			if (source != null)
			{
				source.LogError((object)message);
			}
		}

		internal static void ErrorOnce(string key, Exception error)
		{
			if (Reported.Add("e:" + key))
			{
				ManualLogSource source = _source;
				if (source != null)
				{
					source.LogError((object)$"[{key}] {error}");
				}
			}
		}
	}
	public static class Settings
	{
		public static ConfigEntry<float> ThrowSpeed;

		public static ConfigEntry<float> ThrowDamageMultiplier;

		public static ConfigEntry<float> MaxFlightDistance;

		public static ConfigEntry<float> ChargedThrowDamageMultiplier;

		public static ConfigEntry<float> ReturnSpeed;

		public static ConfigEntry<float> CurveAmount;

		public static ConfigEntry<float> ReturnDamageMultiplier;

		public static ConfigEntry<float> FreezeDuration;

		public static ConfigEntry<int> FreezeThreshold;

		public static ConfigEntry<bool> FreezeBosses;

		public static ConfigEntry<bool> RecallWithHideKey;

		public static ConfigEntry<bool> RecallWithSecondaryAttack;

		public static ConfigEntry<KeyboardShortcut> RecallKey;

		public static ConfigEntry<bool> AutoEquipOnCatch;

		public static ConfigEntry<bool> GlowPulse;

		internal static void Bind(ConfigFile config)
		{
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			ThrowSpeed = config.Bind<float>("1. Throw", "ThrowSpeed", 40f, ServerRule("Speed of the thrown axe, in meters per second.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 100f)));
			ThrowDamageMultiplier = config.Bind<float>("1. Throw", "ThrowDamageMultiplier", 1f, ServerRule("Damage of a horizontal throw, relative to the axe's damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f)));
			ChargedThrowDamageMultiplier = config.Bind<float>("1. Throw", "ChargedThrowDamageMultiplier", 2f, ServerRule("Damage of a vertical throw, relative to a horizontal one. The secondary attack still held when the arm has pulled back throws the axe vertically: it sticks in creatures. Released sooner, it throws it horizontally: it bounces off creatures.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 5f)));
			MaxFlightDistance = config.Bind<float>("1. Throw", "MaxFlightDistance", 45f, ServerRule("Beyond this distance without hitting anything, the axe drops to the ground.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 200f)));
			ReturnSpeed = config.Bind<float>("2. Recall", "ReturnSpeed", 35f, ServerRule("Speed of the axe coming back, in meters per second: from d meters away, the trip lasts (2.5 + d) / speed seconds, 1.5 seconds at most.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 100f)));
			CurveAmount = config.Bind<float>("2. Recall", "CurveAmount", 1f, ServerRule("How far the returning axe swings out to the right: 1 is the usual curve, wider the farther it comes from; 0 brings it back almost straight.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f)));
			ReturnDamageMultiplier = config.Bind<float>("2. Recall", "ReturnDamageMultiplier", 0.5f, ServerRule("Damage dealt to enemies crossed by the returning axe, relative to a throw. 0 disables it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f)));
			FreezeDuration = config.Bind<float>("3. Freeze", "FreezeDuration", 4f, ServerRule("Seconds a creature stays frozen. 0 disables freezing.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f)));
			FreezeThreshold = config.Bind<int>("3. Freeze", "FreezeThreshold", 3, ServerRule("Frost that freezes a creature: a horizontal throw adds 1, a vertical one 2, and the hit that reaches this value freezes it. The frost fades when the creature has not been hit for 6 seconds. 1 freezes on every hit.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10)));
			FreezeBosses = config.Bind<bool>("3. Freeze", "FreezeBosses", false, ServerRule("Also freeze bosses."));
			RecallWithHideKey = config.Bind<bool>("4. Controls", "RecallWithHideKey", true, "The game's Hide key (R by default), which normally draws or sheathes weapons, recalls the thrown axe instead.");
			RecallWithSecondaryAttack = config.Bind<bool>("4. Controls", "RecallWithSecondaryAttack", true, "The secondary attack, with an empty right hand, recalls the thrown axe.");
			RecallKey = config.Bind<KeyboardShortcut>("4. Controls", "RecallKey", new KeyboardShortcut((KeyCode)0, Array.Empty<KeyCode>()), "An extra key that recalls the thrown axe. Empty by default.");
			AutoEquipOnCatch = config.Bind<bool>("4. Controls", "AutoEquipOnCatch", true, "The caught axe goes back in hand when the right hand is free. Recalling with the Hide key or the axe's hotbar slot always does.");
			GlowPulse = config.Bind<bool>("5. Look", "GlowPulse", true, "The runes on the blade glow, slowly breathing, and cast a blue light on the one holding the axe. Only changes what you see.");
		}

		private static ConfigDescription ServerRule(string description, AcceptableValueBase range = null)
		{
			//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)
			//IL_0017: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			return new ConfigDescription(description, range, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} });
		}
	}
}
namespace LeviathanAxe.Throwing
{
	public interface IThrowHandler
	{
		void Launch(ThrownAxeRelay relay, Character owner, Vector3 velocity, float hitNoise, HitData hitData, ItemData item);
	}
	public sealed class ThrownAxeRelay : MonoBehaviour, IProjectile
	{
		public Transform m_pivot;

		public Vector3 m_center;

		public Vector3 m_edge;

		public Transform m_model;

		public MeleeWeaponTrail m_trail;

		public ParticleSystem m_sparks;

		public Light m_light;

		public static IThrowHandler Handler { get; set; }

		public string GetTooltipString(int itemQuality)
		{
			return "";
		}

		public void Setup(Character owner, Vector3 velocity, float hitNoise, HitData hitData, ItemData item, ItemData ammo)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (Handler == null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			try
			{
				Handler.Launch(this, owner, velocity, hitNoise, hitData, item);
			}
			catch (Exception error)
			{
				Log.ErrorOnce("ThrownAxeRelay.Setup", error);
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
}
namespace LeviathanAxe.Freeze
{
	public interface IFreeze
	{
		bool CanFreeze(Character character);

		void Begin(Character character, float duration);

		void Hold(Character character);

		void End(Character character);

		void Forget(Character character);
	}
	public sealed class FrozenEffect : StatusEffect
	{
		public const string EffectName = "LeviathanAxe_Frozen";

		public static readonly int Hash = StringExtensionMethods.GetStableHashCode("LeviathanAxe_Frozen");

		private static FrozenEffect _prototype;

		public static IFreeze Logic { get; set; }

		internal static void Register()
		{
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			FrozenEffect frozenEffect = ScriptableObject.CreateInstance<FrozenEffect>();
			((Object)frozenEffect).name = "LeviathanAxe_Frozen";
			((StatusEffect)frozenEffect).m_name = "$leviathanaxe_frozen";
			((StatusEffect)frozenEffect).m_category = "";
			((StatusEffect)frozenEffect).m_tooltip = "";
			((StatusEffect)frozenEffect).m_startMessage = "";
			((StatusEffect)frozenEffect).m_stopMessage = "";
			((StatusEffect)frozenEffect).m_repeatMessage = "";
			((StatusEffect)frozenEffect).m_ttl = Settings.FreezeDuration.Value;
			StatusEffect prefab = Cache.GetPrefab<StatusEffect>("Frost");
			if ((Object)(object)prefab != (Object)null)
			{
				((StatusEffect)frozenEffect).m_icon = prefab.m_icon;
				((StatusEffect)frozenEffect).m_startEffects = (EffectList)(((object)prefab.m_startEffects) ?? ((object)new EffectList()));
				((StatusEffect)frozenEffect).m_stopEffects = (EffectList)(((object)prefab.m_stopEffects) ?? ((object)new EffectList()));
			}
			else
			{
				Log.Warning("Status effect \"Frost\" not found: frozen creatures get no frost particles.");
			}
			_prototype = frozenEffect;
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)frozenEffect, false));
		}

		internal static void ApplyDuration()
		{
			if ((Object)(object)_prototype != (Object)null)
			{
				((StatusEffect)_prototype).m_ttl = Settings.FreezeDuration.Value;
			}
		}

		public override bool CanAdd(Character character)
		{
			if (Logic != null)
			{
				return Logic.CanFreeze(character);
			}
			return false;
		}

		public override void Setup(Character character)
		{
			((StatusEffect)this).Setup(character);
			Logic?.Begin(character, base.m_ttl);
		}

		public override void ResetTime()
		{
			((StatusEffect)this).ResetTime();
			if ((Object)(object)base.m_character != (Object)null)
			{
				Logic?.Begin(base.m_character, base.m_ttl);
			}
		}

		public override void UpdateStatusEffect(float dt)
		{
			((StatusEffect)this).UpdateStatusEffect(dt);
			Logic?.Hold(base.m_character);
		}

		public override void Stop()
		{
			((StatusEffect)this).Stop();
			Logic?.End(base.m_character);
		}

		public override void OnDestroy()
		{
			((StatusEffect)this).OnDestroy();
			Logic?.Forget(base.m_character);
		}

		public override void ModifySpeed(float baseSpeed, ref float speed, Character character, Vector3 dir)
		{
			speed = 0f;
		}
	}
}
namespace LeviathanAxe.Content
{
	public static class ContentFactory
	{
		private static bool _bound;

		public static bool Ready { get; private set; }

		public static event Action Created;

		internal static void Create()
		{
			try
			{
				FrozenEffect.Register();
				GameObject val = LeviathanItem.Create();
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				GameObject thrownPrefab = ThrownAxePrefab.Create(val);
				LeviathanItem.Register(val, thrownPrefab);
				LeviathanItem.CreateRecipe(val);
				Settings.FreezeDuration.SettingChanged += OnFreezeDurationChanged;
				_bound = true;
				Log.Info("Leviathan created.");
			}
			catch (Exception arg)
			{
				Log.Error($"The Leviathan could not be created: {arg}");
				return;
			}
			Ready = true;
			try
			{
				ContentFactory.Created?.Invoke();
			}
			catch (Exception arg2)
			{
				Log.Error($"The module could not settle on the Leviathan: {arg2}");
			}
		}

		internal static void Unbind()
		{
			if (_bound)
			{
				Settings.FreezeDuration.SettingChanged -= OnFreezeDurationChanged;
				_bound = false;
			}
		}

		private static void OnFreezeDurationChanged(object sender, EventArgs args)
		{
			FrozenEffect.ApplyDuration();
		}
	}
	internal static class IconRenderer
	{
		private const int Size = 128;

		private static readonly Quaternion Rotation;

		internal static Sprite Render(GameObject itemPrefab, int size = 128)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_0046: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			Transform val = itemPrefab.transform.Find("attach");
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			GameObject val2 = new GameObject("LeviathanAxeIcon");
			bool fog = RenderSettings.fog;
			try
			{
				GameObject val3 = Object.Instantiate<GameObject>(((Component)val).gameObject, val2.transform, false);
				val3.transform.localPosition = Vector3.zero;
				val3.transform.localRotation = Quaternion.identity;
				val3.SetActive(true);
				ParticleSystem[] componentsInChildren = val3.GetComponentsInChildren<ParticleSystem>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					((Component)componentsInChildren[i]).gameObject.SetActive(false);
				}
				Light[] componentsInChildren2 = val3.GetComponentsInChildren<Light>(true);
				for (int i = 0; i < componentsInChildren2.Length; i++)
				{
					((Behaviour)componentsInChildren2[i]).enabled = false;
				}
				RenderSettings.fog = false;
				return RenderManager.Instance.Render(new RenderRequest(val2)
				{
					Rotation = Rotation,
					Width = size,
					Height = size,
					UseCache = false
				});
			}
			catch (Exception arg)
			{
				Log.Warning(string.Format("Icon of \"{0}\" could not be rendered: {1}", "LeviathanAxe", arg));
				return null;
			}
			finally
			{
				RenderSettings.fog = fog;
				Object.DestroyImmediate((Object)(object)val2);
			}
		}

		static IconRenderer()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0026: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = new Vector3(-1f, 1f, 0f);
			Rotation = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.forward);
		}
	}
	public static class LeviathanItem
	{
		internal const string PrefabName = "LeviathanAxe";

		internal const string AttachChild = "attach";

		internal const string TrailPath = "equiped/trail";

		internal const string EdgeChild = "edge";

		public const string ModelChild = "Model";

		private const string UpgradeGlowChild = "UpgraderGlow";

		public const string HeadChild = "head";

		private static readonly Color RuneEmission = Color.black;

		private const string EmissionKeyword = "_EMISSION";

		private static readonly int MainTex = Shader.PropertyToID("_MainTex");

		private static readonly int EmissionMap = Shader.PropertyToID("_EmissionMap");

		private static readonly int EmissionColor = Shader.PropertyToID("_EmissionColor");

		private static readonly int MetallicGlossMap = Shader.PropertyToID("_MetallicGlossMap");

		private static readonly int BumpMap = Shader.PropertyToID("_BumpMap");

		public static GameObject Prefab { get; private set; }

		public static bool Is(ItemData item)
		{
			if (item?.m_shared != null)
			{
				return item.m_shared.m_name == "$leviathanaxe_name";
			}
			return false;
		}

		internal static GameObject Create()
		{
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("LeviathanAxe", "AxeGold");
			if ((Object)(object)val == (Object)null)
			{
				Log.Error("Vanilla prefab \"AxeGold\" not found: the Leviathan was not created.");
				return null;
			}
			ApplyStats(val.GetComponent<ItemDrop>().m_itemData);
			ApplyLook(val);
			Prefab = val;
			return val;
		}

		internal static void Register(GameObject prefab, GameObject thrownPrefab)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			SharedData shared = prefab.GetComponent<ItemDrop>().m_itemData.m_shared;
			Attack val = ThrowAttack(thrownPrefab);
			if (val != null)
			{
				shared.m_secondaryAttack = val;
			}
			if (!GUIManager.IsHeadless())
			{
				Sprite val2 = IconRenderer.Render(prefab);
				if ((Object)(object)val2 != (Object)null)
				{
					shared.m_icons = (Sprite[])(object)new Sprite[1] { val2 };
				}
				else
				{
					Log.Warning("Icon of \"LeviathanAxe\" not rendered: it keeps the one of \"AxeGold\".");
				}
			}
			ItemManager.Instance.AddItem(new CustomItem(prefab, false));
		}

		private static void ApplyStats(ItemData item)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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)
			SharedData shared = item.m_shared;
			shared.m_name = "$leviathanaxe_name";
			shared.m_description = "$leviathanaxe_desc";
			shared.m_damages = new DamageTypes
			{
				m_slash = 70f,
				m_chop = 55f,
				m_frost = 35f
			};
			shared.m_damagesPerLevel = new DamageTypes
			{
				m_slash = 6f,
				m_chop = 3f,
				m_frost = 4f
			};
			shared.m_toolTier = 3;
			shared.m_maxQuality = 4;
			shared.m_maxDurability = 200f;
			shared.m_durabilityPerLevel = 50f;
			item.m_durability = shared.m_maxDurability;
			shared.m_blockPower = 30f;
			shared.m_attackForce = 50f;
			shared.m_value = 0;
			shared.m_attack.m_attackStamina = 12f;
		}

		private static void ApplyLook(GameObject prefab)
		{
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			Transform val = prefab.transform.Find("attach");
			Transform val2 = (((Object)(object)val == (Object)null) ? null : val.Find("Model"));
			MeshFilter val3 = (((Object)(object)val2 == (Object)null) ? null : ((Component)val2).GetComponent<MeshFilter>());
			Renderer val4 = (((Object)(object)val2 == (Object)null) ? null : ((Component)val2).GetComponent<Renderer>());
			GameObject prefab2 = PrefabManager.Instance.GetPrefab("AxeGold_FrostFire");
			Transform val5 = (((Object)(object)prefab2 == (Object)null) ? null : prefab2.transform.Find("attach/Model"));
			Renderer val6 = (((Object)(object)val5 == (Object)null) ? null : ((Component)val5).GetComponent<Renderer>());
			if ((Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null || (Object)(object)val6 == (Object)null || (Object)(object)val6.sharedMaterial == (Object)null)
			{
				Log.Warning("Model of \"AxeGold\" or \"AxeGold_FrostFire\" not found: the Leviathan keeps the gold axe's look.");
				return;
			}
			LeviathanModel leviathanModel = LeviathanModel.Load();
			if (leviathanModel != null)
			{
				val2.localPosition = Vector3.zero;
				val2.localRotation = Quaternion.identity;
				val2.localScale = Vector3.one;
				val3.sharedMesh = leviathanModel.Mesh;
				MeshCollider component = ((Component)val2).GetComponent<MeshCollider>();
				if ((Object)(object)component != (Object)null)
				{
					component.convex = true;
					component.sharedMesh = leviathanModel.Mesh;
				}
				Material val7 = new Material(val6.sharedMaterial)
				{
					name = "leviathanaxe_mat"
				};
				val7.SetTexture(MainTex, (Texture)(object)leviathanModel.Albedo);
				val7.SetTexture(EmissionMap, (Texture)(object)leviathanModel.Emission);
				val7.SetColor(EmissionColor, RuneEmission);
				val7.EnableKeyword("_EMISSION");
				val7.SetTexture(MetallicGlossMap, (Texture)(object)leviathanModel.MetalGloss);
				val7.SetTexture(BumpMap, (Texture)(object)leviathanModel.FlatNormal);
				val4.sharedMaterial = val7;
				Transform val8 = val.Find("equiped/trail");
				Transform val9 = (((Object)(object)val8 == (Object)null) ? null : val8.Find("base"));
				Transform val10 = (((Object)(object)val8 == (Object)null) ? null : val8.Find("tip"));
				if ((Object)(object)val9 != (Object)null && (Object)(object)val10 != (Object)null)
				{
					val9.localPosition = leviathanModel.EdgeBase;
					val10.localPosition = leviathanModel.EdgeTip;
				}
				else
				{
					Log.Warning("Trail of \"AxeGold\" not found: the Leviathan swings without one.");
				}
				FitUpgradeGlow(val, leviathanModel);
				Transform transform = new GameObject("edge").transform;
				transform.SetParent(val, false);
				transform.localPosition = leviathanModel.EdgeFront;
				Transform transform2 = new GameObject("head").transform;
				transform2.SetParent(val, false);
				transform2.localPosition = leviathanModel.HeadCenter;
			}
		}

		private static void FitUpgradeGlow(Transform attach, LeviathanModel look)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			Transform val = attach.Find("UpgraderGlow");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			ParticleSystem[] componentsInChildren = ((Component)val).GetComponentsInChildren<ParticleSystem>(true);
			foreach (ParticleSystem val2 in componentsInChildren)
			{
				ShapeModule shape = val2.shape;
				if ((int)((ShapeModule)(ref shape)).shapeType == 6)
				{
					((ShapeModule)(ref shape)).mesh = look.Mesh;
					((Component)val2).transform.localPosition = Vector3.zero;
					((Component)val2).transform.localRotation = Quaternion.identity;
					((Component)val2).transform.localScale = Vector3.one;
				}
			}
			Light[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<Light>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				((Component)componentsInChildren2[i]).transform.localPosition = new Vector3(look.EdgeFront.x * 0.5f, 0f, look.EdgeFront.z);
			}
		}

		private static Attack ThrowAttack(GameObject thrownPrefab)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Invalid comparison between Unknown and I4
			GameObject prefab = PrefabManager.Instance.GetPrefab("SpearBronze");
			Attack val = (((Object)(object)prefab == (Object)null) ? null : prefab.GetComponent<ItemDrop>()?.m_itemData.m_shared.m_secondaryAttack);
			if (val == null || (int)val.m_attackType != 2 || (Object)(object)thrownPrefab == (Object)null)
			{
				Log.Error("Throw of \"SpearBronze\" not found: the Leviathan cannot be thrown.");
				return null;
			}
			Attack obj = val.Clone();
			obj.m_attackProjectile = thrownPrefab;
			obj.m_consumeItem = false;
			obj.m_attackStamina = 14f;
			obj.m_damageMultiplier = 1f;
			obj.m_projectileVel = 40f;
			obj.m_projectileVelMin = 40f;
			obj.m_randomVelocity = false;
			obj.m_projectileAccuracy = 0f;
			obj.m_projectileAccuracyMin = 0f;
			obj.m_skillAccuracy = false;
			obj.m_requiresReload = false;
			obj.m_bowDraw = false;
			obj.m_destroyPreviousProjectile = false;
			obj.m_projectiles = 1;
			obj.m_projectileBursts = 1;
			return obj;
		}

		internal static void CreateRecipe(GameObject prefab)
		{
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			GameObject prefab2 = PrefabManager.Instance.GetPrefab("forge");
			CraftingStation val = ((prefab2 != null) ? prefab2.GetComponent<CraftingStation>() : null);
			if ((Object)(object)val == (Object)null)
			{
				Log.Error("Crafting station \"forge\" not found: the Leviathan cannot be crafted.");
				return;
			}
			List<Requirement> list = new List<Requirement>();
			if (!(AddRequirement(list, "Silver", 20, 10, recover: true, upgrader: false) & AddRequirement(list, "Iron", 10, 5, recover: true, upgrader: false) & AddRequirement(list, "FreezeGland", 8, 2, recover: true, upgrader: false) & AddRequirement(list, "ElderBark", 5, 0, recover: true, upgrader: false)))
			{
				Log.Error("An ingredient of the Leviathan was not found: it cannot be crafted.");
				return;
			}
			if (!AddRequirement(list, "Upgrader3Weapon", 1, 0, recover: false, upgrader: true))
			{
				Log.Warning("\"Upgrader3Weapon\" not found: the Leviathan cannot be upgraded at an upgrade station.");
			}
			Recipe val2 = ScriptableObject.CreateInstance<Recipe>();
			((Object)val2).name = "Recipe_LeviathanAxe";
			val2.m_item = prefab.GetComponent<ItemDrop>();
			val2.m_amount = 1;
			val2.m_enabled = true;
			val2.m_qualityResultAmountMultiplier = 1f;
			val2.m_listSortWeight = 100;
			val2.m_noCraftOnlyUpgrade = false;
			val2.m_craftingStation = val;
			val2.m_repairStation = null;
			val2.m_minStationLevel = 3;
			val2.m_requireOnlyOneIngredient = false;
			val2.m_resources = list.ToArray();
			if (!ItemManager.Instance.AddRecipe(new CustomRecipe(val2, false, false)))
			{
				Log.Error("Recipe of the Leviathan refused by Jotunn: it cannot be crafted.");
			}
		}

		private static bool AddRequirement(List<Requirement> requirements, string itemName, int amount, int perLevel, bool recover, bool upgrader)
		{
			//IL_0039: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			GameObject prefab = PrefabManager.Instance.GetPrefab(itemName);
			ItemDrop val = ((prefab != null) ? prefab.GetComponent<ItemDrop>() : null);
			if ((Object)(object)val == (Object)null)
			{
				Log.Warning("Ingredient \"" + itemName + "\" not found.");
				return false;
			}
			requirements.Add(new Requirement
			{
				m_resItem = val,
				m_amount = amount,
				m_extraAmountOnlyOneIngredient = 0,
				m_amountPerLevel = perLevel,
				m_upgraderResource = upgrader,
				m_recover = recover
			});
			return true;
		}
	}
	internal sealed class LeviathanModel
	{
		[Serializable]
		private sealed class MeshData
		{
			[SerializeField]
			internal float[] positions;

			[SerializeField]
			internal float[] normals;

			[SerializeField]
			internal float[] uvs;

			[SerializeField]
			internal int[] triangles;

			[SerializeField]
			internal float[] edgeBase;

			[SerializeField]
			internal float[] edgeTip;

			[SerializeField]
			internal float[] edgeFront;
		}

		private const string MeshResource = "leviathan_mesh.json";

		private const string AlbedoResource = "leviathan_albedo.png";

		private const string EmissionResource = "leviathan_emission.png";

		private const string MetalGlossResource = "leviathan_metalgloss.png";

		private static readonly MethodInfo LoadImage = typeof(ImageConversion).GetMethod("LoadImage", new Type[3]
		{
			typeof(Texture2D),
			typeof(byte[]),
			typeof(bool)
		});

		internal Mesh Mesh { get; private set; }

		internal Texture2D Albedo { get; private set; }

		internal Texture2D Emission { get; private set; }

		internal Texture2D MetalGloss { get; private set; }

		internal Texture2D FlatNormal { get; private set; }

		internal Vector3 EdgeBase { get; private set; }

		internal Vector3 EdgeTip { get; private set; }

		internal Vector3 EdgeFront { get; private set; }

		internal Vector3 HeadCenter { get; private set; }

		internal static LeviathanModel Load()
		{
			//IL_0091: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				MeshData data;
				Mesh val = LoadMesh(out data);
				Texture2D val2 = LoadTexture("leviathan_albedo.png", linear: false, (FilterMode)0);
				Texture2D val3 = LoadTexture("leviathan_emission.png", linear: false, (FilterMode)0);
				Texture2D val4 = LoadTexture("leviathan_metalgloss.png", linear: false, (FilterMode)1);
				if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null)
				{
					return null;
				}
				return new LeviathanModel
				{
					Mesh = val,
					Albedo = val2,
					Emission = val3,
					MetalGloss = val4,
					FlatNormal = FlatNormalMap(),
					EdgeBase = ToVector(data.edgeBase),
					EdgeTip = ToVector(data.edgeTip),
					EdgeFront = ToVector(data.edgeFront),
					HeadCenter = HeadCenterOf(val.vertices, data.edgeBase[2])
				};
			}
			catch (Exception arg)
			{
				Log.Error($"The Leviathan model could not be loaded: {arg}");
				return null;
			}
		}

		private static Mesh LoadMesh(out MeshData data)
		{
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Expected O, but got Unknown
			data = null;
			byte[] array = ReadResource("leviathan_mesh.json");
			if (array == null)
			{
				return null;
			}
			data = JsonUtility.FromJson<MeshData>(Encoding.UTF8.GetString(array));
			int num = data.positions.Length / 3;
			if (data.positions.Length != num * 3 || data.normals.Length != num * 3 || data.uvs.Length != num * 2 || data.triangles.Length % 3 != 0 || data.edgeBase.Length != 3 || data.edgeTip.Length != 3 || data.edgeFront.Length != 3)
			{
				Log.Error("\"leviathan_mesh.json\" is malformed: the Leviathan keeps the gold axe's model.");
				return null;
			}
			Vector3[] array2 = (Vector3[])(object)new Vector3[num];
			Vector3[] array3 = (Vector3[])(object)new Vector3[num];
			Vector2[] array4 = (Vector2[])(object)new Vector2[num];
			for (int i = 0; i < num; i++)
			{
				array2[i] = new Vector3(data.positions[3 * i], data.positions[3 * i + 1], data.positions[3 * i + 2]);
				array3[i] = new Vector3(data.normals[3 * i], data.normals[3 * i + 1], data.normals[3 * i + 2]);
				array4[i] = new Vector2(data.uvs[2 * i], data.uvs[2 * i + 1]);
			}
			int[] triangles = data.triangles;
			foreach (int num2 in triangles)
			{
				if (num2 < 0 || num2 >= num)
				{
					Log.Error("\"leviathan_mesh.json\" has a triangle out of its vertices: the Leviathan keeps the gold axe's model.");
					return null;
				}
			}
			Mesh val = new Mesh
			{
				name = "leviathanaxe",
				vertices = array2,
				normals = array3,
				uv = array4,
				triangles = data.triangles
			};
			val.RecalculateBounds();
			val.RecalculateTangents();
			return val;
		}

		private static Texture2D LoadTexture(string resource, bool linear, FilterMode filter)
		{
			//IL_0011: 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_0023: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			byte[] array = ReadResource(resource);
			if (array == null)
			{
				return null;
			}
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, linear)
			{
				name = Path.GetFileNameWithoutExtension(resource)
			};
			if (LoadImage == null || !(bool)LoadImage.Invoke(null, new object[3] { val, array, true }))
			{
				Log.Error("\"" + resource + "\" could not be decoded: the Leviathan keeps the gold axe's model.");
				Object.Destroy((Object)(object)val);
				return null;
			}
			((Texture)val).filterMode = filter;
			((Texture)val).wrapMode = (TextureWrapMode)1;
			return val;
		}

		private static Texture2D FlatNormalMap()
		{
			//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_0016: Expected O, but got Unknown
			//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)
			Texture2D val = new Texture2D(4, 4, (TextureFormat)4, false, true)
			{
				name = "leviathan_normal"
			};
			Color32[] array = (Color32[])(object)new Color32[16];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = new Color32((byte)128, (byte)128, byte.MaxValue, byte.MaxValue);
			}
			val.SetPixels32(array);
			val.Apply(false, true);
			return val;
		}

		private static byte[] ReadResource(string name)
		{
			using Stream stream = typeof(LeviathanModel).Assembly.GetManifestResourceStream(name);
			if (stream == null)
			{
				Log.Error("\"" + name + "\" is missing from the mod: the Leviathan keeps the gold axe's model.");
				return null;
			}
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			return memoryStream.ToArray();
		}

		private static Vector3 HeadCenterOf(Vector3[] vertices, float bottom)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			Bounds val = default(Bounds);
			foreach (Vector3 val2 in vertices)
			{
				if (!(val2.z < bottom))
				{
					if (!flag)
					{
						((Bounds)(ref val))..ctor(val2, Vector3.zero);
						flag = true;
					}
					else
					{
						((Bounds)(ref val)).Encapsulate(val2);
					}
				}
			}
			return ((Bounds)(ref val)).center;
		}

		private static Vector3 ToVector(float[] values)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(values[0], values[1], values[2]);
		}
	}
	public static class ThrownAxePrefab
	{
		internal const string PrefabName = "LeviathanAxe_thrown";

		private const string SparksChild = "sparcs_world";

		private const string LightChild = "Point light";

		private static GameObject _container;

		public static GameObject Prefab { get; private set; }

		internal static GameObject Create(GameObject itemPrefab)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: 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_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: 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)
			Transform val = itemPrefab.transform.Find("attach");
			if ((Object)(object)val == (Object)null)
			{
				Log.Error("\"LeviathanAxe\" has no \"attach\" model: the axe cannot be thrown.");
				return null;
			}
			GameObject val2 = new GameObject("LeviathanAxe_thrown");
			val2.transform.SetParent(Container(), false);
			GameObject val3 = new GameObject("pivot");
			val3.transform.SetParent(val2.transform, false);
			GameObject val4 = Object.Instantiate<GameObject>(((Component)val).gameObject, val3.transform, false);
			((Object)val4).name = "model";
			val4.SetActive(true);
			Collider[] componentsInChildren = val4.GetComponentsInChildren<Collider>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
			}
			Transform val5 = val4.transform.Find("equiped");
			if ((Object)(object)val5 != (Object)null)
			{
				((Component)val5).gameObject.SetActive(true);
			}
			Vector3 val6 = ModelCenter(val4.transform);
			Vector3 val7 = BladeEdge(val4.transform, val6);
			val4.transform.localPosition = -val6;
			val4.transform.localRotation = Quaternion.identity;
			BorrowFrostSparks(val2.transform);
			ThrownAxeRelay thrownAxeRelay = val2.AddComponent<ThrownAxeRelay>();
			thrownAxeRelay.m_pivot = val3.transform;
			thrownAxeRelay.m_center = val6;
			thrownAxeRelay.m_edge = val7 - val6;
			thrownAxeRelay.m_model = val4.transform.Find("Model");
			Transform obj = val4.transform.Find("equiped/trail");
			thrownAxeRelay.m_trail = ((obj != null) ? ((Component)obj).GetComponent<MeleeWeaponTrail>() : null);
			Transform obj2 = val2.transform.Find("sparcs_world");
			thrownAxeRelay.m_sparks = ((obj2 != null) ? ((Component)obj2).GetComponent<ParticleSystem>() : null);
			Transform obj3 = val2.transform.Find("Point light");
			thrownAxeRelay.m_light = ((obj3 != null) ? ((Component)obj3).GetComponent<Light>() : null);
			Prefab = val2;
			return val2;
		}

		private static Transform Container()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			if ((Object)(object)_container == (Object)null)
			{
				_container = new GameObject("LeviathanAxe_Prefabs");
				_container.SetActive(false);
				Object.DontDestroyOnLoad((Object)(object)_container);
			}
			return _container.transform;
		}

		private static Vector3 ModelCenter(Transform model)
		{
			//IL_0004: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			Bounds val = default(Bounds);
			MeshFilter[] componentsInChildren = ((Component)model).GetComponentsInChildren<MeshFilter>(true);
			Vector3 val4 = default(Vector3);
			foreach (MeshFilter val2 in componentsInChildren)
			{
				if ((Object)(object)val2.sharedMesh == (Object)null)
				{
					continue;
				}
				Bounds bounds = val2.sharedMesh.bounds;
				Matrix4x4 val3 = model.worldToLocalMatrix * ((Component)val2).transform.localToWorldMatrix;
				for (int j = 0; j < 8; j++)
				{
					((Vector3)(ref val4))..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 val5 = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(val4);
					if (!flag)
					{
						((Bounds)(ref val))..ctor(val5, Vector3.zero);
						flag = true;
					}
					else
					{
						((Bounds)(ref val)).Encapsulate(val5);
					}
				}
			}
			if (!flag)
			{
				return Vector3.zero;
			}
			return ((Bounds)(ref val)).center;
		}

		private static Vector3 BladeEdge(Transform model, Vector3 center)
		{
			//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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			Transform val = model.Find("edge");
			if ((Object)(object)val != (Object)null)
			{
				return model.InverseTransformPoint(val.position);
			}
			Transform val2 = model.Find("equiped/trail");
			Transform val3 = (((Object)(object)val2 != (Object)null) ? val2.Find("base") : null);
			Transform val4 = (((Object)(object)val2 != (Object)null) ? val2.Find("tip") : null);
			if ((Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null)
			{
				return model.InverseTransformPoint((val3.position + val4.position) * 0.5f);
			}
			Log.Warning("Blade of the Leviathan not found: the axe will stick by its center.");
			return center;
		}

		private static void BorrowFrostSparks(Transform root)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = PrefabManager.Instance.GetPrefab("bow_projectile_frost");
			if ((Object)(object)prefab == (Object)null)
			{
				Log.Warning("\"bow_projectile_frost\" not found: the thrown axe has no frost sparks.");
				return;
			}
			string[] array = new string[2] { "sparcs_world", "Point light" };
			foreach (string text in array)
			{
				Transform val = prefab.transform.Find(text);
				if ((Object)(object)val == (Object)null)
				{
					Log.Warning("\"" + text + "\" not found in \"bow_projectile_frost\".");
					continue;
				}
				GameObject obj = Object.Instantiate<GameObject>(((Component)val).gameObject, root, false);
				((Object)obj).name = text;
				obj.transform.localPosition = Vector3.zero;
			}
		}
	}
	public static class Translations
	{
		public const string Name = "$leviathanaxe_name";

		public const string Description = "$leviathanaxe_desc";

		public const string Frozen = "$leviathanaxe_frozen";
	}
	internal static class VanillaPrefabs
	{
		internal const string ModelTemplate = "AxeGold";

		internal const string FrostTemplate = "AxeGold_FrostFire";

		internal const string ThrowTemplate = "SpearBronze";

		internal const string FrostProjectile = "bow_projectile_frost";

		internal const string FrostStatusEffect = "Frost";

		internal const string Forge = "forge";

		internal const string Silver = "Silver";

		internal const string Iron = "Iron";

		internal const string FreezeGland = "FreezeGland";

		internal const string ElderBark = "ElderBark";

		internal const string Upgrader = "Upgrader3Weapon";
	}
}

plugins/LeviathanAxe.Module.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using HotReload;
using Jotunn.Managers;
using LeviathanAxe.Content;
using LeviathanAxe.Freeze;
using LeviathanAxe.Look;
using LeviathanAxe.Throwing;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("LeviathanAxe.Module")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3")]
[assembly: AssemblyProduct("LeviathanAxe")]
[assembly: AssemblyTitle("LeviathanAxe.Module")]
[assembly: AssemblyVersion("1.0.3.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[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 LeviathanAxe
{
	internal static class GameAccess
	{
		internal static readonly FieldRef<Character, ZNetView> CharacterView = AccessTools.FieldRefAccess<Character, ZNetView>("m_nview");

		internal static readonly FieldRef<Character, Animator> CharacterAnimator = AccessTools.FieldRefAccess<Character, Animator>("m_animator");

		internal static readonly FieldRef<Character, Rigidbody> CharacterBody = AccessTools.FieldRefAccess<Character, Rigidbody>("m_body");

		internal static readonly FieldRef<Character, bool> CharacterShown = AccessTools.FieldRefAccess<Character, bool>("m_lodVisible");

		internal static readonly FieldRef<VisEquipment, int> VisibleRightItem = AccessTools.FieldRefAccess<VisEquipment, int>("m_currentRightItemHash");

		internal static readonly FieldRef<VisEquipment, GameObject> RightItemInstance = AccessTools.FieldRefAccess<VisEquipment, GameObject>("m_rightItemInstance");

		internal static readonly FieldRef<Player, float> QueuedSecondaryAttack = AccessTools.FieldRefAccess<Player, float>("m_queuedSecondAttackTimer");

		internal static readonly FieldRef<Character, bool> SecondaryAttackHold = AccessTools.FieldRefAccess<Character, bool>("m_secondaryAttackHold");

		internal static ZDO ZdoOf(Character character)
		{
			if ((Object)(object)character == (Object)null)
			{
				return null;
			}
			ZNetView val = CharacterView.Invoke(character);
			if (!((Object)(object)val != (Object)null) || !val.IsValid())
			{
				return null;
			}
			return val.GetZDO();
		}
	}
	internal sealed class LeviathanModule : IModule
	{
		private const string PendingEquipKey = "pendingEquip";

		private bool _installed;

		private IDictionary<string, object> _carry;

		public void Start(ModuleContext context)
		{
			Log.Init(context.Log);
			_carry = context.Carry;
			if (ContentFactory.Ready)
			{
				Install();
			}
			else
			{
				ContentFactory.Created += Install;
			}
		}

		public void Update()
		{
			FrozenLook.Tick();
		}

		public void Stop()
		{
			ContentFactory.Created -= Install;
			if (!_installed)
			{
				return;
			}
			_installed = false;
			ThrownAxeRelay.Handler = null;
			FrozenEffect.Logic = null;
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				Leave(allPlayer, _carry);
			}
			RuneBreath.ShutdownAll();
			LightFade.ShutdownAll();
			FrozenLook.ReleaseAll();
		}

		internal static void Settle(Player player)
		{
			if ((Object)(object)((Component)player).GetComponent<AxeLook>() == (Object)null)
			{
				((Component)player).gameObject.AddComponent<AxeLook>();
			}
			if ((Object)(object)((Component)player).GetComponent<AxeKeeper>() == (Object)null)
			{
				((Component)player).gameObject.AddComponent<AxeKeeper>();
			}
			if ((Object)(object)((Component)player).GetComponent<CatchReach>() == (Object)null)
			{
				((Component)player).gameObject.AddComponent<CatchReach>();
			}
			if ((Object)(object)((Component)player).GetComponent<ThrowSwing>() == (Object)null)
			{
				((Component)player).gameObject.AddComponent<ThrowSwing>();
			}
		}

		private void Install()
		{
			ContentFactory.Created -= Install;
			Effects.Borrow(LeviathanItem.Prefab);
			AxeHits.RegisterYoungTrees();
			ThrownAxeRelay.Handler = (IThrowHandler)(object)new ThrowHandler();
			FrozenEffect.Logic = (IFreeze)(object)new FreezeLogic();
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				Settle(allPlayer);
			}
			ResumePendingEquip();
			_installed = true;
		}

		private void ResumePendingEquip()
		{
			if (_carry == null || !_carry.TryGetValue("pendingEquip", out var value))
			{
				return;
			}
			_carry.Remove("pendingEquip");
			AxeKeeper axeKeeper = (((Object)(object)Player.m_localPlayer != (Object)null) ? ((Component)Player.m_localPlayer).GetComponent<AxeKeeper>() : null);
			if ((Object)(object)axeKeeper != (Object)null)
			{
				ItemData val = (ItemData)((value is ItemData) ? value : null);
				if (val != null)
				{
					axeKeeper.ResumeEquip(val);
				}
			}
		}

		private static void Leave(Player player, IDictionary<string, object> carry)
		{
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			AxeKeeper component = ((Component)player).GetComponent<AxeKeeper>();
			if ((Object)(object)component != (Object)null)
			{
				component.Shutdown();
				if ((Object)(object)player == (Object)(object)Player.m_localPlayer && component.PendingEquip != null && carry != null)
				{
					carry["pendingEquip"] = component.PendingEquip;
				}
				Object.DestroyImmediate((Object)(object)component);
			}
			CatchReach component2 = ((Component)player).GetComponent<CatchReach>();
			if ((Object)(object)component2 != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component2);
			}
			ThrowSwing component3 = ((Component)player).GetComponent<ThrowSwing>();
			if ((Object)(object)component3 != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component3);
			}
			AxeLook component4 = ((Component)player).GetComponent<AxeLook>();
			if ((Object)(object)component4 != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component4);
			}
		}
	}
	internal static class Log
	{
		private static ManualLogSource _source;

		private static readonly HashSet<string> Reported = new HashSet<string>();

		internal static void Init(ManualLogSource source)
		{
			_source = source;
		}

		internal static void Info(string message)
		{
			ManualLogSource source = _source;
			if (source != null)
			{
				source.LogInfo((object)message);
			}
		}

		internal static void Warning(string message)
		{
			ManualLogSource source = _source;
			if (source != null)
			{
				source.LogWarning((object)message);
			}
		}

		internal static void WarnOnce(string key, string message)
		{
			if (Reported.Add("w:" + key))
			{
				ManualLogSource source = _source;
				if (source != null)
				{
					source.LogWarning((object)message);
				}
			}
		}

		internal static void Error(string message)
		{
			ManualLogSource source = _source;
			if (source != null)
			{
				source.LogError((object)message);
			}
		}

		internal static void ErrorOnce(string key, Exception error)
		{
			if (Reported.Add("e:" + key))
			{
				ManualLogSource source = _source;
				if (source != null)
				{
					source.LogError((object)$"[{key}] {error}");
				}
			}
		}
	}
	[BepInPlugin("grogui.LeviathanAxe.Module", "LeviathanAxe Module", "1.0.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal sealed class ModulePlugin : BaseUnityPlugin
	{
		private const string Guid = "grogui.LeviathanAxe.Module";

		private const string BaseGuid = "grogui.LeviathanAxe";

		internal const string Version = "1.0.3";

		private void Awake()
		{
			ModuleBridge.Attach((IModule)(object)new LeviathanModule());
		}
	}
}
namespace LeviathanAxe.Throwing
{
	internal static class AxeHits
	{
		private static readonly RaycastHit[] WallHits = (RaycastHit[])(object)new RaycastHit[16];

		private static readonly HashSet<int> YoungTreeHashes = new HashSet<int>();

		private static int _solidMask;

		private static int _characterMask;

		private static int _staticMask;

		internal static int SolidMask
		{
			get
			{
				if (_solidMask == 0)
				{
					return _solidMask = LayerMask.GetMask(new string[12]
					{
						"Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox",
						"character_noenv", "vehicle"
					});
				}
				return _solidMask;
			}
		}

		internal static int CharacterMask
		{
			get
			{
				if (_characterMask == 0)
				{
					return _characterMask = LayerMask.GetMask(new string[5] { "character", "character_net", "character_ghost", "hitbox", "character_noenv" });
				}
				return _characterMask;
			}
		}

		internal static int StaticMask
		{
			get
			{
				if (_staticMask == 0)
				{
					return _staticMask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "terrain" });
				}
				return _staticMask;
			}
		}

		internal static bool IsValidTarget(Character thrower, Character target, HitData hitData)
		{
			if ((Object)(object)target == (Object)null || (Object)(object)thrower == (Object)null || (Object)(object)target == (Object)(object)thrower || target.IsDead())
			{
				return false;
			}
			BaseAI baseAI = target.GetBaseAI();
			bool flag = BaseAI.IsEnemy(thrower, target) || ((Object)(object)baseAI != (Object)null && baseAI.IsAggravatable() && thrower.IsPlayer());
			if (thrower.IsPlayer() && !thrower.IsPVPEnabled() && !flag)
			{
				return false;
			}
			if (hitData != null && hitData.m_dodgeable && target.IsDodgeInvincible())
			{
				Character obj = ((target is Player) ? target : null);
				if (obj != null)
				{
					((Player)obj).HitWhileDodging();
				}
				return false;
			}
			return true;
		}

		internal static void RegisterYoungTrees()
		{
			YoungTreeHashes.Clear();
			string[] youngTrees = VanillaPrefabs.YoungTrees;
			foreach (string text in youngTrees)
			{
				if ((Object)(object)PrefabManager.Instance.GetPrefab(text) == (Object)null)
				{
					Log.Warning("Young tree \"" + text + "\" not found: the axe will stick in it.");
				}
				else
				{
					YoungTreeHashes.Add(StringExtensionMethods.GetStableHashCode(text));
				}
			}
		}

		internal static bool IsYoungTree(GameObject hitObject)
		{
			ZNetView val = (((Object)(object)hitObject != (Object)null) ? hitObject.GetComponent<ZNetView>() : null);
			ZDO val2 = (((Object)(object)val != (Object)null && val.IsValid()) ? val.GetZDO() : null);
			if (val2 != null)
			{
				return YoungTreeHashes.Contains(val2.GetPrefab());
			}
			return false;
		}

		internal static bool IsHard(IDestructible target)
		{
			//IL_0029: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Invalid comparison between Unknown and I4
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Invalid comparison between Unknown and I4
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Invalid comparison between Unknown and I4
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Invalid comparison between Unknown and I4
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Invalid comparison between Unknown and I4
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Invalid comparison between Unknown and I4
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			if (!(target is MineRock) && !(target is MineRock5))
			{
				WearNTear val = (WearNTear)(object)((target is WearNTear) ? target : null);
				if (val == null)
				{
					Destructible val2 = (Destructible)(object)((target is Destructible) ? target : null);
					if (val2 != null)
					{
						if ((int)val2.m_damages.m_chop == 3)
						{
							return (int)val2.m_damages.m_pickaxe != 3;
						}
						return false;
					}
					return false;
				}
				MaterialType materialType = val.m_materialType;
				if ((int)materialType != 1 && (int)materialType != 4 && (int)materialType != 5 && (int)materialType != 2)
				{
					return (int)materialType == 7;
				}
				return true;
			}
			return true;
		}

		internal static bool FirstWall(Vector3 from, Vector3 to, out Vector3 point, Predicate<GameObject> passThrough)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_0022: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			point = to;
			Vector3 val = to - from;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude < 0.0001f)
			{
				return false;
			}
			int num = Physics.RaycastNonAlloc(from, val / magnitude, WallHits, magnitude, StaticMask, (QueryTriggerInteraction)1);
			SortByDistance(WallHits, num);
			for (int i = 0; i < num; i++)
			{
				Collider collider = ((RaycastHit)(ref WallHits[i])).collider;
				if ((Object)(object)collider == (Object)null)
				{
					continue;
				}
				Rigidbody attachedRigidbody = collider.attachedRigidbody;
				if (!((Object)(object)attachedRigidbody != (Object)null) || attachedRigidbody.IsSleeping())
				{
					GameObject val2 = Projectile.FindHitObject(collider);
					ZNetView val3 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<ZNetView>() : null);
					if ((!((Object)(object)val3 != (Object)null) || val3.IsValid()) && !IsYoungTree(val2) && (passThrough == null || !passThrough(val2)))
					{
						point = ((RaycastHit)(ref WallHits[i])).point;
						return true;
					}
				}
			}
			return false;
		}

		internal static void SortByDistance(RaycastHit[] hits, int count)
		{
			//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_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_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)
			for (int i = 1; i < count; i++)
			{
				RaycastHit val = hits[i];
				int num = i - 1;
				while (num >= 0 && ((RaycastHit)(ref hits[num])).distance > ((RaycastHit)(ref val)).distance)
				{
					hits[num + 1] = hits[num];
					num--;
				}
				hits[num + 1] = val;
			}
		}
	}
	internal enum ThrowKind
	{
		None,
		Horizontal,
		Vertical
	}
	internal sealed class AxeKeeper : MonoBehaviour
	{
		private const float PendingEquipTime = 1.5f;

		private const float CatchShakeRange = 10f;

		private const float CatchShakeStrength = 0.6f;

		internal const float WindUpTime = 0.35f;

		private static AxeKeeper _local;

		private Player _player;

		private ZNetView _nview;

		private ThrownAxe _axe;

		private CatchReach _reach;

		private ItemData _item;

		private bool _equipOnCatch;

		private ItemData _pendingEquip;

		private float _pendingEquipUntil;

		private bool _secondaryLatched;

		private bool _charged;

		private int _appliedRevision = int.MinValue;

		private float _throwStart = -1f;

		private bool _releasedInWindUp;

		private ThrowKind _launchKind;

		internal static AxeKeeper Local
		{
			get
			{
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null)
				{
					return null;
				}
				if ((Object)(object)_local == (Object)null || (Object)(object)_local._player != (Object)(object)localPlayer)
				{
					_local = ((Component)localPlayer).GetComponent<AxeKeeper>();
				}
				return _local;
			}
		}

		internal bool HasAxeOut => (Object)(object)_axe != (Object)null;

		internal bool AxeReturning
		{
			get
			{
				if ((Object)(object)_axe != (Object)null)
				{
					return _axe.Phase == AxePhase.Returning;
				}
				return false;
			}
		}

		internal CatchReach Reach
		{
			get
			{
				if (!((Object)(object)_reach != (Object)null))
				{
					return _reach = ((Component)this).GetComponent<CatchReach>();
				}
				return _reach;
			}
		}

		internal FrostGauge Frost { get; } = new FrostGauge();

		internal ItemData PendingEquip => _pendingEquip;

		internal ThrowKind PendingKind => _launchKind;

		internal bool Charged => _charged;

		internal bool IsThrown(ItemData item)
		{
			if ((Object)(object)_axe != (Object)null && item != null)
			{
				return item == _item;
			}
			return false;
		}

		internal void ResumeEquip(ItemData item)
		{
			_pendingEquip = item;
			_pendingEquipUntil = Time.time + 1.5f;
		}

		private void Awake()
		{
			_player = ((Component)this).GetComponent<Player>();
			_nview = ((Component)this).GetComponent<ZNetView>();
		}

		private void Update()
		{
			if ((Object)(object)_nview == (Object)null || !_nview.IsValid())
			{
				return;
			}
			try
			{
				if (_nview.IsOwner())
				{
					UpdateOwner();
				}
				else
				{
					UpdateMirror();
				}
			}
			catch (Exception error)
			{
				Log.ErrorOnce("AxeKeeper.Update", error);
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)_axe != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_axe).gameObject);
			}
		}

		private void UpdateOwner()
		{
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			bool flag = GameAccess.SecondaryAttackHold.Invoke((Character)(object)_player);
			if (!flag)
			{
				_secondaryLatched = false;
			}
			if (_throwStart >= 0f && _launchKind == ThrowKind.None)
			{
				_releasedInWindUp |= !flag;
				if (Time.time - _throwStart >= 0.35f)
				{
					Decide();
				}
			}
			else if (_throwStart >= 0f && !((Character)_player).InAttack() && (Object)(object)_axe == (Object)null && Time.time - _throwStart > 1.35f)
			{
				_throwStart = -1f;
				_launchKind = ThrowKind.None;
			}
			if (_item != null && (Object)(object)_axe == (Object)null)
			{
				Clear();
			}
			else if ((Object)(object)_axe != (Object)null)
			{
				if (!((Humanoid)_player).GetInventory().ContainsItem(_item))
				{
					Effects.Impact(((Component)_axe).transform.position, Vector3.down, creature: false);
					Clear();
				}
				else if (RecallKeyDown())
				{
					Recall(equipOnCatch: false);
				}
			}
			if (_pendingEquip != null)
			{
				TryPendingEquip();
			}
		}

		private void UpdateMirror()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			ZDO zDO = _nview.GetZDO();
			int num = AxeNet.Revision(zDO);
			if (num == _appliedRevision)
			{
				return;
			}
			_appliedRevision = num;
			AxeNetState state = AxeNet.Read(zDO);
			if (state.Phase == AxePhase.None)
			{
				DestroyAxe();
				return;
			}
			if ((Object)(object)_axe == (Object)null)
			{
				_axe = ThrownAxe.Spawn(state.Position);
				if ((Object)(object)_axe == (Object)null)
				{
					return;
				}
				_axe.InitMirror(this, _player, state.Quality);
			}
			_axe.ApplyNetState(state);
		}

		internal void OnThrowStarted()
		{
			_throwStart = Time.time;
			_releasedInWindUp = !GameAccess.SecondaryAttackHold.Invoke((Character)(object)_player);
			_launchKind = ThrowKind.None;
			AxeLook component = ((Component)this).GetComponent<AxeLook>();
			if ((Object)(object)component != (Object)null)
			{
				component.Kindle();
			}
		}

		private void Decide()
		{
			_launchKind = (_releasedInWindUp ? ThrowKind.Horizontal : ThrowKind.Vertical);
			ZDO val = (((Object)(object)_nview != (Object)null && _nview.IsValid()) ? _nview.GetZDO() : null);
			if (val != null)
			{
				AxeNet.WriteSwing(val, _launchKind, AxeNet.NowTicks());
			}
		}

		internal ThrowKind TakeLaunchKind()
		{
			if (_throwStart >= 0f && _launchKind == ThrowKind.None)
			{
				Decide();
			}
			ThrowKind result = ((_launchKind == ThrowKind.None) ? ThrowKind.Horizontal : _launchKind);
			_throwStart = -1f;
			_launchKind = ThrowKind.None;
			return result;
		}

		internal void Charge()
		{
			_charged = true;
		}

		internal bool TakeCharge()
		{
			bool charged = _charged;
			_charged = false;
			return charged;
		}

		internal void OnThrown(ThrownAxe axe, ItemData item)
		{
			if ((Object)(object)_axe != (Object)null && (Object)(object)_axe != (Object)(object)axe)
			{
				DestroyAxe();
			}
			_axe = axe;
			_item = item;
			_equipOnCatch = false;
			_pendingEquip = null;
			_secondaryLatched = true;
			GameAccess.QueuedSecondaryAttack.Invoke(_player) = 0f;
			((Humanoid)_player).UnequipItem(item, false);
		}

		internal bool Recall(bool equipOnCatch)
		{
			if ((Object)(object)_axe == (Object)null)
			{
				return false;
			}
			_equipOnCatch |= equipOnCatch;
			_axe.BeginReturn();
			return true;
		}

		internal void OnCaught()
		{
			Catch(shake: true);
		}

		internal void Shutdown()
		{
			if (!((Object)(object)_axe == (Object)null))
			{
				if ((Object)(object)_nview != (Object)null && _nview.IsValid() && _nview.IsOwner())
				{
					Catch(shake: false);
					return;
				}
				Object.Destroy((Object)(object)((Component)_axe).gameObject);
				_axe = null;
			}
		}

		private void Catch(bool shake)
		{
			//IL_0045: 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_004a: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			ItemData item = _item;
			bool equipOnCatch = _equipOnCatch;
			bool flag = equipOnCatch || Settings.AutoEquipOnCatch.Value;
			Vector3 point = (((Object)(object)_axe != (Object)null) ? ((Component)_axe).transform.position : ((Character)_player).GetCenterPoint());
			DestroyAxe();
			if (shake && (Object)(object)GameCamera.instance != (Object)null)
			{
				GameCamera.instance.AddShake(((Component)_player).transform.position, 10f, 0.6f, false);
			}
			if (shake && _charged)
			{
				Effects.Shards(point);
			}
			if (item != null && flag && ((Humanoid)_player).GetInventory().ContainsItem(item) && (equipOnCatch || HandsFree()) && !((Humanoid)_player).EquipItem(item, true))
			{
				_pendingEquip = item;
				_pendingEquipUntil = Time.time + 1.5f;
			}
		}

		internal bool ConsumeSecondaryAttack()
		{
			if ((Object)(object)_axe != (Object)null)
			{
				if (!Settings.RecallWithSecondaryAttack.Value || ((Humanoid)_player).RightItem != null)
				{
					return false;
				}
				if (!_secondaryLatched)
				{
					_secondaryLatched = true;
					Recall(equipOnCatch: false);
				}
				GameAccess.QueuedSecondaryAttack.Invoke(_player) = 0f;
				return true;
			}
			if (_secondaryLatched && LeviathanItem.Is(((Humanoid)_player).RightItem))
			{
				GameAccess.QueuedSecondaryAttack.Invoke(_player) = 0f;
				return true;
			}
			return false;
		}

		internal bool ConsumeHideKey()
		{
			if ((Object)(object)_axe == (Object)null || !Settings.RecallWithHideKey.Value || !HideKeyDown())
			{
				return false;
			}
			Recall(equipOnCatch: true);
			return true;
		}

		internal void Publish(AxeNetState state)
		{
			ZDO val = (((Object)(object)_nview != (Object)null && _nview.IsValid()) ? _nview.GetZDO() : null);
			if (val != null)
			{
				state.Quality = ((_item == null) ? 1 : _item.m_quality);
				AxeNet.Write(val, state);
			}
		}

		private void Clear()
		{
			DestroyAxe();
			_equipOnCatch = false;
		}

		private void DestroyAxe()
		{
			if ((Object)(object)_axe != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_axe).gameObject);
			}
			_axe = null;
			_item = null;
			if ((Object)(object)_nview != (Object)null && _nview.IsValid() && _nview.IsOwner())
			{
				Publish(new AxeNetState
				{
					Phase = AxePhase.None
				});
			}
		}

		private bool HandsFree()
		{
			ItemData leftItem = ((Humanoid)_player).LeftItem;
			if (((Humanoid)_player).RightItem == null)
			{
				if (leftItem != null)
				{
					return !leftItem.IsTwoHanded();
				}
				return true;
			}
			return false;
		}

		private void TryPendingEquip()
		{
			if (Time.time > _pendingEquipUntil || ((Humanoid)_player).IsItemEquiped(_pendingEquip) || !((Humanoid)_player).GetInventory().ContainsItem(_pendingEquip))
			{
				_pendingEquip = null;
			}
			else if (!((Character)_player).InAttack() && !((Character)_player).InDodge() && ((Humanoid)_player).EquipItem(_pendingEquip, true))
			{
				_pendingEquip = null;
			}
		}

		private static bool HideKeyDown()
		{
			if (!ZInput.GetButtonDown("Hide"))
			{
				return ZInput.GetButtonUp("JoyHide");
			}
			return true;
		}

		private static bool RecallKeyDown()
		{
			//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_000d: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value = Settings.RecallKey.Value;
			if ((int)((KeyboardShortcut)(ref value)).MainKey == 0 || !TakesInput())
			{
				return false;
			}
			if (!UnityInput.Current.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey))
			{
				return false;
			}
			foreach (KeyCode modifier in ((KeyboardShortcut)(ref value)).Modifiers)
			{
				if (!UnityInput.Current.GetKey(modifier))
				{
					return false;
				}
			}
			return true;
		}

		private static bool TakesInput()
		{
			if (!Console.IsVisible() && !Menu.IsVisible() && !TextInput.IsVisible() && !Minimap.InTextInput() && !InventoryGui.IsVisible())
			{
				if (!((Object)(object)Chat.instance == (Object)null))
				{
					return !Chat.instance.HasFocus();
				}
				return true;
			}
			return false;
		}
	}
	internal enum AxePhase
	{
		None,
		Flying,
		Stuck,
		Returning,
		Loose
	}
	internal struct AxeNetState
	{
		internal AxePhase Phase;

		internal long StartTicks;

		internal Vector3 Position;

		internal Vector3 Velocity;

		internal float Gravity;

		internal float Acceleration;

		internal float MaxSpeed;

		internal bool Horizontal;

		internal Vector3 AngularVelocity;

		internal Quaternion Rotation;

		internal float ReleaseBlend;

		internal ZDOID Target;

		internal string Bone;

		internal string Skin;

		internal int Vertex;

		internal float Duration;

		internal float Delay;

		internal Vector3 RipOut;

		internal Vector3 WiggleAxis;

		internal Vector3 Heading;

		internal float LiftStart;

		internal float LiftEnd;

		internal float Span;

		internal int FelledPrefab;

		internal Vector3 FelledRoot;

		internal ZDOID FelledId;

		internal bool Precision;

		internal int Quality;

		internal float Spin;

		internal Vector3 SpinAxis;

		internal double StartSeconds => (double)StartTicks / 10000000.0;
	}
	internal static class AxeNet
	{
		private static readonly int RevisionKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_revision");

		private static readonly int PhaseKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_phase");

		private static readonly int TimeKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_time");

		private static readonly int PositionKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_position");

		private static readonly int VelocityKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_velocity");

		private static readonly int GravityKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_gravity");

		private static readonly int RotationKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_rotation");

		private static readonly int BoneKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_bone");

		private static readonly int DurationKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_duration");

		private static readonly int QualityKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_quality");

		private static readonly int SpinKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_spin");

		private static readonly int SpinAxisKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_spinAxis");

		private static readonly int HorizontalKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_horizontal");

		private static readonly int AngularVelocityKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_angularVelocity");

		private static readonly int SkinKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_skin");

		private static readonly int VertexKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_vertex");

		private static readonly KeyValuePair<int, int> TargetKey = ZDO.GetHashZDOID("LeviathanAxe_target");

		private static readonly int AccelerationKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_acceleration");

		private static readonly int MaxSpeedKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_maxSpeed");

		private static readonly int DelayKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_delay");

		private static readonly int SpanKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_span");

		private static readonly int PrecisionKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_precision");

		private static readonly int ReleaseBlendKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_releaseBlend");

		private static readonly int RipOutKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_ripOut");

		private static readonly int WiggleAxisKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_wiggleAxis");

		private static readonly int HeadingKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_heading");

		private static readonly int LiftStartKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_lift");

		private static readonly int LiftEndKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_arrivalLift");

		private static readonly int FelledPrefabKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_felledPrefab");

		private static readonly int FelledRootKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_felledRoot");

		private static readonly KeyValuePair<int, int> FelledIdKey = ZDO.GetHashZDOID("LeviathanAxe_felledId");

		private static readonly int SwingKindKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_swingKind");

		private static readonly int SwingTimeKey = StringExtensionMethods.GetStableHashCode("LeviathanAxe_swingTime");

		internal static int Revision(ZDO zdo)
		{
			return zdo.GetInt(RevisionKey, 0);
		}

		internal static void Write(ZDO zdo, AxeNetState state)
		{
			//IL_0035: 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_008a: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			zdo.Set(PhaseKey, (int)state.Phase, false);
			if (state.Phase != AxePhase.None)
			{
				zdo.Set(TimeKey, state.StartTicks);
				zdo.Set(PositionKey, state.Position);
				zdo.Set(VelocityKey, state.Velocity);
				zdo.Set(GravityKey, state.Gravity);
				zdo.Set(AccelerationKey, state.Acceleration);
				zdo.Set(MaxSpeedKey, state.MaxSpeed);
				zdo.Set(RotationKey, state.Rotation);
				zdo.Set(TargetKey, state.Target);
				zdo.Set(BoneKey, state.Bone ?? "");
				zdo.Set(DurationKey, state.Duration);
				zdo.Set(DelayKey, state.Delay);
				zdo.Set(SpanKey, state.Span);
				zdo.Set(PrecisionKey, state.Precision);
				zdo.Set(ReleaseBlendKey, state.ReleaseBlend);
				zdo.Set(RipOutKey, state.RipOut);
				zdo.Set(WiggleAxisKey, state.WiggleAxis);
				zdo.Set(HeadingKey, state.Heading);
				zdo.Set(LiftStartKey, state.LiftStart);
				zdo.Set(LiftEndKey, state.LiftEnd);
				zdo.Set(FelledPrefabKey, state.FelledPrefab, false);
				zdo.Set(FelledRootKey, state.FelledRoot);
				zdo.Set(FelledIdKey, state.FelledId);
				zdo.Set(QualityKey, state.Quality, false);
				zdo.Set(SpinKey, state.Spin);
				zdo.Set(SpinAxisKey, state.SpinAxis);
				zdo.Set(HorizontalKey, state.Horizontal);
				zdo.Set(AngularVelocityKey, state.AngularVelocity);
				zdo.Set(SkinKey, state.Skin ?? "");
				zdo.Set(VertexKey, state.Vertex, false);
			}
			zdo.Set(RevisionKey, zdo.GetInt(RevisionKey, 0) + 1, false);
		}

		internal static void WriteSwing(ZDO zdo, ThrowKind kind, long ticks)
		{
			zdo.Set(SwingKindKey, (int)kind, false);
			zdo.Set(SwingTimeKey, ticks);
		}

		internal static void ReadSwing(ZDO zdo, out ThrowKind kind, out long ticks)
		{
			kind = (ThrowKind)zdo.GetInt(SwingKindKey, 0);
			ticks = zdo.GetLong(SwingTimeKey, 0L);
		}

		internal static AxeNetState Read(ZDO zdo)
		{
			//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_0041: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: 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_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			return new AxeNetState
			{
				Phase = (AxePhase)zdo.GetInt(PhaseKey, 0),
				StartTicks = zdo.GetLong(TimeKey, 0L),
				Position = zdo.GetVec3(PositionKey, Vector3.zero),
				Velocity = zdo.GetVec3(VelocityKey, Vector3.zero),
				Gravity = zdo.GetFloat(GravityKey, 0f),
				Acceleration = zdo.GetFloat(AccelerationKey, 0f),
				MaxSpeed = zdo.GetFloat(MaxSpeedKey, 0f),
				Rotation = zdo.GetQuaternion(RotationKey, Quaternion.identity),
				Target = zdo.GetZDOID(TargetKey),
				Bone = zdo.GetString(BoneKey, ""),
				Duration = zdo.GetFloat(DurationKey, 0f),
				Delay = zdo.GetFloat(DelayKey, 0f),
				Span = zdo.GetFloat(SpanKey, 0f),
				Precision = zdo.GetBool(PrecisionKey, false),
				ReleaseBlend = zdo.GetFloat(ReleaseBlendKey, 0f),
				RipOut = zdo.GetVec3(RipOutKey, Vector3.zero),
				WiggleAxis = zdo.GetVec3(WiggleAxisKey, Vector3.zero),
				Heading = zdo.GetVec3(HeadingKey, Vector3.zero),
				LiftStart = zdo.GetFloat(LiftStartKey, 0f),
				LiftEnd = zdo.GetFloat(LiftEndKey, 0f),
				FelledPrefab = zdo.GetInt(FelledPrefabKey, 0),
				FelledRoot = zdo.GetVec3(FelledRootKey, Vector3.zero),
				FelledId = zdo.GetZDOID(FelledIdKey),
				Quality = zdo.GetInt(QualityKey, 1),
				Spin = zdo.GetFloat(SpinKey, 0f),
				SpinAxis = zdo.GetVec3(SpinAxisKey, Vector3.zero),
				Horizontal = zdo.GetBool(HorizontalKey, false),
				AngularVelocity = zdo.GetVec3(AngularVelocityKey, Vector3.zero),
				Skin = zdo.GetString(SkinKey, ""),
				Vertex = zdo.GetInt(VertexKey, -1)
			};
		}

		internal static double NowSeconds()
		{
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				return Time.time;
			}
			return ZNet.instance.GetTimeSeconds() + (double)Mathf.Clamp(Time.time - Time.fixedTime, 0f, Time.fixedDeltaTime);
		}

		internal static long NowTicks()
		{
			return (long)(NowSeconds() * 10000000.0);
		}
	}
	internal static class BodySurface
	{
		private const float ReachRatio = 0.35f;

		private const float MinReach = 0.08f;

		private const float MaxReach = 0.4f;

		internal static bool Find(Character character, Vector3 point, Vector3 direction, out Vector3 surface, out Vector3 normal, out SkinAnchor anchor)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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)
			//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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: 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_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: 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_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: 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_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: 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_0217: Unknown result type (might be due to invalid IL or missing references)
			surface = point;
			normal = -direction;
			anchor = null;
			float num = Mathf.Clamp(character.GetRadius() * 0.35f, 0.08f, 0.4f);
			float num2 = float.MaxValue;
			float num3 = float.MaxValue;
			Vector3 val = point;
			Vector3 val2 = -direction;
			SkinnedMeshRenderer val3 = null;
			SkinnedMeshRenderer val4 = null;
			int index = -1;
			int num4 = -1;
			SkinnedMeshRenderer[] componentsInChildren = ((Component)character).GetComponentsInChildren<SkinnedMeshRenderer>();
			foreach (SkinnedMeshRenderer val5 in componentsInChildren)
			{
				Mesh sharedMesh = val5.sharedMesh;
				if ((Object)(object)sharedMesh == (Object)null || !sharedMesh.isReadable || !((Renderer)val5).enabled || !((Component)val5).gameObject.activeInHierarchy)
				{
					continue;
				}
				Transform[] bones = val5.bones;
				Matrix4x4[] bindposes = sharedMesh.bindposes;
				Vector3[] vertices = sharedMesh.vertices;
				Vector3[] normals = sharedMesh.normals;
				BoneWeight[] boneWeights = sharedMesh.boneWeights;
				if (bones == null || bones.Length == 0 || bindposes.Length != bones.Length || boneWeights.Length != vertices.Length)
				{
					continue;
				}
				bool flag = normals != null && normals.Length == vertices.Length;
				Matrix4x4[] array = (Matrix4x4[])(object)new Matrix4x4[bones.Length];
				for (int j = 0; j < bones.Length; j++)
				{
					array[j] = (((Object)(object)bones[j] != (Object)null) ? (bones[j].localToWorldMatrix * bindposes[j]) : Matrix4x4.zero);
				}
				for (int k = 0; k < vertices.Length; k++)
				{
					BoneWeight weight = boneWeights[k];
					Vector3 val6 = SkinPoint(array, weight, vertices[k]);
					Vector3 val7 = val6 - point;
					float sqrMagnitude = ((Vector3)(ref val7)).sqrMagnitude;
					float num5 = Vector3.Dot(val7, direction);
					Vector3 val8 = val7 - direction * num5;
					float magnitude = ((Vector3)(ref val8)).magnitude;
					bool flag2 = num5 > 0f - num && magnitude < num;
					if (flag2 || !(sqrMagnitude >= num3))
					{
						Vector3 val9 = (flag ? SkinNormal(array, weight, normals[k]) : (-direction));
						if (flag2 && num5 < num2)
						{
							num2 = num5;
							surface = val6;
							normal = val9;
							val3 = val5;
							index = k;
						}
						if (sqrMagnitude < num3)
						{
							num3 = sqrMagnitude;
							val = val6;
							val2 = val9;
							val4 = val5;
							num4 = k;
						}
					}
				}
			}
			if ((Object)(object)val3 == (Object)null && (Object)(object)val4 != (Object)null)
			{
				surface = val;
				normal = val2;
				val3 = val4;
				index = num4;
			}
			anchor = (((Object)(object)val3 != (Object)null) ? SkinAnchor.Create(val3, index) : null);
			if (anchor == null)
			{
				return false;
			}
			if (((Vector3)(ref normal)).sqrMagnitude < 0.01f || Vector3.Dot(normal, direction) > 0f)
			{
				normal = -direction;
			}
			((Vector3)(ref normal)).Normalize();
			return true;
		}

		private static Vector3 SkinPoint(Matrix4x4[] skinning, BoneWeight weight, Vector3 vertex)
		{
			//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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_003e: 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_0051: 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_0062: 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_0075: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			return ((Matrix4x4)(ref skinning[((BoneWeight)(ref weight)).boneIndex0])).MultiplyPoint3x4(vertex) * ((BoneWeight)(ref weight)).weight0 + ((Matrix4x4)(ref skinning[((BoneWeight)(ref weight)).boneIndex1])).MultiplyPoint3x4(vertex) * ((BoneWeight)(ref weight)).weight1 + ((Matrix4x4)(ref skinning[((BoneWeight)(ref weight)).boneIndex2])).MultiplyPoint3x4(vertex) * ((BoneWeight)(ref weight)).weight2 + ((Matrix4x4)(ref skinning[((BoneWeight)(ref weight)).boneIndex3])).MultiplyPoint3x4(vertex) * ((BoneWeight)(ref weight)).weight3;
		}

		private static Vector3 SkinNormal(Matrix4x4[] skinning, BoneWeight weight, Vector3 normal)
		{
			//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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_003e: 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_0051: 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_0062: 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_0075: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Matrix4x4)(ref skinning[((BoneWeight)(ref weight)).boneIndex0])).MultiplyVector(normal) * ((BoneWeight)(ref weight)).weight0 + ((Matrix4x4)(ref skinning[((BoneWeight)(ref weight)).boneIndex1])).MultiplyVector(normal) * ((BoneWeight)(ref weight)).weight1 + ((Matrix4x4)(ref skinning[((BoneWeight)(ref weight)).boneIndex2])).MultiplyVector(normal) * ((BoneWeight)(ref weight)).weight2 + ((Matrix4x4)(ref skinning[((BoneWeight)(ref weight)).boneIndex3])).MultiplyVector(normal) * ((BoneWeight)(ref weight)).weight3;
			return ((Vector3)(ref val)).normalized;
		}
	}
	internal sealed class CatchReach : MonoBehaviour
	{
		private readonly struct BonePose
		{
			internal readonly HumanBodyBones Bone;

			internal readonly Quaternion Local;

			internal BonePose(HumanBodyBones bone, float x, float y, float z, float w)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				Bone = bone;
				Local = new Quaternion(x, y, z, w);
			}
		}

		private const float RaiseTime = 0.15f;

		private const float LowerTime = 0.35f;

		private static readonly BonePose[] ReachPose = new BonePose[19]
		{
			new BonePose((HumanBodyBones)12, -0.56429f, -0.418865f, 0.586007f, -0.403391f),
			new BonePose((HumanBodyBones)14, 0.119511f, 0.043487f, -0.172257f, 0.976808f),
			new BonePose((HumanBodyBones)16, -0.389437f, 0.002039f, 0.212383f, 0.89623f),
			new BonePose((HumanBodyBones)18, 0.014693f, -0.813961f, 0.007572f, 0.580684f),
			new BonePose((HumanBodyBones)39, 0.104108f, 0.028459f, 0.355634f, 0.928373f),
			new BonePose((HumanBodyBones)40, 0.061811f, -0.189057f, -0.053897f, 0.978536f),
			new BonePose((HumanBodyBones)41, 0.104301f, 0.245711f, -0.051085f, 0.962361f),
			new BonePose((HumanBodyBones)42, 0.11008f, 0.000158f, 0.132882f, 0.985f),
			new BonePose((HumanBodyBones)43, 0.128358f, -0.076142f, -0.015515f, 0.988679f),
			new BonePose((HumanBodyBones)44, 0.066204f, 0.04645f, -0.010217f, 0.996672f),
			new BonePose((HumanBodyBones)45, 0.052285f, 0.00323f, 0.068011f, 0.996308f),
			new BonePose((HumanBodyBones)46, 0.127568f, -0.006783f, -0.002775f, 0.991803f),
			new BonePose((HumanBodyBones)47, 0.073112f, -0.008947f, -0.007382f, 0.997256f),
			new BonePose((HumanBodyBones)48, 0.056084f, 0.006386f, 0.005482f, 0.998391f),
			new BonePose((HumanBodyBones)49, 0.127668f, 0.013804f, -0.00469f, 0.99171f),
			new BonePose((HumanBodyBones)50, 0.101929f, 0.001519f, 0.001896f, 0.994789f),
			new BonePose((HumanBodyBones)51, 0.096881f, 0.00266f, -0.050311f, 0.99402f),
			new BonePose((HumanBodyBones)52, 0.120801f, 0.006463f, 0.017802f, 0.992496f),
			new BonePose((HumanBodyBones)53, 0.072161f, 0.009514f, -0.04404f, 0.996375f)
		};

		private Player _player;

		private AxeKeeper _keeper;

		private float _weight;

		private int _posedFrame = -1;

		private Transform[] _bones;

		private Quaternion[] _targets;

		private bool _written;

		private Quaternion[] _animated;

		private Quaternion[] _posed;

		private void Awake()
		{
			_player = ((Component)this).GetComponent<Player>();
			_keeper = ((Component)this).GetComponent<AxeKeeper>();
		}

		private void LateUpdate()
		{
			try
			{
				Pose();
			}
			catch (Exception error)
			{
				Log.ErrorOnce("CatchReach.LateUpdate", error);
				((Behaviour)this).enabled = false;
			}
		}

		internal void Pose()
		{
			//IL_0044: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: 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_0146: Unknown result type (might be due to invalid IL or missing references)
			if (!((Behaviour)this).enabled || _posedFrame == Time.frameCount || !FindBones())
			{
				return;
			}
			_posedFrame = Time.frameCount;
			if (_written)
			{
				_written = false;
				for (int i = 0; i < _bones.Length; i++)
				{
					if (_bones[i].localRotation == _posed[i])
					{
						_bones[i].localRotation = _animated[i];
					}
				}
			}
			float num = (ShouldReach() ? 1f : 0f);
			_weight = Mathf.MoveTowards(_weight, num, Time.deltaTime / ((num > _weight) ? 0.15f : 0.35f));
			if (!(_weight <= 0f))
			{
				float num2 = Mathf.SmoothStep(0f, 1f, _weight);
				for (int j = 0; j < _bones.Length; j++)
				{
					_animated[j] = _bones[j].localRotation;
					_bones[j].localRotation = Quaternion.Slerp(_animated[j], _targets[j], num2);
					_posed[j] = _bones[j].localRotation;
				}
				_written = true;
			}
		}

		private bool ShouldReach()
		{
			if ((Object)(object)_keeper == (Object)null || !_keeper.AxeReturning)
			{
				return false;
			}
			if (((Character)_player).IsDead() || ((Character)_player).InAttack() || ((Character)_player).InDodge() || ((Character)_player).IsAttached() || ((Character)_player).IsSwimming())
			{
				return false;
			}
			VisEquipment visEquipment = ((Humanoid)_player).GetVisEquipment();
			if ((Object)(object)visEquipment != (Object)null)
			{
				return GameAccess.VisibleRightItem.Invoke(visEquipment) == 0;
			}
			return false;
		}

		private bool FindBones()
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			if (_bones != null)
			{
				bool flag = true;
				Transform[] bones = _bones;
				foreach (Transform val in bones)
				{
					flag &= (Object)(object)val != (Object)null;
				}
				if (flag)
				{
					return true;
				}
				_bones = null;
			}
			_written = false;
			Animator val2 = (((Object)(object)_player != (Object)null) ? GameAccess.CharacterAnimator.Invoke((Character)(object)_player) : null);
			if ((Object)(object)val2 == (Object)null || !val2.isHuman)
			{
				return false;
			}
			List<Transform> list = new List<Transform>();
			List<Quaternion> list2 = new List<Quaternion>();
			BonePose[] reachPose = ReachPose;
			for (int i = 0; i < reachPose.Length; i++)
			{
				BonePose bonePose = reachPose[i];
				Transform boneTransform = val2.GetBoneTransform(bonePose.Bone);
				if ((Object)(object)boneTransform != (Object)null)
				{
					list.Add(boneTransform);
					list2.Add(bonePose.Local);
				}
			}
			if (list.Count == 0)
			{
				Log.Warning("Right arm of the player not found: the arm does not reach for the returning axe.");
				((Behaviour)this).enabled = false;
				return false;
			}
			_bones = list.ToArray();
			_targets = list2.ToArray();
			_animated = (Quaternion[])(object)new Quaternion[_bones.Length];
			_posed = (Quaternion[])(object)new Quaternion[_bones.Length];
			return true;
		}
	}
	internal static class ReturnCurve
	{
		private const float MinBend = 1.6f;

		private const float MaxBend = 9f;

		private const float MinBendDistance = 4f;

		private const float MaxBendDistance = 50f;

		private const float Lead = 1f;

		private const float ArrivalAhead = 0.75f;

		private const float ArrivalSide = 1.5f;

		private const float LiftRatio = 0.08f;

		private const float MinLift = 0.2f;

		private const float MaxLift = 2.5f;

		private const float ArrivalLift = 0.5f;

		private const float AxeReach = 0.55f;

		private const float TerrainMargin = 0.25f;

		private const float TerrainSkipStart = 1f;

		private const float TerrainSkipEnd = 1.5f;

		private const float TerrainRamp = 2f;

		private const float MaxTerrainLiftRatio = 0.75f;

		private const float MinTerrainLiftCap = 3f;

		private const float MaxTerrainLift = 20f;

		private const float FloorFade = 0.1f;

		private const float LaunchTime = 0.06f;

		private const float MaxLaunchShare = 0.4f;

		private const int MinSamples = 64;

		private const int MaxSamples = 192;

		private const float SampleStep = 0.5f;

		private const int Samples = 32;

		private static readonly float[] Lengths = new float[33];

		private static readonly Vector3[] TerrainPoints = (Vector3[])(object)new Vector3[193];

		private static readonly float[] TerrainDistances = new float[193];

		private static readonly float[] TerrainRest = new float[193];

		private static int _terrainMask;

		private static int TerrainMask
		{
			get
			{
				if (_terrainMask == 0)
				{
					return _terrainMask = LayerMask.GetMask(new string[1] { "terrain" });
				}
				return _terrainMask;
			}
		}

		internal static float Ease(float time)
		{
			return 3f - 6f / (Mathf.Clamp01(time) + 2f);
		}

		internal static float Pace(float time)
		{
			float num = Mathf.Clamp01(time) + 2f;
			return 6f / (num * num);
		}

		internal static float Launch(float time, float duration, out float rate)
		{
			float num = ((duration > 0f) ? Mathf.Min(0.4f, 0.06f / duration) : 0f);
			time = Mathf.Clamp01(time);
			if (num <= 0f)
			{
				rate = 1f;
				return time;
			}
			float num2 = 1f - num * 0.5f;
			if (time < num)
			{
				rate = time / (num * num2);
				return time * time / (2f * num * num2);
			}
			rate = 1f / num2;
			return (time - num * 0.5f) / num2;
		}

		internal static float BaseLift(float span)
		{
			return Mathf.Clamp(span * 0.08f, 0.2f, 2.5f);
		}

		internal static float BaseArrivalLift(float span)
		{
			return BaseLift(span) * 0.5f;
		}

		internal static Vector3 Evaluate(Vector3 start, Vector3 end, Vector3 side, Vector3 forward, float span, float amount, float liftStart, float liftEnd, float share, out Vector3 tangent)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: 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)
			//IL_012e: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: 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_0146: 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)
			Controls(start, end, side, forward, span, amount, liftStart, liftEnd, out var p, out var p2);
			Lengths[0] = 0f;
			Vector3 val = start;
			for (int i = 1; i <= 32; i++)
			{
				Vector3 val2 = Point(start, p, p2, end, (float)i / 32f);
				float[] lengths = Lengths;
				int num = i;
				float num2 = Lengths[i - 1];
				Vector3 val3 = val2 - val;
				lengths[num] = num2 + ((Vector3)(ref val3)).magnitude;
				val = val2;
			}
			float num3 = Mathf.Clamp01(share) * Lengths[32];
			int j;
			for (j = 1; j < 32 && Lengths[j] < num3; j++)
			{
			}
			float num4 = Lengths[j] - Lengths[j - 1];
			float num5 = ((float)(j - 1) + ((num4 > 1E-05f) ? Mathf.Clamp01((num3 - Lengths[j - 1]) / num4) : 0f)) / 32f;
			float num6 = 1f - num5;
			tangent = 3f * num6 * num6 * (p - start) + 6f * num6 * num5 * (p2 - p) + 3f * num5 * num5 * (end - p2);
			return Point(start, p, p2, end, num5);
		}

		internal static void TerrainLift(Vector3 start, Vector3 end, Vector3 side, Vector3 forward, float span, float amount, out float liftStart, out float liftEnd)
		{
			//IL_0018: 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_001a: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			float num = BaseLift(span);
			float num2 = num * 0.5f;
			liftStart = num;
			liftEnd = num2;
			Controls(start, end, side, forward, span, amount, 0f, 0f, out var p, out var p2);
			float num3 = 0f;
			Vector3 val = start;
			Vector3 val3;
			for (int i = 1; i <= 64; i++)
			{
				Vector3 val2 = Point(start, p, p2, end, (float)i / 64f);
				float num4 = num3;
				val3 = val2 - val;
				num3 = num4 + ((Vector3)(ref val3)).magnitude;
				val = val2;
			}
			int num5 = Mathf.Clamp(Mathf.CeilToInt(num3 / 0.5f), 64, 192);
			TerrainPoints[0] = start;
			TerrainDistances[0] = 0f;
			for (int j = 1; j <= num5; j++)
			{
				TerrainPoints[j] = Point(start, p, p2, end, (float)j / (float)num5);
				float[] terrainDistances = TerrainDistances;
				int num6 = j;
				float num7 = TerrainDistances[j - 1];
				val3 = TerrainPoints[j] - TerrainPoints[j - 1];
				terrainDistances[num6] = num7 + ((Vector3)(ref val3)).magnitude;
			}
			float num8 = TerrainDistances[num5];
			bool flag = false;
			for (int k = 1; k < num5; k++)
			{
				TerrainRest[k] = 0f;
				float num9 = TerrainDistances[k] - 1f;
				float num10 = num8 - TerrainDistances[k] - 1.5f;
				if (!(num9 <= 0f) && !(num10 <= 0f) && PivotFloor(TerrainPoints[k], out var floor))
				{
					float t = (float)k / (float)num5;
					float num11 = Mathf.Clamp01(Mathf.Min(num9, num10) / 2f);
					float num12 = floor - 0.55f + 0.8f * num11 - TerrainPoints[k].y - StartWeight(t) * num - EndWeight(t) * num2;
					if (num12 > 0f)
					{
						TerrainRest[k] = num12;
						flag = true;
					}
				}
			}
			if (!flag)
			{
				return;
			}
			float num13 = Mathf.Clamp(span * 0.75f, 3f, 20f);
			float num14 = float.MaxValue;
			float num15 = float.MaxValue;
			for (int num16 = 10; num16 >= 0; num16--)
			{
				float num17 = (float)num16 / 10f;
				float num18 = 0f;
				for (int l = 1; l < num5; l++)
				{
					if (!(TerrainRest[l] <= 0f))
					{
						float t2 = (float)l / (float)num5;
						float num19 = num17 * StartWeight(t2) + (1f - num17) * EndWeight(t2);
						num18 = Mathf.Max(num18, (num19 > 0.0001f) ? (TerrainRest[l] / num19) : float.MaxValue);
					}
				}
				if (num17 > 0f)
				{
					num18 = Mathf.Min(num18, (num13 - num) / num17);
				}
				if (num17 < 1f)
				{
					num18 = Mathf.Min(num18, (num13 - num2) / (1f - num17));
				}
				num18 = Mathf.Max(0f, num18);
				float num20 = 0f;
				for (int m = 1; m < num5; m++)
				{
					if (!(TerrainRest[m] <= 0f))
					{
						float t3 = (float)m / (float)num5;
						float num21 = num17 * StartWeight(t3) + (1f - num17) * EndWeight(t3);
						num20 = Mathf.Max(num20, TerrainRest[m] - num21 * num18);
					}
				}
				float num22 = num + num17 * num18;
				float num23 = num2 + (1f - num17) * num18;
				float num24 = 0f;
				for (int n = 1; n < 32; n++)
				{
					float t4 = (float)n / 32f;
					num24 = Mathf.Max(num24, StartWeight(t4) * num22 + EndWeight(t4) * num23);
				}
				bool flag2 = num20 < num14 - 0.01f;
				bool flag3 = !flag2 && num20 <= num14 + 0.01f;
				if (flag2 || (flag3 && num24 < num15 - 0.001f))
				{
					num14 = (flag2 ? num20 : Mathf.Min(num14, num20));
					num15 = num24;
					liftStart = num22;
					liftEnd = num23;
				}
			}
		}

		internal static Vector3 Floor(Vector3 position, float share)
		{
			//IL_0000: 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_0046: 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)
			if (!PivotFloor(position, out var floor))
			{
				return position;
			}
			float num = Mathf.Clamp01(Mathf.Min(share, 1f - share) / 0.1f);
			position.y = Mathf.Max(position.y, floor - 0.55f * (1f - num));
			return position;
		}

		internal static Vector3 AboveTerrain(Vector3 position, float clearance)
		{
			//IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references)
			if (PivotFloor(position, out var floor))
			{
				position.y = Mathf.Max(position.y, floor - 0.55f + clearance);
			}
			return position;
		}

		private static bool PivotFloor(Vector3 point, out float floor)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_002c: Unknown result type (might be due to invalid IL or missing references)
			floor = 0f;
			if (Character.InInterior(point))
			{
				return false;
			}
			RaycastHit val = default(RaycastHit);
			if (!Physics.SphereCast(new Vector3(point.x, 6000f, point.z), 0.55f, Vector3.down, ref val, 10000f, TerrainMask, (QueryTriggerInteraction)1))
			{
				return false;
			}
			floor = 6000f - ((RaycastHit)(ref val)).distance;
			return true;
		}

		private static void Controls(Vector3 start, Vector3 end, Vector3 side, Vector3 forward, float span, float amount, float liftStart, float liftEnd, out Vector3 p1, out Vector3 p2)
		{
			//IL_0024: 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_0026: 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_0043: 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_003a: 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_0055: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//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_006f: 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_0079: 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_0081: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			float num = amount * Mathf.Lerp(1.6f, 9f, Mathf.InverseLerp(4f, 50f, span));
			Vector3 val = end - start;
			Vector3 val2 = ((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? (((Vector3)(ref val)).normalized * 1f) : Vector3.zero);
			p1 = start + val2 + side * num + Vector3.up * liftStart;
			p2 = end + forward * (0.75f * Mathf.Abs(num)) + side * (1.5f * num) + Vector3.up * liftEnd;
		}

		private static float StartWeight(float t)
		{
			float num = 1f - t;
			return 3f * num * num * t;
		}

		private static float EndWeight(float t)
		{
			return 3f * (1f - t) * t * t;
		}

		private static Vector3 Point(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0026: 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_0039: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			float num = 1f - t;
			return num * num * num * p0 + 3f * num * num * t * p1 + 3f * num * t * t * p2 + t * t * t * p3;
		}
	}
	internal sealed class SkinAnchor
	{
		private readonly Transform[] _bones = (Transform[])(object)new Transform[4];

		private readonly Matrix4x4[] _bindposes = (Matrix4x4[])(object)new Matrix4x4[4];

		private readonly float[] _weights = new float[4];

		private Vector3 _vertex;

		internal SkinnedMeshRenderer Renderer { get; private set; }

		internal int Index { get; private set; }

		internal Transform Dominant { get; private set; }

		internal bool Valid
		{
			get
			{
				for (int i = 0; i < 4; i++)
				{
					if (_weights[i] > 0f && (Object)(object)_bones[i] == (Object)null)
					{
						return false;
					}
				}
				return (Object)(object)Dominant != (Object)null;
			}
		}

		internal static SkinAnchor Create(SkinnedMeshRenderer renderer, int index)
		{
			//IL_0048: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			Mesh val = (((Object)(object)renderer != (Object)null) ? renderer.sharedMesh : null);
			if ((Object)(object)val == (Object)null || !val.isReadable || index < 0 || index >= val.vertexCount)
			{
				return null;
			}
			Transform[] bones = renderer.bones;
			Matrix4x4[] bindposes = val.bindposes;
			BoneWeight val2 = val.boneWeights[index];
			SkinAnchor skinAnchor = new SkinAnchor
			{
				Renderer = renderer,
				Index = index,
				_vertex = val.vertices[index]
			};
			int[] array = new int[4]
			{
				((BoneWeight)(ref val2)).boneIndex0,
				((BoneWeight)(ref val2)).boneIndex1,
				((BoneWeight)(ref val2)).boneIndex2,
				((BoneWeight)(ref val2)).boneIndex3
			};
			float[] array2 = new float[4]
			{
				((BoneWeight)(ref val2)).weight0,
				((BoneWeight)(ref val2)).weight1,
				((BoneWeight)(ref val2)).weight2,
				((BoneWeight)(ref val2)).weight3
			};
			float num = -1f;
			for (int i = 0; i < 4; i++)
			{
				if (array[i] < 0 || array[i] >= bones.Length || array[i] >= bindposes.Length)
				{
					return null;
				}
				skinAnchor._bones[i] = bones[array[i]];
				skinAnchor._bindposes[i] = bindposes[array[i]];
				skinAnchor._weights[i] = array2[i];
				if (array2[i] > num && (Object)(object)bones[array[i]] != (Object)null)
				{
					num = array2[i];
					skinAnchor.Dominant = bones[array[i]];
				}
			}
			if (!((Object)(object)skinAnchor.Dominant != (Object)null))
			{
				return null;
			}
			return skinAnchor;
		}

		internal Vector3 Position()
		{
			//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_0061: 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_0022: 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)
			//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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.zero;
			for (int i = 0; i < 4; i++)
			{
				if (_weights[i] > 0f)
				{
					Vector3 val2 = val;
					Matrix4x4 val3 = _bones[i].localToWorldMatrix * _bindposes[i];
					val = val2 + ((Matrix4x4)(ref val3)).MultiplyPoint3x4(_vertex) * _weights[i];
				}
			}
			return val;
		}

		internal Quaternion Rotation()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return Dominant.rotation;
		}
	}
	internal sealed class ThrowHandler : IThrowHandler
	{
		public void Launch(ThrownAxeRelay relay, Character owner, Vector3 velocity, float hitNoise, HitData hitData, ItemData item)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			ThrownAxe.Attach(relay).Launch(owner, velocity, hitNoise, hitData, item);
		}
	}
	internal sealed class ThrownAxe : MonoBehaviour
	{
		private struct Felling
		{
			internal Vector3 Root;

			internal ZDOID Id;

			internal int Log;

			internal int Stub;

			internal int Spawn;
		}

		private Transform _pivot;

		private Vector3 _center;

		private SkinnedMeshRenderer[] _throwerRenderers;

		private bool _visibleSet;

		private bool _visible;

		private Vector3 _edge;

		private Transform _model;

		private MeleeWeaponTrail _trail;

		private ParticleSystem _sparks;

		private Light _light;

		private const float FlightGravity = 0f;

		private const float FallGravity = 20f;

		private const float LaunchSpeedRatio = 0.625f;

		private const float RampTime = 0.25f;

		private const float MinAimDistance = 2f;

		private const float ReleaseBlendDistance = 1.5f;

		private const float MaxReleaseWait = 0.1f;

		private const float HandTargetBlendTime = 0.15f;

		private const float SpinPerMeter = 22.5f;

		private const float HitRadius = 0.15f;

		private const float ReturnHitRadius = 0.4f;

		private const float MinPenetration = 0.04f;

		private const float MaxPenetration = 0.06f;

		private const float HandleLift = 25f;

		private const float LiftSpread = 8f;

		private const float MinBladeTilt = 45f;

		private const float HeadOnLead = 0.3f;

		private const float MaxFlightTime = 8f;

		private const float GlanceAngle = 8f;

		private const float GlanceSpeedRatio = 0.5f;

		private const int MaxGlances = 2;

		private const float RicochetGravity = 10f;

		private const float GlanceClearance = 0.05f;

		private const float MaxReturnStart = 60f;

		private const float ReturnLead = 2.5f;

		private const float MaxReturnTime = 1.5f;

		private const float WiggleTime = 0.3f;

		private const float FarWiggleTime = 0.1f;

		private const float WiggleNear = 15f;

		private const float WiggleFar = 40f;

		private const float WiggleAngle = 10f;

		private const float WiggleFrequency = 10f;

		private const float WiggleStartShare = 0.5f;

		private const float RipOutTime = 0.12f;

		private const float RipOutDistance = 0.3f;

		private const float MinRipExit = 0.7f;

		private const float LyingRaise = 0.06f;

		private const float ClampedStartClearance = 1f;

		private const float ReturnTurnsPerMeter = 0.06f;

		private const float DepartureBlend = 0.1f;

		private const float DepartureTurnTime = 0.1f;

		private const float CatchBlend = 0.2f;

		private const float WhooshSpin = 900f;

		private const float MinWhooshPitch = 0.75f;

		private const float MaxWhooshPitch = 1.25f;

		private const float WhooshSpacing = 0.15f;

		private const float PrecisionRise = 2.5f;

		private const float PrecisionWindow = 0.8f;

		private const float HoverSpinRatio = 0.25f;

		private const float FlashTime = 0.35f;

		private const float FlashBoost = 6f;

		private const float NovaRadius = 4f;

		private const float NovaFrostRatio = 0.5f;

		private const float LegShare = 0.3f;

		private const float ForcedStagger = 100f;

		private const float SupportCheckInterval = 0.25f;

		private const float Adrenaline = 2f;

		private const float WeakSpotReach = 0.3f;

		private const float SinkRatio = 0.35f;

		private const float MaxSink = 0.6f;

		private const float StuckLightRatio = 0.35f;

		private const float DropSpeedRatio = 0.35f;

		private const float MinBounceSpeed = 1.5f;

		private const float MaxBounceSpeed = 3f;

		private const float BounceLift = 9f;

		private const float BounceGravity = 14f;

		private const float SurfaceSpread = 70f;

		private const float TumbleSpeed = 1080f;

		private const float MaxTumbleTilt = 15f;

		private const float LooseRadius = 0.5f;

		private const float MaxAngularSpeed = 30f;

		private const float RestDrift = 0.03f;

		private const float RestTurn = 5f;

		private const float RestDelay = 0.3f;

		private const float MaxLooseTime = 5f;

		private const float TrailStopSpeed = 1.5f;

		private const float TrailStartSpeed = 3f;

		private const float RestBlendTime = 0.25f;

		private const float KillWindow = 1f;

		private const float DebrisReach = 15f;

		private const float RootReach = 1f;

		private static readonly Quaternion BaseRotation = Quaternion.LookRotation(Vector3.up, Vector3.right);

		private static readonly RaycastHit[] Hits = (RaycastHit[])(object)new RaycastHit[32];

		private static readonly Collider[] Overlaps = (Collider[])(object)new Collider[64];

		private static readonly List<Collider> LooseColliders = new List<Collider>();

		private AxeKeeper _keeper;

		private bool _authority;

		private Player _thrower;

		private HitData _hitData;

		private float _hitNoise = 30f;

		private AxeNetState _state;

		private Vector3 _lastPosition;

		private Vector3 _direction = Vector3.forward;

		private float _spin;

		private double _flightStart;

		private Vector3 _flightOrigin;

		private bool _striking;

		private bool _horizontal;

		private bool _looseLanding;

		private bool _lying;

		private Rigidbody _body;

		private MeshCollider _looseCollider;

		private float _looseStart;

		private Vector3 _restPosition;

		private Quaternion _restRotation;

		private float _restSince;

		private bool _blending;

		private float _blendStart;

		private Vector3 _blendFrom;

		private Quaternion _blendFromRotation;

		private readonly HashSet<Character> _killed = new HashSet<Character>();

		private readonly List<Felling> _fellings = new List<Felling>();

		private Character _victim;

		private double _victimHitTime;

		private Vector3 _victimFrom;

		private Vector3 _victimVelocity;

		private float _victimGravity;

		private float _victimAcceleration;

		private float _victimMaxSpeed;

		private float _victimSpin;

		private GameObject _struck;

		private Felling _struckFelling;

		private Transform _anchor;

		private SkinAnchor _skin;

		private TreeSway _sway;

		private Vector3 _anchorPosition;

		private Quaternion _anchorRotation = Quaternion.identity;

		private Collider _support;

		private bool _parked;

		private float _supportCheck;

		private Character _stuckIn;

		private Vector3 _stuckNormal;

		private float _stuckDepth;

		private bool _mirrorStopped;

		private bool _trailEmitting;

		private float _lightIntensity = -1f;

		private float _lightRange;

		private readonly HashSet<Character> _returnHits = new HashSet<Character>();

		private readonly HashSet<GameObject> _cutTrees = new HashSet<GameObject>();

		private int _glances;

		private bool _charged;

		private bool _releasePending;

		private Vector3 _gameOrigin;

		private Vector3 _aimPoint;

		private Vector3 _aimDirection;

		private Vector3 _launchDirection;

		private bool _aimTurnPending;

		private Vector3 _frameUp;

		private double _returnNow = double.MinValue;

		private long _returnKey;

		private Vector3 _heldLocal;

		private Quaternion _heldLocalRotation;

		private bool _hasHeld;

		private float _handWeight = -1f;

		private float _releaseRequested;

		private int _struckPrefab;

		private Predicate<GameObject> _passThrough;

		private bool _rising;

		private double _hoverEnd = -1.0;

		private bool _ripping;

		private bool _ripCreature;

		private bool _departed;

		private bool _baseKnown;

		private Vector3 _basePosition;

		private Quaternion _baseRotation;

		private Vector3 _departPosition;

		private Quaternion _departRotation;

		private Quaternion _lastFlight;

		private bool _hasLastFlight;

		private Quaternion _lastHand;

		private bool _hasLastHand;

		private int _catchSign;

		private long _soundSegment;

		private int _whooshTurn;

		private float _lastWhoosh;

		private float _flashUntil;

		private bool _moving;

		private readonly HashSet<Character> _novaHits = new HashSet<Character>();

		internal AxePhase Phase => _state.Phase;

		internal bool Hovering
		{
			get
			{
				if (_state.Phase == AxePhase.Flying)
				{
					return _state.Precision;
				}
				return false;
			}
		}

		internal static ThrownAxe Attach(ThrownAxeRelay relay)
		{
			//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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			ThrownAxe thrownAxe = ((Component)relay).gameObject.AddComponent<ThrownAxe>();
			thrownAxe._pivot = relay.m_pivot;
			thrownAxe._center = relay.m_center;
			thrownAxe._edge = relay.m_edge;
			thrownAxe._model = relay.m_model;
			thrownAxe._trail = relay.m_trail;
			thrownAxe._sparks = relay.m_sparks;
			thrownAxe._light = relay.m_light;
			Transform val = (((Object)(object)relay.m_model != (Object)null) ? relay.m_model.parent : null);
			if ((Object)(object)val != (Object)null)
			{
				((Component)val).gameObject.AddComponent<RuneBreath>();
			}
			return thrownAxe;
		}

		internal static ThrownAxe Spawn(Vector3 position)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = ThrownAxePrefab.Prefab;
			ThrownAxeRelay val = (((Object)(object)prefab != (Object)null) ? Object.Instantiate<GameObject>(prefab, position, Quaternion.identity).GetComponent<ThrownAxeRelay>() : null);
			if (!((Object)(object)val != (Object)null))
			{
				return null;
			}
			return Attach(val);
		}

		internal void Launch(Character owner, Vector3 velocity, float hitNoise, HitData hitData, ItemData item)
		{
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: 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_01cc: 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_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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)
			//IL_0135: 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_013b: 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)
			Player val = (Player)(object)((owner is Player) ? owner : null);
			AxeKeeper axeKeeper = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<AxeKeeper>() : null);
			if ((Object)(object)axeKeeper == (Object)null || (Object)(object)val != (Object)(object)Player.m_localPlayer || hitData == null || !LeviathanItem.Is(item))
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			_authority = true;
			_keeper = axeKeeper;
			_thrower = val;
			_hitData = hitData;
			_horizontal = axeKeeper.TakeLaunchKind() == ThrowKind.Horizontal;
			((DamageTypes)(ref _hitData.m_damage)).Modify(Settings.ThrowDamageMultiplier.Value * (_horizontal ? 1f : Settings.ChargedThrowDamageMultiplier.Value));
			if (hitNoise >= 0f)
			{
				_hitNoise = hitNoise;
			}
			SetQuality(item.m_quality);
			Vector3 val2 = ((((Vector3)(ref velocity)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref velocity)).normalized : ((Component)val).transform.forward);
			_charged = axeKeeper.TakeCharge();
			axeKeeper.OnThrown(this, item);
			_striking = true;
			_looseLanding = false;
			_lying = false;
			if (_horizontal)
			{
				_gameOrigin = ((Component)this).transform.position;
				_aimDirection = val2;
				_aimPoint = AimPoint(_gameOrigin, val2);
				_releasePending = true;
				_releaseRequested = Time.time;
				SetVisible(visible: false);
			}
			else
			{
				float value = Settings.ThrowSpeed.Value;
				float num = value * 0.625f;
				Vector3 position = ((Component)this).transform.position;
				Vector3 velocity2 = val2 * num;
				float acceleration = (value - num) / 0.25f;
				float maxSpeed = value;
				BeginFlight(position, velocity2, 0f, 0f, fresh: true, default(Vector3), acceleration, maxSpeed);
			}
		}

		private void Release(bool force = false)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: 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_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			if (force || !((Object)(object)_thrower != (Object)null) || !GameAccess.CharacterShown.Invoke((Character)(object)_thrower) || BonesPosed() || !(Time.time - _releaseRequested < 0.1f))
			{
				_releasePending = false;
				SetVisible(visible: true);
				ThrowSwing throwSwing = (((Object)(object)_thrower != (Object)null) ? ((Component)_thrower).GetComponent<ThrowSwing>() : null);
				if ((Object)(object)throwSwing != (Object)null)
				{
					throwSwing.PoseNow();
				}
				Vector3 position;
				Quaternion rotation;
				bool flag = HeldPivot(out position, out rotation) && !Physics.Linecast(((Character)_thrower).GetCenterPoint(), position, AxeHits.StaticMask, (QueryTriggerInteraction)1) && !Physics.CheckSphere(position, 0.15f, AxeHits.StaticMask, (QueryTriggerInteraction)1);
				if (!flag)
				{
					position = _gameOrigin;
				}
				Vector3 val = _aimPoint - position;
				Vector3 val2 = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : ((Component)_thrower).transform.forward);
				float value = Settings.ThrowSpeed.Value;
				float num = value * 0.625f;
				Vector3 val3 = position;
				Vector3 velocity = val2 * num;
				float acceleration = (value - num) / 0.25f;
				float maxSpeed = value;
				Quaternion? release = (flag ? new Quaternion?(rotation) : ((Quaternion?)null));
				BeginFlight(val3, velocity, 0f, 0f, fresh: true, default(Vector3), acceleration, maxSpeed, precision: false, release);
				_launchDirection = val2;
				_aimTurnPending = flag;
				Place(position, flag ? rotation : FlightFrame(val2));
			}
		}

		private Vector3 AimPoint(Vector3 origin, Vector3 direction)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			float value = Settings.MaxFlightDistance.Value;
			int num = Physics.SphereCastNonAlloc(origin, 0.15f, direction, Hits, value, AxeHits.SolidMask, (QueryTriggerInteraction)1);
			AxeHits.SortByDistance(Hits, num);
			for (int i = 0; i < num; i++)
			{
				Collider collider = ((RaycastHit)(ref Hits[i])).collider;
				if ((Object)(object)collider == (Object)null)
				{
					continue;
				}
				GameObject val = Projectile.FindHitObject(collider);
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)((Component)_thrower).gameObject))
				{
					Character component = val.GetComponent<Character>();
					if (!((Object)(object)component != (Object)null) || AxeHits.IsValidTarget((Character)(object)_thrower, component, null))
					{
						return origin + direction * Mathf.Max(((RaycastHit)(ref Hits[i])).distance, 2f);
					}
				}
			}
			return origin + direction * value;
		}

		internal void InitMirror(AxeKeeper keeper, Player thrower, int quality)
		{
			_authority = false;
			_keeper = keeper;
			_thrower = thrower;
			SetQuality(quality);
		}

		internal void ApplyNetState(AxeNetState state)
		{
			//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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result