Decompiled source of WoodcutterNPC v1.1.0

plugins/WoodcutterNPC.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using Splatform;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.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 WoodcutterNPC
{
	internal static class ModUi
	{
		private static bool _waitForMouseRelease;

		internal static bool IsOpen
		{
			get
			{
				if (!WoodcutterSettingsWindow.IsOpen)
				{
					return WoodcutterPostWindow.IsOpen;
				}
				return true;
			}
		}

		internal static bool BlocksGameInput
		{
			get
			{
				if (IsOpen)
				{
					return true;
				}
				if (_waitForMouseRelease && !Input.GetMouseButton(0) && !Input.GetMouseButton(1) && !Input.GetMouseButton(2))
				{
					_waitForMouseRelease = false;
				}
				return _waitForMouseRelease;
			}
		}

		internal static void NotifyClosed()
		{
			_waitForMouseRelease = true;
		}
	}
	[HarmonyPatch(typeof(Container), "GetHoverText")]
	internal static class Container_GetHoverText_Post_Patch
	{
		private static void Postfix(Container __instance, ref string __result)
		{
			WoodcutterHirePost component = ((Component)__instance).GetComponent<WoodcutterHirePost>();
			if ((Object)(object)component != (Object)null)
			{
				__result = component.BuildHoverText();
			}
		}
	}
	[HarmonyPatch(typeof(Character), "GetHoverText")]
	internal static class Character_GetHoverText_Patch
	{
		private static void Postfix(Character __instance, ref string __result)
		{
			WoodcutterInteraction component = ((Component)__instance).GetComponent<WoodcutterInteraction>();
			if ((Object)(object)component != (Object)null)
			{
				__result = component.BuildHoverText();
			}
		}
	}
	[HarmonyPatch(typeof(ZNetScene), "Awake")]
	internal static class ZNetScene_Awake_LogTreeSpecies_Patch
	{
		private static void Postfix()
		{
			TreeSpecies.LogKnownPrefabs();
		}
	}
	[HarmonyPatch(typeof(Container), "Interact")]
	internal static class Container_Interact_Patch
	{
		private static bool Prefix(Container __instance, Humanoid character, bool hold, bool alt, ref bool __result)
		{
			WoodcutterHirePost component = ((Component)__instance).GetComponent<WoodcutterHirePost>();
			if ((Object)(object)component != (Object)null)
			{
				if (!alt)
				{
					return true;
				}
				if (!hold && (Object)(object)character == (Object)(object)Player.m_localPlayer)
				{
					WoodcutterPostWindow.Open(component);
				}
				__result = !hold;
				return false;
			}
			WoodcutterInteraction component2 = ((Component)__instance).GetComponent<WoodcutterInteraction>();
			if ((Object)(object)component2 == (Object)null)
			{
				return true;
			}
			if (hold)
			{
				__result = false;
				return false;
			}
			if (!alt)
			{
				return true;
			}
			WoodcutterSettingsWindow.Open(component2);
			__result = true;
			return false;
		}
	}
	[HarmonyPatch(typeof(Character), "OnDeath")]
	internal static class Character_OnDeath_DropLootChest_Patch
	{
		private const string ChestPrefabName = "piece_chest_wood";

		private static void Prefix(Character __instance)
		{
			//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_0094: Unknown result type (might be due to invalid IL or missing references)
			WoodcutterInteraction component = ((Component)__instance).GetComponent<WoodcutterInteraction>();
			Container component2 = ((Component)__instance).GetComponent<Container>();
			if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null)
			{
				return;
			}
			Inventory inventory = component2.GetInventory();
			if (inventory == null || inventory.NrOfItems() == 0)
			{
				return;
			}
			GameObject prefab = ZNetScene.instance.GetPrefab("piece_chest_wood");
			if ((Object)(object)prefab == (Object)null)
			{
				Logger.LogWarning((object)"WoodcutterNPC: could not find 'piece_chest_wood' prefab to drop a loot chest on death.");
				return;
			}
			GameObject obj = Object.Instantiate<GameObject>(prefab, ((Component)__instance).transform.position, Quaternion.identity);
			WoodcutterLootChest.Mark(obj);
			Container component3 = obj.GetComponent<Container>();
			if (component3 != null)
			{
				Inventory inventory2 = component3.GetInventory();
				if (inventory2 != null)
				{
					inventory2.MoveAll(inventory);
				}
			}
			WoodcutterDeathPin.Add(obj.transform.position);
		}
	}
	[HarmonyPatch(typeof(Container), "CheckForChanges")]
	internal static class Container_CheckForChanges_BreakEmptyLootChest_Patch
	{
		private static void Postfix(Container __instance)
		{
			if (WoodcutterLootChest.ShouldBreak(__instance))
			{
				WoodcutterLootChest.Break(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(Container), "OnContainerChanged")]
	internal static class Container_OnContainerChanged_RemoveDeathPin_Patch
	{
		private static void Postfix(Container __instance)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			Inventory inventory = __instance.GetInventory();
			if (inventory != null && inventory.NrOfItems() == 0 && (Object)(object)((Component)__instance).GetComponent<WoodcutterInteraction>() == (Object)null)
			{
				WoodcutterDeathPin.RemoveAt(((Component)__instance).transform.position);
			}
		}
	}
	internal static class WoodcutterLootChest
	{
		private const string ZdoKey = "WoodcutterNPC_LootChest";

		private static readonly FieldRef<Container, uint> LastRevisionRef = AccessTools.FieldRefAccess<Container, uint>("m_lastRevision");

		internal static void Mark(GameObject chest)
		{
			ZNetView component = chest.GetComponent<ZNetView>();
			ZDO obj = ((component != null) ? component.GetZDO() : null);
			if (obj != null)
			{
				obj.Set("WoodcutterNPC_LootChest", true);
			}
		}

		internal static bool ShouldBreak(Container container)
		{
			ZNetView component = ((Component)container).GetComponent<ZNetView>();
			if ((Object)(object)component == (Object)null || !component.IsValid() || !component.IsOwner() || !component.GetZDO().GetBool("WoodcutterNPC_LootChest", false))
			{
				return false;
			}
			Inventory inventory = container.GetInventory();
			if (inventory != null && inventory.NrOfItems() == 0 && !container.IsInUse())
			{
				return LastRevisionRef.Invoke(container) != uint.MaxValue;
			}
			return false;
		}

		internal static void Break(Container container)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			WoodcutterDeathPin.RemoveAt(((Component)container).transform.position);
			WearNTear component = ((Component)container).GetComponent<WearNTear>();
			if ((Object)(object)component != (Object)null)
			{
				component.Remove(true);
			}
			else
			{
				((Component)container).GetComponent<ZNetView>().Destroy();
			}
		}
	}
	internal static class WoodcutterDeathPin
	{
		private const float MatchRadius = 1f;

		private static readonly FieldRef<Minimap, List<PinData>> PinsRef = AccessTools.FieldRefAccess<Minimap, List<PinData>>("m_pins");

		internal static void Add(Vector3 position)
		{
			//IL_0013: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Minimap.instance == (Object)null))
			{
				Minimap.instance.AddPin(position, (PinType)4, WoodcutterTexts.T("npc_name"), true, false, 0L, default(PlatformUserID));
			}
		}

		internal static void RemoveAt(Vector3 position)
		{
			//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)
			if (!((Object)(object)Minimap.instance == (Object)null))
			{
				HashSet<string> names = new HashSet<string>(WoodcutterTexts.AllLanguages("npc_name"));
				PinData val = PinsRef.Invoke(Minimap.instance).Find((PinData pin) => (int)pin.m_type == 4 && names.Contains(pin.m_name) && Vector3.Distance(pin.m_pos, position) <= 1f);
				if (val != null)
				{
					Minimap.instance.RemovePin(val);
				}
			}
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "Show")]
	internal static class InventoryGui_Show_HideSidePanels_Patch
	{
		private static void Postfix(InventoryGui __instance, Container container)
		{
			bool flag = (Object)(object)container != (Object)null && (Object)(object)((Component)container).GetComponent<WoodcutterInteraction>() != (Object)null;
			InventoryGuiPanels.SetVisible(__instance, !flag);
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "Hide")]
	internal static class InventoryGui_Hide_RestoreSidePanels_Patch
	{
		private static void Postfix(InventoryGui __instance)
		{
			InventoryGuiPanels.SetVisible(__instance, visible: true);
		}
	}
	[HarmonyPatch(typeof(InventoryGrid), "DropItem")]
	internal static class InventoryGrid_DropItem_AxeSlotPatch
	{
		private static bool Prefix(InventoryGrid __instance, ItemData item, Vector2i pos, ref bool __result)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			Inventory inventory = __instance.GetInventory();
			if (!WoodcutterAxeSlot.IsAxeCell(inventory, pos.x, pos.y) || WoodcutterAxeSlot.IsAxe(item))
			{
				return true;
			}
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				((Character)Player.m_localPlayer).Message((MessageType)2, WoodcutterTexts.T(WoodcutterAxeSlot.IsPost(inventory) ? "drop_post_axerow" : "drop_axeslot"), 0, (Sprite)null, false);
			}
			__result = false;
			return false;
		}
	}
	[HarmonyPatch(typeof(Inventory), "MoveItemToThis", new Type[]
	{
		typeof(Inventory),
		typeof(ItemData)
	})]
	internal static class Inventory_MoveItemToThis_AxeSlotPatch
	{
		private static void Postfix(Inventory __instance, ItemData item)
		{
			if (WoodcutterAxeSlot.IsManaged(__instance))
			{
				WoodcutterAxeSlot.Rearrange(__instance, item);
			}
		}
	}
	[HarmonyPatch(typeof(InventoryGrid), "UpdateGui")]
	internal static class InventoryGrid_UpdateGui_AxeSlotPatch
	{
		private sealed class Changes
		{
			public readonly List<Image> Icons = new List<Image>();

			public readonly List<KeyValuePair<Image, Color>> Backgrounds = new List<KeyValuePair<Image, Color>>();
		}

		private static readonly Color GhostTint = new Color(1f, 1f, 1f, 0.25f);

		private static readonly Color AxeCellTint = new Color(1f, 0.72f, 0.3f, 1f);

		private static readonly MethodInfo GetElementMethod = AccessTools.Method(typeof(InventoryGrid), "GetElement", (Type[])null, (Type[])null);

		private static readonly Dictionary<InventoryGrid, Changes> ByGrid = new Dictionary<InventoryGrid, Changes>();

		private static void Postfix(InventoryGrid __instance)
		{
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_0103: 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)
			if (!ByGrid.TryGetValue(__instance, out var value))
			{
				value = new Changes();
				ByGrid[__instance] = value;
			}
			Undo(value);
			Inventory inventory = __instance.GetInventory();
			if (!WoodcutterAxeSlot.IsManaged(inventory) || GetElementMethod == null)
			{
				return;
			}
			Sprite ghostIcon = WoodcutterAxeSlot.GhostIcon;
			int width = inventory.GetWidth();
			for (int i = 0; i < inventory.GetHeight(); i++)
			{
				for (int j = 0; j < width; j++)
				{
					if (!WoodcutterAxeSlot.IsAxeCell(inventory, j, i))
					{
						continue;
					}
					object? obj = GetElementMethod.Invoke(__instance, new object[3] { j, i, width });
					InventoryElement val = (InventoryElement)((obj is InventoryElement) ? obj : null);
					if (!((Object)(object)val == (Object)null))
					{
						Image val2 = (((Object)(object)val.m_button != (Object)null) ? ((Selectable)val.m_button).image : null);
						if ((Object)(object)val2 != (Object)null)
						{
							value.Backgrounds.Add(new KeyValuePair<Image, Color>(val2, ((Graphic)val2).color));
							((Graphic)val2).color = ((Graphic)val2).color * AxeCellTint;
						}
						if ((Object)(object)ghostIcon != (Object)null && (Object)(object)val.m_icon != (Object)null && inventory.GetItemAt(j, i) == null)
						{
							val.m_icon.sprite = ghostIcon;
							((Graphic)val.m_icon).color = GhostTint;
							((Behaviour)val.m_icon).enabled = true;
							value.Icons.Add(val.m_icon);
						}
					}
				}
			}
		}

		private static void Undo(Changes changes)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			foreach (Image icon in changes.Icons)
			{
				if ((Object)(object)icon != (Object)null)
				{
					((Graphic)icon).color = Color.white;
				}
			}
			changes.Icons.Clear();
			foreach (KeyValuePair<Image, Color> background in changes.Backgrounds)
			{
				if ((Object)(object)background.Key != (Object)null)
				{
					((Graphic)background.Key).color = background.Value;
				}
			}
			changes.Backgrounds.Clear();
		}
	}
	[HarmonyPatch(typeof(Player), "TakeInput")]
	internal static class Player_TakeInput_Patch
	{
		private static void Postfix(ref bool __result)
		{
			if (ModUi.BlocksGameInput)
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerController), "TakeInput")]
	internal static class PlayerController_TakeInput_Patch
	{
		private static void Postfix(ref bool __result)
		{
			if (ModUi.BlocksGameInput)
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")]
	internal static class GameCamera_UpdateMouseCapture_Patch
	{
		private static bool Prefix()
		{
			if (!ModUi.IsOpen)
			{
				return true;
			}
			ZCursor.LockState = (CursorLockMode)0;
			ZCursor.Show();
			return false;
		}
	}
	internal static class InventoryGuiPanels
	{
		internal static void SetVisible(InventoryGui gui, bool visible)
		{
			if ((Object)(object)gui.m_crafting != (Object)null)
			{
				((Component)gui.m_crafting).gameObject.SetActive(visible);
			}
			if ((Object)(object)gui.m_info != (Object)null)
			{
				((Component)gui.m_info).gameObject.SetActive(visible);
			}
		}
	}
	[BepInPlugin("com.roman.woodcutternpc", "WoodcutterNPC", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private const string PluginGUID = "com.roman.woodcutternpc";

		private const string PluginName = "WoodcutterNPC";

		private const string PluginVersion = "1.1.0";

		private const string BaseCreatureName = "Skeleton";

		internal const string CreatureName = "WoodcutterNPC";

		internal const int InventoryWidth = 6;

		internal const int InventoryHeight = 3;

		private const string BasePostPieceName = "piece_workbench_ext1";

		private const string PostPieceName = "piece_woodcutter_post";

		private const string RuntimeHostName = "WoodcutterNPC_RuntimeHost";

		private static ConfigEntry<bool> _useDurability;

		private static ConfigEntry<float> _chopDamageMultiplier;

		private static ConfigEntry<float> _chopInterval;

		private static ConfigEntry<float> _defaultZoneRadius;

		private static ConfigEntry<bool> _showMapPins;

		private static ConfigEntry<bool> _notifications;

		private static ConfigEntry<string> _language;

		private static ConfigEntry<int> _hirePrice1;

		private static ConfigEntry<int> _hirePrice2;

		private static ConfigEntry<int> _hirePrice3;

		private static ConfigEntry<int> _rehireDiscount;

		private static ConfigEntry<int> _level2Cores;

		private static ConfigEntry<int> _level3Cores;

		private static ConfigEntry<float> _maxHealth;

		private static ConfigEntry<float> _regenAmount;

		private static ConfigEntry<float> _regenInterval;

		private static ConfigEntry<bool> _pathfinding;

		private static ConfigEntry<int> _repairCostPercent;

		private static ConfigEntry<float> _skillGainRate;

		private static ConfigEntry<int> _skillStartLevel;

		private Harmony _harmony;

		internal static bool UseDurability
		{
			get
			{
				if (_useDurability != null)
				{
					return _useDurability.Value;
				}
				return true;
			}
		}

		internal static float ChopDamageMultiplier
		{
			get
			{
				if (_chopDamageMultiplier == null)
				{
					return 1f;
				}
				return _chopDamageMultiplier.Value;
			}
		}

		internal static float ChopInterval
		{
			get
			{
				if (_chopInterval == null)
				{
					return 1.5f;
				}
				return _chopInterval.Value;
			}
		}

		internal static bool ShowMapPins
		{
			get
			{
				if (_showMapPins != null)
				{
					return _showMapPins.Value;
				}
				return true;
			}
		}

		internal static bool Notifications
		{
			get
			{
				if (_notifications != null)
				{
					return _notifications.Value;
				}
				return true;
			}
		}

		internal static float MaxHealth
		{
			get
			{
				if (_maxHealth == null)
				{
					return 300f;
				}
				return _maxHealth.Value;
			}
		}

		internal static float RegenAmount
		{
			get
			{
				if (_regenAmount == null)
				{
					return 5f;
				}
				return _regenAmount.Value;
			}
		}

		internal static float RegenInterval
		{
			get
			{
				if (_regenInterval == null)
				{
					return 2.5f;
				}
				return _regenInterval.Value;
			}
		}

		internal static float SkillGainRate
		{
			get
			{
				if (_skillGainRate == null)
				{
					return 1f;
				}
				return _skillGainRate.Value;
			}
		}

		internal static int SkillStartLevel
		{
			get
			{
				if (_skillStartLevel == null)
				{
					return 0;
				}
				return _skillStartLevel.Value;
			}
		}

		internal static int RepairCostPercent
		{
			get
			{
				if (_repairCostPercent == null)
				{
					return 30;
				}
				return _repairCostPercent.Value;
			}
		}

		internal static bool UsePathfinding
		{
			get
			{
				if (_pathfinding != null)
				{
					return _pathfinding.Value;
				}
				return true;
			}
		}

		internal static int HirePrice1
		{
			get
			{
				if (_hirePrice1 == null)
				{
					return 50;
				}
				return _hirePrice1.Value;
			}
		}

		internal static int HirePrice2
		{
			get
			{
				if (_hirePrice2 == null)
				{
					return 100;
				}
				return _hirePrice2.Value;
			}
		}

		internal static int HirePrice3
		{
			get
			{
				if (_hirePrice3 == null)
				{
					return 200;
				}
				return _hirePrice3.Value;
			}
		}

		internal static int RehireDiscountPercent
		{
			get
			{
				if (_rehireDiscount == null)
				{
					return 50;
				}
				return _rehireDiscount.Value;
			}
		}

		internal static int Level2Cores
		{
			get
			{
				if (_level2Cores == null)
				{
					return 10;
				}
				return _level2Cores.Value;
			}
		}

		internal static int Level3Cores
		{
			get
			{
				if (_level3Cores == null)
				{
					return 20;
				}
				return _level3Cores.Value;
			}
		}

		internal static float DefaultZoneRadius
		{
			get
			{
				if (_defaultZoneRadius == null)
				{
					return 100f;
				}
				return _defaultZoneRadius.Value;
			}
		}

		internal static void ApplyLanguage()
		{
			string gameLanguage = ((Localization.instance != null) ? Localization.instance.GetSelectedLanguage() : null);
			WoodcutterTexts.Current = WoodcutterTexts.Resolve((_language != null) ? _language.Value : "Auto", gameLanguage);
		}

		private void Awake()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Expected O, but got Unknown
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Expected O, but got Unknown
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Expected O, but got Unknown
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Expected O, but got Unknown
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Expected O, but got Unknown
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Expected O, but got Unknown
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Expected O, but got Unknown
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Expected O, but got Unknown
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Expected O, but got Unknown
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Expected O, but got Unknown
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Expected O, but got Unknown
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Expected O, but got Unknown
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_040e: Expected O, but got Unknown
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Expected O, but got Unknown
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_044b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_0465: Expected O, but got Unknown
			_useDurability = ((BaseUnityPlugin)this).Config.Bind<bool>("Axe", "UseDurability", true, "Whether the axe in the woodcutter's axe slot loses durability while it works. A worn-out axe stops the NPC until the player repairs it; it is never destroyed.");
			_chopDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Axe", "ChopDamageMultiplier", 1f, new ConfigDescription("Multiplier on top of the damage a player with the woodcutter's skill level would do with that same axe. 1.0 = exactly like such a player.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
			_chopInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Axe", "ChopInterval", 1.5f, new ConfigDescription("Seconds between swings.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 10f), Array.Empty<object>()));
			_defaultZoneRadius = ((BaseUnityPlugin)this).Config.Bind<float>("WorkZone", "DefaultRadius", 100f, new ConfigDescription("Radius in meters of a new Woodcutter's Post work zone. Its woodcutters only chop and collect inside it. Each post's radius can be changed in-game from the post's window (alt interact on the post).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 300f), Array.Empty<object>()));
			_showMapPins = ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "ShowWoodcutterPins", true, "Show a live pin with an axe icon on the map where each woodcutter currently is.");
			_language = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Language", "Auto", new ConfigDescription("Language of the mod's texts. Auto follows the game's language (English if it isn't one of the others). The names of the woodcutter and the post are set when the game starts, so changing this needs a restart for those; the windows switch right away.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[4] { "Auto", "English", "Ukrainian", "Russian" }), Array.Empty<object>()));
			_notifications = ((BaseUnityPlugin)this).Config.Bind<bool>("Notifications", "Enabled", true, "Show a message when a woodcutter's axe drops to 5% durability and when it breaks.");
			_maxHealth = ((BaseUnityPlugin)this).Config.Bind<float>("Health", "MaxHealth", 300f, new ConfigDescription("Woodcutter's max health. Falling trees hit hard, so it is well above a skeleton's.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 10000f), Array.Empty<object>()));
			_regenAmount = ((BaseUnityPlugin)this).Config.Bind<float>("Health", "RegenAmount", 5f, new ConfigDescription("Health restored every RegenInterval seconds while below max (0 = no regeneration).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1000f), Array.Empty<object>()));
			_regenInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Health", "RegenInterval", 2.5f, new ConfigDescription("Seconds between regeneration ticks.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 60f), Array.Empty<object>()));
			_skillGainRate = ((BaseUnityPlugin)this).Config.Bind<float>("Skill", "GainRate", 1f, new ConfigDescription("How fast woodcutters get better at woodcutting. Each swing counts like a player's (the world's skill gain modifier applies too); 1.0 = as fast as a player, 0 = never.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			_skillStartLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Skill", "StartLevel", 0, new ConfigDescription("Woodcutting skill of a newly hired woodcutter (and of ones hired before skills existed). A player's damage with an axe goes from about 40% at 0 to 100% at 100.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			_repairCostPercent = ((BaseUnityPlugin)this).Config.Bind<int>("Repair", "CostPercent", 30, new ConfigDescription("When a post has automatic axe repair ticked, a woodcutter whose axe breaks repairs it there, paying this share of the axe's main crafting material - the one its recipe takes the most of, handle wood not counted - from the post's storage (at least 1).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
			_pathfinding = ((BaseUnityPlugin)this).Config.Bind<bool>("Movement", "Pathfinding", true, "Woodcutters find their way around rocks, trees, buildings and cliffs, the way the game's creatures do. Off: they walk in straight lines and give up on whatever is in the way.");
			AcceptableValueRange<int> val = new AcceptableValueRange<int>(0, 99999);
			_hirePrice1 = ((BaseUnityPlugin)this).Config.Bind<int>("Hire", "Price1", 50, new ConfigDescription("Coins for the 1st woodcutter in the world (post level 1).", (AcceptableValueBase)(object)val, Array.Empty<object>()));
			_hirePrice2 = ((BaseUnityPlugin)this).Config.Bind<int>("Hire", "Price2", 100, new ConfigDescription("Coins for the 2nd woodcutter (needs post level 2).", (AcceptableValueBase)(object)val, Array.Empty<object>()));
			_hirePrice3 = ((BaseUnityPlugin)this).Config.Bind<int>("Hire", "Price3", 200, new ConfigDescription("Coins for the 3rd woodcutter (needs post level 3).", (AcceptableValueBase)(object)val, Array.Empty<object>()));
			_rehireDiscount = ((BaseUnityPlugin)this).Config.Bind<int>("Hire", "RehireThirdDiscountPercent", 50, new ConfigDescription("Discount on hiring a 3rd woodcutter again, once one has been hired in this world before (after it died or was dismissed).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			AcceptableValueRange<int> val2 = new AcceptableValueRange<int>(0, 9999);
			_level2Cores = ((BaseUnityPlugin)this).Config.Bind<int>("Upgrade", "Level2SurtlingCores", 10, new ConfigDescription("Surtling cores to upgrade the Woodcutter's Post to level 2 (one-off per world).", (AcceptableValueBase)(object)val2, Array.Empty<object>()));
			_level3Cores = ((BaseUnityPlugin)this).Config.Bind<int>("Upgrade", "Level3SurtlingCores", 20, new ConfigDescription("Surtling cores to upgrade the Woodcutter's Post to level 3 (one-off per world).", (AcceptableValueBase)(object)val2, Array.Empty<object>()));
			_harmony = new Harmony("com.roman.woodcutternpc");
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			GameObject val3 = new GameObject("WoodcutterNPC_RuntimeHost");
			val3.AddComponent<WoodcutterSettingsWindow>();
			val3.AddComponent<WoodcutterPostWindow>();
			val3.AddComponent<WoodcutterMapPins>();
			val3.AddComponent<WoodcutterZoneRings>();
			val3.AddComponent<WoodcutterNotificationListener>();
			Object.DontDestroyOnLoad((Object)val3);
			CreatureManager.OnVanillaCreaturesAvailable += RegisterWoodcutterCreature;
			PrefabManager.OnVanillaPrefabsAvailable += RegisterHirePost;
		}

		private void RegisterHirePost()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			ApplyLanguage();
			PrefabManager.OnVanillaPrefabsAvailable -= RegisterHirePost;
			PieceConfig val = new PieceConfig();
			val.Name = WoodcutterHirePost.DisplayName;
			val.Description = WoodcutterTexts.T("post_desc");
			val.PieceTable = PieceTables.Hammer;
			val.Category = PieceCategories.Crafting;
			val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig("Wood", 10, 0, true)
			};
			PieceConfig val2 = val;
			CustomPiece val3 = new CustomPiece("piece_woodcutter_post", "piece_workbench_ext1", val2);
			if ((Object)(object)val3.PiecePrefab == (Object)null)
			{
				Logger.LogError((object)"WoodcutterNPC: could not clone base piece 'piece_workbench_ext1'");
				return;
			}
			GameObject piecePrefab = val3.PiecePrefab;
			val3.Piece.m_craftingStation = null;
			StationExtension component = piecePrefab.GetComponent<StationExtension>();
			if ((Object)(object)component != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component);
			}
			Container obj = piecePrefab.AddComponent<Container>();
			obj.m_name = WoodcutterHirePost.DisplayName;
			obj.m_width = 5;
			obj.m_height = 5;
			obj.m_privacy = (PrivacySetting)2;
			obj.m_checkGuardStone = true;
			obj.m_autoDestroyEmpty = false;
			piecePrefab.AddComponent<WoodcutterHirePost>();
			PieceManager.Instance.AddPiece(val3);
		}

		private void RegisterWoodcutterCreature()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			ApplyLanguage();
			CreatureManager.OnVanillaCreaturesAvailable -= RegisterWoodcutterCreature;
			CreatureConfig val = new CreatureConfig
			{
				Name = "WoodcutterNPC",
				Faction = (Faction)11
			};
			CustomCreature val2 = new CustomCreature("WoodcutterNPC", "Skeleton", val);
			if ((Object)(object)val2.Prefab == (Object)null)
			{
				Logger.LogError((object)"WoodcutterNPC: could not clone base prefab 'Skeleton'");
				return;
			}
			GameObject prefab = val2.Prefab;
			MonsterAI component = prefab.GetComponent<MonsterAI>();
			if ((Object)(object)component != (Object)null)
			{
				((Behaviour)component).enabled = false;
				component.m_sleeping = false;
			}
			Character component2 = prefab.GetComponent<Character>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.m_speed = 2f;
				component2.m_walkSpeed = 2f;
				component2.m_runSpeed = 2f;
				component2.m_health = MaxHealth;
				component2.m_name = WoodcutterTexts.T("npc_name");
			}
			Container val3 = prefab.AddComponent<Container>();
			val3.m_name = WoodcutterTexts.T("npc_name");
			val3.m_width = 6;
			val3.m_height = 3;
			val3.m_privacy = (PrivacySetting)2;
			val3.m_checkGuardStone = false;
			val3.m_autoDestroyEmpty = false;
			prefab.AddComponent<WoodcutterInteraction>().Inventory = val3;
			prefab.AddComponent<WoodcutterAI>();
			Logger.LogInfo((object)(CreatureManager.Instance.AddCreature(val2) ? "WoodcutterNPC: 'WoodcutterNPC' registered. Spawn with 'devcommands' then 'spawn WoodcutterNPC 1'." : "WoodcutterNPC: 'WoodcutterNPC' failed validation, see warnings above."));
		}
	}
	internal static class TreeSpecies
	{
		internal const int AllMask = -1;

		private static readonly Dictionary<string, int> IndexByPrefab = new Dictionary<string, int>();

		internal static int Count => WoodcutterLogic.SpeciesCount;

		internal static int IndexOf(MonoBehaviour treeOrLog)
		{
			string prefabName = Utils.GetPrefabName(((Component)treeOrLog).gameObject);
			if (!IndexByPrefab.TryGetValue(prefabName, out var value))
			{
				value = WoodcutterLogic.ClassifySpecies(prefabName);
				IndexByPrefab[prefabName] = value;
			}
			return value;
		}

		internal static bool IsAllowed(MonoBehaviour treeOrLog, int mask)
		{
			return WoodcutterLogic.IsSpeciesAllowed(mask, IndexOf(treeOrLog));
		}

		internal static void LogKnownPrefabs()
		{
			if (!((Object)(object)ZNetScene.instance == (Object)null))
			{
				IEnumerable<string> values = from p in ZNetScene.instance.m_prefabs
					where (Object)(object)p != (Object)null && ((Object)(object)p.GetComponent<TreeBase>() != (Object)null || (Object)(object)p.GetComponent<TreeLog>() != (Object)null)
					select ((Object)p).name + " -> " + WoodcutterTexts.Species[0][WoodcutterLogic.ClassifySpecies(((Object)p).name)] into line
					orderby line
					select line;
				Logger.LogInfo((object)("WoodcutterNPC: tree species by prefab:\n  " + string.Join("\n  ", values)));
			}
		}
	}
	internal static class UiTheme
	{
		internal sealed class WindowState
		{
			internal float Height;

			internal float Scale;

			internal void Reset()
			{
				Height = 0f;
				Scale = 0f;
			}
		}

		private const float ReferenceHeight = 1080f;

		internal static readonly Color Panel = Hex(1973015);

		internal static readonly Color PanelBorder = Hex(4866100);

		internal static readonly Color Card = Hex(2762272);

		internal static readonly Color CardBorder = Hex(3814444);

		internal static readonly Color Accent = Hex(14723146);

		internal static readonly Color AccentHover = Hex(15776866);

		internal static readonly Color AccentPressed = Hex(12618804);

		internal static readonly Color Text = Hex(15656664);

		internal static readonly Color TextMuted = Hex(11116432);

		internal static readonly Color TextOnAccent = Hex(1973015);

		internal static readonly Color Button = Hex(3748651);

		internal static readonly Color ButtonHover = Hex(4866616);

		internal static readonly Color ButtonPressed = Hex(3090979);

		internal static readonly Color Success = Hex(6200919);

		internal static readonly Color SuccessHover = Hex(7189094);

		internal static readonly Color Danger = Hex(12145471);

		internal static readonly Color DangerHover = Hex(13460560);

		internal static GUIStyle PanelStyle;

		internal static GUIStyle CardStyle;

		internal static GUIStyle RowStyle;

		internal static GUIStyle RowTitle;

		internal static GUIStyle Title;

		internal static GUIStyle SectionHeader;

		internal static GUIStyle Label;

		internal static GUIStyle LabelMuted;

		internal static GUIStyle Hint;

		internal static GUIStyle BigValue;

		internal static GUIStyle ButtonStyle;

		internal static GUIStyle PrimaryButton;

		internal static GUIStyle SuccessButton;

		internal static GUIStyle DangerButton;

		internal static GUIStyle SmallButton;

		internal static GUIStyle CloseButton;

		internal static GUIStyle Chip;

		internal static GUIStyle PillSuccess;

		internal static GUIStyle PillDanger;

		internal static GUIStyle SliderTrack;

		internal static GUIStyle SliderThumb;

		private static GUIStyle _shadowStyle;

		private static Texture2D _dim;

		private static bool _ready;

		private const float ScreenMargin = 12f;

		private const float TopFraction = 0.08f;

		internal static void Window(int id, WindowState state, float width, WindowFunction draw)
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Invalid comparison between Unknown and I4
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: 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_01a7: Unknown result type (might be due to invalid IL or missing references)
			EnsureStyles();
			bool num = state.Height > 0f;
			if (num && state.Scale <= 0f)
			{
				float num2 = Mathf.Max(1f, (float)Screen.height / 1080f);
				float num3 = (float)Screen.height * 0.92f / (state.Height + 12f);
				state.Scale = Mathf.Min(num2, num3);
			}
			float num4 = ((state.Scale > 0f) ? state.Scale : Mathf.Max(1f, (float)Screen.height / 1080f));
			GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(num4, num4, 1f));
			float num5 = (float)Screen.width / num4;
			float num6 = (float)Screen.height / num4;
			GUI.DrawTexture(new Rect(0f, 0f, num5, num6), (Texture)(object)_dim);
			float num7 = Mathf.Round(Mathf.Max(12f, num6 * 0.08f));
			float num8 = Mathf.Round((num5 - width) / 2f);
			Color color = GUI.color;
			if (!num)
			{
				GUI.color = Color.clear;
			}
			else
			{
				GUI.Box(new Rect(num8 - 14f, num7 - 10f, width + 28f, state.Height + 32f), GUIContent.none, _shadowStyle);
			}
			GUILayout.BeginArea(new Rect(num8, num7, width, Mathf.Max(100f, num6 - num7 - 12f)));
			GUILayout.BeginVertical(PanelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) });
			draw.Invoke(id);
			GUILayout.EndVertical();
			if ((int)Event.current.type == 7)
			{
				Rect lastRect = GUILayoutUtility.GetLastRect();
				float height = ((Rect)(ref lastRect)).height;
				if (height > 0f)
				{
					state.Height = height;
				}
			}
			GUILayout.EndArea();
			GUI.color = color;
			GUI.matrix = Matrix4x4.identity;
		}

		internal static bool Header(string title, string subtitle = null, GUIStyle pill = null, string pillText = null)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUILayout.Label(title, Title, Array.Empty<GUILayoutOption>());
			if (subtitle != null)
			{
				GUILayout.Label(subtitle, LabelMuted, Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndVertical();
			GUILayout.FlexibleSpace();
			if (pill != null)
			{
				GUILayout.Label(pillText, pill, Array.Empty<GUILayoutOption>());
				GUILayout.Space(6f);
			}
			bool result = GUILayout.Button("X", CloseButton, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.Space(10f);
			return result;
		}

		internal static void BeginCard(string header)
		{
			GUILayout.BeginVertical(CardStyle, Array.Empty<GUILayoutOption>());
			if (header != null)
			{
				GUILayout.Label(header.ToUpperInvariant(), SectionHeader, Array.Empty<GUILayoutOption>());
				GUILayout.Space(4f);
			}
		}

		internal static void EndCard()
		{
			GUILayout.EndVertical();
			GUILayout.Space(10f);
		}

		internal static float Slider(float value, float min, float max)
		{
			return GUILayout.HorizontalSlider(value, min, max, SliderTrack, SliderThumb, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
		}

		private static void EnsureStyles()
		{
			//IL_0039: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_0097: Expected O, but got Unknown
			//IL_0097: 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_00a2: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_00cd: 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_00e0: Expected O, but got Unknown
			//IL_00e5: Expected O, but got Unknown
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Expected O, but got Unknown
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Expected O, but got Unknown
			//IL_0141: Expected O, but got Unknown
			//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)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			//IL_0172: 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_0183: Expected O, but got Unknown
			//IL_0188: Expected O, but got Unknown
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Expected O, but got Unknown
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: 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_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: 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_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Expected O, but got Unknown
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Expected O, but got Unknown
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Expected O, but got Unknown
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b7: Expected O, but got Unknown
			//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d1: Expected O, but got Unknown
			//IL_04d6: Expected O, but got Unknown
			//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04db: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0505: Unknown result type (might be due to invalid IL or missing references)
			//IL_050b: Unknown result type (might be due to invalid IL or missing references)
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0525: Unknown result type (might be due to invalid IL or missing references)
			//IL_0535: Expected O, but got Unknown
			if (!_ready || !((Object)(object)PanelStyle.normal.background != (Object)null))
			{
				_ready = true;
				_dim = Solid(new Color(0f, 0f, 0f, 0.35f));
				GUIStyle val = new GUIStyle();
				val.normal.background = Rounded(new Color(0f, 0f, 0f, 0.55f), 24, 0, Color.clear, soft: true);
				val.border = new RectOffset(24, 24, 24, 24);
				_shadowStyle = val;
				GUIStyle val2 = new GUIStyle();
				val2.normal.background = Rounded(Panel, 12, 2, PanelBorder);
				val2.border = new RectOffset(14, 14, 14, 14);
				val2.padding = new RectOffset(20, 20, 18, 16);
				PanelStyle = val2;
				GUIStyle val3 = new GUIStyle();
				val3.normal.background = Rounded(Card, 8, 1, CardBorder);
				val3.border = new RectOffset(10, 10, 10, 10);
				val3.padding = new RectOffset(14, 14, 12, 14);
				val3.margin = new RectOffset(0, 0, 0, 0);
				CardStyle = val3;
				GUIStyle val4 = new GUIStyle();
				val4.normal.background = Rounded(Panel, 6, 1, CardBorder);
				val4.border = new RectOffset(8, 8, 8, 8);
				val4.padding = new RectOffset(10, 10, 6, 6);
				RowStyle = val4;
				Title = TextStyle(20, Accent, (FontStyle)1);
				SectionHeader = TextStyle(11, TextMuted, (FontStyle)1);
				Label = TextStyle(14, Text, (FontStyle)0);
				LabelMuted = TextStyle(12, TextMuted, (FontStyle)0);
				Hint = TextStyle(12, TextMuted, (FontStyle)0);
				Hint.wordWrap = true;
				BigValue = TextStyle(22, Text, (FontStyle)1);
				RowTitle = TextStyle(15, Text, (FontStyle)1);
				RowTitle.margin = new RectOffset(0, 8, 0, 0);
				ButtonStyle = MakeButton(Button, ButtonHover, ButtonPressed, Text, 14, 36f);
				PrimaryButton = MakeButton(Accent, AccentHover, AccentPressed, TextOnAccent, 14, 36f);
				PrimaryButton.fontStyle = (FontStyle)1;
				SuccessButton = MakeButton(Success, SuccessHover, Success, Color.white, 14, 36f);
				SuccessButton.fontStyle = (FontStyle)1;
				DangerButton = MakeButton(Danger, DangerHover, Danger, Color.white, 14, 36f);
				DangerButton.fontStyle = (FontStyle)1;
				SmallButton = MakeButton(Button, ButtonHover, ButtonPressed, Text, 12, 26f);
				SmallButton.padding = new RectOffset(10, 10, 4, 4);
				CloseButton = MakeButton(Card, Danger, Danger, TextMuted, 14, 28f);
				CloseButton.fixedWidth = 28f;
				CloseButton.hover.textColor = Color.white;
				CloseButton.padding = new RectOffset(0, 0, 0, 0);
				Chip = MakeButton(Card, ButtonHover, ButtonPressed, TextMuted, 13, 32f, Rounded(Card, 16, 1, PanelBorder));
				Chip.border = new RectOffset(16, 16, 16, 16);
				Chip.onNormal.background = Rounded(Accent, 16, 0, Accent);
				Chip.onHover.background = Rounded(AccentHover, 16, 0, AccentHover);
				Chip.onActive.background = Rounded(AccentPressed, 16, 0, AccentPressed);
				GUIStyleState onNormal = Chip.onNormal;
				GUIStyleState onHover = Chip.onHover;
				Color val5 = (Chip.onActive.textColor = TextOnAccent);
				Color textColor = (onHover.textColor = val5);
				onNormal.textColor = textColor;
				Chip.hover.textColor = Text;
				PillSuccess = Pill(Success);
				PillDanger = Pill(Danger);
				GUIStyle val7 = new GUIStyle();
				val7.normal.background = SliderTrackTexture();
				val7.border = new RectOffset(4, 4, 0, 0);
				val7.fixedHeight = 20f;
				val7.margin = new RectOffset(8, 8, 8, 8);
				SliderTrack = val7;
				GUIStyle val8 = new GUIStyle();
				val8.normal.background = Circle(Accent);
				val8.hover.background = Circle(AccentHover);
				val8.active.background = Circle(AccentPressed);
				val8.fixedWidth = 20f;
				val8.fixedHeight = 20f;
				SliderThumb = val8;
			}
		}

		private static GUIStyle TextStyle(int size, Color color, FontStyle style = (FontStyle)0)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_001f: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_003d: Expected O, but got Unknown
			GUIStyle val = new GUIStyle
			{
				fontSize = size,
				fontStyle = style
			};
			val.normal.textColor = color;
			val.alignment = (TextAnchor)3;
			val.richText = true;
			val.padding = new RectOffset(0, 0, 2, 2);
			return val;
		}

		private static GUIStyle MakeButton(Color normal, Color hover, Color pressed, Color text, int fontSize, float height, Texture2D normalTexture = null)
		{
			//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_0020: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//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_009d: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_0011: 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)
			GUIStyle val = new GUIStyle();
			val.normal.background = normalTexture ?? Rounded(normal, 6, 0, normal);
			val.normal.textColor = text;
			val.hover.background = Rounded(hover, 6, 0, hover);
			val.hover.textColor = text;
			val.active.background = Rounded(pressed, 6, 0, pressed);
			val.active.textColor = text;
			val.border = new RectOffset(8, 8, 8, 8);
			val.padding = new RectOffset(14, 14, 6, 6);
			val.margin = new RectOffset(0, 0, 3, 3);
			val.alignment = (TextAnchor)4;
			val.fontSize = fontSize;
			val.fixedHeight = height;
			val.richText = true;
			return val;
		}

		private static GUIStyle Pill(Color color)
		{
			//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_000b: 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_001b: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//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_004f: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			GUIStyle val = new GUIStyle();
			val.normal.background = Rounded(color, 11, 0, color);
			val.normal.textColor = Color.white;
			val.border = new RectOffset(12, 12, 12, 12);
			val.padding = new RectOffset(10, 10, 3, 3);
			val.alignment = (TextAnchor)4;
			val.fontSize = 12;
			val.fontStyle = (FontStyle)1;
			val.fixedHeight = 22f;
			return val;
		}

		private static Texture2D Solid(Color color)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			Texture2D obj = NewTexture(1, 1);
			obj.SetPixel(0, 0, color);
			obj.Apply();
			return obj;
		}

		private static Texture2D Rounded(Color fill, int radius, int borderWidth, Color border, bool soft = false)
		{
			//IL_008b: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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)
			int num = radius * 2 + 2;
			Texture2D val = NewTexture(num, num);
			float num2 = (float)num / 2f;
			float num3 = num2 - (float)radius;
			Color val2 = default(Color);
			for (int i = 0; i < num; i++)
			{
				for (int j = 0; j < num; j++)
				{
					float num4 = Mathf.Max(Mathf.Abs((float)j + 0.5f - num2) - num3, 0f);
					float num5 = Mathf.Max(Mathf.Abs((float)i + 0.5f - num2) - num3, 0f);
					float num6 = Mathf.Sqrt(num4 * num4 + num5 * num5) - (float)radius;
					if (soft)
					{
						float num7 = Mathf.Clamp01((0f - num6) / (float)radius);
						((Color)(ref val2))..ctor(fill.r, fill.g, fill.b, fill.a * num7 * num7);
					}
					else
					{
						float num8 = Mathf.Clamp01(0.5f - num6);
						val2 = ((borderWidth > 0 && num6 > (float)(-borderWidth) - 0.5f) ? Color.Lerp(border, fill, Mathf.Clamp01(0f - num6 - (float)borderWidth + 0.5f)) : fill);
						val2.a *= num8;
					}
					val.SetPixel(j, i, val2);
				}
			}
			val.Apply();
			return val;
		}

		private static Texture2D Circle(Color color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: 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_000f: Unknown result type (might be due to invalid IL or missing references)
			return Rounded(color, 10, 2, Color.Lerp(color, Color.black, 0.35f));
		}

		private static Texture2D SliderTrackTexture()
		{
			//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_005b: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = NewTexture(12, 20);
			for (int i = 0; i < 20; i++)
			{
				for (int j = 0; j < 12; j++)
				{
					bool num = i >= 7 && i < 13;
					float num2 = Mathf.Min((float)j + 0.5f, (float)(12 - j) - 0.5f);
					float a = (num ? Mathf.Clamp01(num2) : 0f);
					Color buttonHover = ButtonHover;
					buttonHover.a = a;
					val.SetPixel(j, i, buttonHover);
				}
			}
			val.Apply();
			return val;
		}

		private static Texture2D NewTexture(int width, int height)
		{
			//IL_0004: 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_0010: 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_0020: Expected O, but got Unknown
			return new Texture2D(width, height, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)1,
				wrapMode = (TextureWrapMode)1,
				hideFlags = (HideFlags)61
			};
		}

		private static Color Hex(int rgb)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			return new Color((float)((rgb >> 16) & 0xFF) / 255f, (float)((rgb >> 8) & 0xFF) / 255f, (float)(rgb & 0xFF) / 255f, 1f);
		}
	}
	public class WoodcutterAI : MonoBehaviour
	{
		private enum State
		{
			Idle,
			MovingToTarget,
			Chopping,
			MovingToItem,
			ScanningAfterFell,
			ReturningToZone,
			ReturningHome,
			Depositing,
			WaitingForStorage
		}

		private enum PickupResult
		{
			Collected,
			NotReadyYet,
			InventoryFull
		}

		private const float SearchRadius = 20f;

		private const float SearchInterval = 1f;

		private const float StopDistance = 2f;

		private const float LogStopDistance = 1.3f;

		private const float ItemPickupDistance = 1.5f;

		private const float AfterFellScanRadius = 25f;

		private const float ScanTimeout = 12f;

		private const float StuckProgressEpsilon = 0.3f;

		private const float StuckAbandonTime = 6f;

		private const float BlockedMoveEpsilon = 0.5f;

		private const float BlockedTime = 4f;

		private const float TouchRadius = 1.1f;

		private const float TreeBlockedReach = 3.5f;

		private const float EquipRetryInterval = 1f;

		private const float DurabilitySaveInterval = 5f;

		private const float AvoidTargetDuration = 45f;

		private const float ZoneSearchInterval = 5f;

		private const float ZoneArriveDistance = 5f;

		private const float ZoneArriveMargin = 10f;

		private const float WaterDepthLimit = 0.3f;

		private const float RecallArriveDistance = 1.5f;

		private const float HomeArriveDistance = 1.5f;

		private const float DepositReach = 3f;

		private const float DepositBlockedReach = 6f;

		private const float DepositRetryInterval = 5f;

		private const float RecallStuckTeleportTime = 8f;

		private const float RepairRetryInterval = 5f;

		private const float SkillSaveInterval = 10f;

		private const float RecallDetourTimeout = 30f;

		private const string ClaimZdoKey = "WoodcutterNPC_Claim";

		private static readonly List<WoodcutterAI> Loaded = new List<WoodcutterAI>();

		private static readonly FieldInfo ItemDropNetViewField = AccessTools.Field(typeof(ItemDrop), "m_nview");

		private static readonly string[] SwingTriggerCandidates = new string[2] { "attack_mace", "attack" };

		private Character _character;

		private Humanoid _humanoid;

		private ZSyncAnimation _zanim;

		private ZNetView _nview;

		private Container _container;

		private WoodcutterInteraction _interaction;

		private ItemData _axe;

		private string _equippedAxeKey;

		private string _swingTrigger;

		private float _nextEquipRetry;

		private float _nextDurabilitySave;

		private bool _wearUnsaved;

		private int _skill;

		private float _skillProgress;

		private bool _skillUnsaved;

		private float _nextSkillSave;

		private bool _lowWarningArmed;

		private bool _brokenWarningArmed;

		private float _nextRepairTry;

		private string _repairNotice;

		private float _nextRegenTime;

		private ZDOID _claimedId = ZDOID.None;

		private bool _claimWritten;

		private Vector3 _lastTargetPosition;

		private float _nextDepositTry;

		private bool _storageFullNotified;

		private bool _recalling;

		private float _recallBestDistance;

		private float _recallStuckSince;

		private State _state;

		private MonoBehaviour _target;

		private IDestructible _targetDestructible;

		private Collider[] _targetColliders = (Collider[])(object)new Collider[0];

		private Vector3 _chainAnchor;

		private ItemDrop _pickupTarget;

		private float _itemChaseDeadline;

		private readonly Dictionary<MonoBehaviour, float> _avoidUntil = new Dictionary<MonoBehaviour, float>();

		private float _nextSearchTime;

		private float _nextZoneSearchTime;

		private float _nextChopTime;

		private float _scanUntil;

		private readonly WoodcutterPathMover _mover = new WoodcutterPathMover();

		private Vector3 _moveAnchor;

		private float _moveAnchorTime;

		private bool HasUsableAxe
		{
			get
			{
				if (_axe != null)
				{
					return !WoodcutterAxeSlot.IsBroken(_axe);
				}
				return false;
			}
		}

		private float TargetStopDistance
		{
			get
			{
				if (_targetColliders.Length == 0)
				{
					return 2f;
				}
				return 1.3f;
			}
		}

		private void Awake()
		{
			_character = ((Component)this).GetComponent<Character>();
			ref Humanoid humanoid = ref _humanoid;
			Character character = _character;
			humanoid = (Humanoid)(object)((character is Humanoid) ? character : null);
			_zanim = ((Component)this).GetComponent<ZSyncAnimation>();
			_nview = ((Component)this).GetComponent<ZNetView>();
			_container = ((Component)this).GetComponent<Container>();
			_interaction = ((Component)this).GetComponent<WoodcutterInteraction>();
		}

		private void OnEnable()
		{
			Loaded.Add(this);
		}

		private void OnDisable()
		{
			Loaded.Remove(this);
		}

		private void Start()
		{
			RefreshAxe();
		}

		private void RefreshAxe()
		{
			Inventory inventory = (((Object)(object)_container != (Object)null) ? _container.GetInventory() : null);
			WoodcutterAxeSlot.Register(inventory);
			_axe = WoodcutterAxeSlot.GetAxe(inventory);
			string text = AxeKey(_axe);
			if (text == _equippedAxeKey)
			{
				if (Time.time < _nextEquipRetry)
				{
					return;
				}
				_nextEquipRetry = Time.time + 1f;
				if (!IsHandEmpty())
				{
					return;
				}
			}
			_equippedAxeKey = text;
			_repairNotice = null;
			_swingTrigger = ResolveSwingTrigger(_axe);
			float num = DurabilityFraction(_axe);
			_lowWarningArmed = num > 0.05f;
			_brokenWarningArmed = num > 0f;
			EquipAxe(_axe);
		}

		private static string AxeKey(ItemData axe)
		{
			if (axe == null)
			{
				return null;
			}
			return axe.m_shared.m_name + "|" + axe.m_quality + "|" + axe.m_variant + "|" + axe.m_worldLevel;
		}

		private bool IsHandEmpty()
		{
			if (_axe != null && (Object)(object)_humanoid != (Object)null)
			{
				return _humanoid.GetInventory().GetEquippedItems().Count == 0;
			}
			return false;
		}

		private void EquipAxe(ItemData axe)
		{
			if (!((Object)(object)_humanoid == (Object)null))
			{
				_humanoid.UnequipAllItems();
				_humanoid.GetInventory().RemoveAll();
				if (axe != null)
				{
					ItemData val = axe.Clone();
					val.m_stack = 1;
					_humanoid.GetInventory().AddItem(val);
					_humanoid.EquipItem(val, true);
				}
			}
		}

		private string ResolveSwingTrigger(ItemData axe)
		{
			if ((Object)(object)_zanim == (Object)null)
			{
				return null;
			}
			string text = axe?.m_shared?.m_attack?.m_attackAnimation;
			if (!string.IsNullOrEmpty(text) && _zanim.HasParameter(text, (AnimatorControllerParameterType)9))
			{
				return text;
			}
			string[] swingTriggerCandidates = SwingTriggerCandidates;
			foreach (string text2 in swingTriggerCandidates)
			{
				if (_zanim.HasParameter(text2, (AnimatorControllerParameterType)9))
				{
					return text2;
				}
			}
			return null;
		}

		private void WearDownAxe()
		{
			if (Plugin.UseDurability && _axe != null && _axe.m_shared.m_useDurability)
			{
				_axe.m_durability = Mathf.Max(0f, _axe.m_durability - _axe.m_shared.m_useDurabilityDrain);
				_wearUnsaved = true;
				NotifyAxeWear();
				if (!(_axe.m_durability > 0f) || !(Time.time < _nextDurabilitySave))
				{
					FlushWear();
				}
			}
		}

		private void FlushWear()
		{
			if (_wearUnsaved)
			{
				_wearUnsaved = false;
				_nextDurabilitySave = Time.time + 5f;
				if ((Object)(object)_container != (Object)null)
				{
					WoodcutterAxeSlot.NotifyChanged(_container.GetInventory());
				}
			}
		}

		private static float DurabilityFraction(ItemData axe)
		{
			if (axe == null || !axe.m_shared.m_useDurability)
			{
				return 1f;
			}
			float maxDurability = axe.GetMaxDurability();
			if (!(maxDurability > 0f))
			{
				return 0f;
			}
			return axe.m_durability / maxDurability;
		}

		private void TryAutoRepair()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			if (_axe == null || !WoodcutterAxeSlot.IsBroken(_axe) || (Object)(object)_interaction == (Object)null || (Object)(object)_container == (Object)null || Time.time < _nextRepairTry)
			{
				return;
			}
			WoodcutterHirePost postInstance = _interaction.PostInstance;
			if ((Object)(object)postInstance == (Object)null)
			{
				return;
			}
			Vector3 val = ((Component)postInstance).transform.position - ((Component)this).transform.position;
			val.y = 0f;
			if (!(((Vector3)(ref val)).magnitude > 6f))
			{
				_nextRepairTry = Time.time + 5f;
				FlushWear();
				List<WoodcutterRepair.Material> cost;
				WoodcutterHirePost.RepairResult repairResult = postInstance.TryRepair(_axe, out cost);
				string name = _interaction.Name;
				switch (repairResult)
				{
				case WoodcutterHirePost.RepairResult.Repaired:
					WoodcutterAxeSlot.NotifyChanged(_container.GetInventory());
					_lowWarningArmed = true;
					_brokenWarningArmed = true;
					_repairNotice = null;
					_nextSearchTime = 0f;
					WoodcutterNotifications.Send("notify_axe_repaired", name, WoodcutterRepair.Describe(cost));
					break;
				case WoodcutterHirePost.RepairResult.MissingMaterials:
					AnnounceRepairProblem("notify_repair_missing", name, WoodcutterRepair.Describe(cost));
					break;
				case WoodcutterHirePost.RepairResult.NotRepairable:
					AnnounceRepairProblem("notify_repair_impossible", name);
					break;
				case WoodcutterHirePost.RepairResult.Disabled:
					break;
				}
			}
		}

		private void AnnounceRepairProblem(string key, params string[] args)
		{
			string text = key + "|" + string.Join("|", args);
			if (!(text == _repairNotice))
			{
				_repairNotice = text;
				WoodcutterNotifications.Send(key, args);
			}
		}

		private void NotifyAxeWear()
		{
			float value = DurabilityFraction(_axe);
			string text = (((Object)(object)_interaction != (Object)null) ? _interaction.Name : "");
			if (WoodcutterLogic.Warn(ref _brokenWarningArmed, value, 0f, 0.15f))
			{
				_lowWarningArmed = false;
				WoodcutterNotifications.Send("notify_axe_broken", text);
			}
			else if (WoodcutterLogic.Warn(ref _lowWarningArmed, value, 0.05f, 0.15f))
			{
				int num = WoodcutterLogic.DurabilityPercent(_axe.m_durability, _axe.GetMaxDurability());
				WoodcutterNotifications.Send("notify_axe_low", text, num.ToString());
			}
		}

		private void TickHealth()
		{
			if (!(Time.time < _nextRegenTime))
			{
				_nextRegenTime = Time.time + Plugin.RegenInterval;
				FlushWear();
				SyncMaxHealth();
				if (Plugin.RegenAmount > 0f && !_character.IsDead() && _character.GetHealth() < _character.GetMaxHealth())
				{
					_character.Heal(Plugin.RegenAmount, true);
				}
			}
		}

		private void SyncMaxHealth()
		{
			_character.m_health = Plugin.MaxHealth;
			float num = _character.GetMaxHealthBase() * (float)_character.GetLevel();
			if (!Mathf.Approximately(_character.GetMaxHealth(), num))
			{
				_character.SetMaxHealth(num);
			}
		}

		private static int MinToolTierOf(MonoBehaviour target)
		{
			return ((TreeBase)(((target is TreeBase) ? target : null)?)).m_minToolTier ?? ((TreeLog)(((target is TreeLog) ? target : null)?)).m_minToolTier ?? 0;
		}

		private void FixedUpdate()
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_nview == (Object)null || !_nview.IsValid() || !_nview.IsOwner())
			{
				return;
			}
			RefreshAxe();
			TickHealth();
			if ((Object)(object)_interaction != (Object)null)
			{
				_interaction.EnsurePost();
			}
			if ((Object)(object)_interaction == (Object)null || !_interaction.WorkEnabled)
			{
				if ((Object)(object)_interaction != (Object)null && _interaction.IsRecalled)
				{
					TickRecall();
				}
				else
				{
					_recalling = false;
					_character.SetMoveDir(Vector3.zero);
				}
				UpdateClaim(null);
			}
			else
			{
				_recalling = false;
				TickState();
				MonoBehaviour current = (MonoBehaviour)((_state == State.MovingToItem) ? ((object)_pickupTarget) : ((object)_target));
				UpdateClaim(current);
			}
		}

		private void TickState()
		{
			switch (_state)
			{
			case State.Idle:
				TickIdle();
				break;
			case State.MovingToTarget:
				TickMovingToTarget();
				break;
			case State.Chopping:
				TickChopping();
				break;
			case State.MovingToItem:
				TickMovingToItem();
				break;
			case State.ScanningAfterFell:
				TickScanningAfterFell();
				break;
			case State.ReturningToZone:
				TickReturningToZone();
				break;
			case State.ReturningHome:
				TickReturningHome();
				break;
			case State.Depositing:
				TickDepositing();
				break;
			case State.WaitingForStorage:
				TickWaitingForStorage();
				break;
			}
		}

		private void TickIdle()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_013f: 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_0149: 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_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			_character.SetMoveDir(Vector3.zero);
			if (Time.time < _nextSearchTime)
			{
				return;
			}
			_nextSearchTime = Time.time + 1f;
			TryAutoRepair();
			bool hasUsableAxe = HasUsableAxe;
			int tier = (hasUsableAxe ? _axe.m_shared.m_toolTier : (-1));
			if (ShouldGoDeposit())
			{
				StartWalking();
				_state = State.Depositing;
				return;
			}
			if ((Object)(object)_interaction != (Object)null && !_interaction.IsInZone(((Component)this).transform.position))
			{
				StartReturningToZone();
				return;
			}
			TreeLog log;
			float logDistSqr;
			ItemDrop drop;
			float itemDistSqr;
			TreeBase tree;
			float treeDistSqr;
			bool flag = FindWork(((Component)this).transform.position, 20f, hasUsableAxe, tier, includeItems: true, out log, out logDistSqr, out drop, out itemDistSqr, out tree, out treeDistSqr);
			bool zoneSearched = false;
			if (!flag && (Object)(object)_interaction != (Object)null && Time.time >= _nextZoneSearchTime)
			{
				_nextZoneSearchTime = Time.time + 5f;
				zoneSearched = true;
				if (hasUsableAxe)
				{
					flag = FindWork(_interaction.ZoneCenter, _interaction.ZoneRadius, hasUsableAxe, tier, includeItems: false, out log, out logDistSqr, out drop, out itemDistSqr, out tree, out treeDistSqr);
				}
			}
			if ((Object)(object)_interaction != (Object)null)
			{
				Vector3 val = _interaction.HomeSpot - ((Component)this).transform.position;
				val.y = 0f;
				if (WoodcutterLogic.ShouldGoHome(zoneSearched, flag, ((Vector3)(ref val)).magnitude, 1.5f))
				{
					StartWalking();
					_state = State.ReturningHome;
					return;
				}
			}
			bool num = (Object)(object)log != (Object)null;
			bool flag2 = (Object)(object)drop != (Object)null;
			bool flag3 = (Object)(object)tree != (Object)null;
			if (num && (!flag2 || logDistSqr <= itemDistSqr) && (!flag3 || logDistSqr <= treeDistSqr))
			{
				SetTarget((MonoBehaviour)(object)log, (IDestructible)(object)log);
				_chainAnchor = ((Component)log).transform.position;
				_state = State.MovingToTarget;
			}
			else if (flag2 && (!flag3 || itemDistSqr <= treeDistSqr))
			{
				_pickupTarget = drop;
				_itemChaseDeadline = float.MaxValue;
				StartWalking();
				_state = State.MovingToItem;
			}
			else if (flag3)
			{
				SetTarget((MonoBehaviour)(object)tree, (IDestructible)(object)tree);
				_chainAnchor = ((Component)tree).transform.position;
				_state = State.MovingToTarget;
			}
		}

		private void TickMovingToTarget()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_0045: 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_006c: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			if (!IsTargetAlive() || !IsSpeciesAllowed(_target))
			{
				AbandonTarget(blacklist: false);
				return;
			}
			_lastTargetPosition = ((Component)_target).transform.position;
			Vector3 val = TargetAimPoint() - ((Component)this).transform.position;
			val.y = 0f;
			if (((Vector3)(ref val)).magnitude <= TargetStopDistance)
			{
				_character.SetMoveDir(Vector3.zero);
				_nextChopTime = 0f;
				_state = State.Chopping;
			}
			else if (IsBlocked())
			{
				if (IsTouchingTarget())
				{
					_character.SetMoveDir(Vector3.zero);
					_nextChopTime = 0f;
					_state = State.Chopping;
				}
				else
				{
					AbandonTarget(blacklist: true);
				}
			}
			else
			{
				WalkTowards(TargetAimPoint());
			}
		}

		private void WalkTowards(Vector3 goal)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_0031: 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)
			_character.SetRun(false);
			Vector3 val = _mover.DirectionTo(((Component)this).transform.position, goal);
			_character.SetMoveDir(val);
			if (val != Vector3.zero)
			{
				_character.SetLookDir(val, 0f);
			}
		}

		private void TickChopping()
		{
			//IL_000e: 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_002e: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Expected O, but got Unknown
			//IL_017e: 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_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: 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_01e8: 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_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: 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)
			if (!HasUsableAxe)
			{
				_character.SetMoveDir(Vector3.zero);
				AbandonTarget(blacklist: false);
				return;
			}
			if (!IsTargetAlive())
			{
				_character.SetMoveDir(Vector3.zero);
				ClearTarget();
				_chainAnchor = _lastTargetPosition;
				_scanUntil = Time.time + 12f;
				_state = State.ScanningAfterFell;
				return;
			}
			_lastTargetPosition = ((Component)_target).transform.position;
			if (MinToolTierOf(_target) > _axe.m_shared.m_toolTier || !IsSpeciesAllowed(_target))
			{
				AbandonTarget(blacklist: false);
				return;
			}
			Vector3 val = TargetAimPoint();
			Vector3 val2 = val - ((Component)this).transform.position;
			val2.y = 0f;
			if (((Vector3)(ref val2)).magnitude > TargetStopDistance + 0.5f && !IsTouchingTarget())
			{
				StartWalking();
				_state = State.MovingToTarget;
				return;
			}
			_character.SetMoveDir(Vector3.zero);
			if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f)
			{
				_character.SetLookDir(val2, 0f);
			}
			if (!(Time.time < _nextChopTime))
			{
				_nextChopTime = Time.time + Plugin.ChopInterval;
				if ((Object)(object)_zanim != (Object)null && _swingTrigger != null)
				{
					_zanim.SetTrigger(_swingTrigger);
				}
				HitData val3 = new HitData();
				val3.m_damage = _axe.GetDamage();
				((DamageTypes)(ref val3.m_damage)).Modify(WoodcutterLogic.SkillDamageFactor(CurrentSkill(), Random.value));
				val3.m_damage.m_chop *= Plugin.ChopDamageMultiplier;
				val3.m_toolTier = (short)_axe.m_shared.m_toolTier;
				val3.m_point = ((_targetColliders.Length != 0) ? val : (val + Vector3.up * 0.5f));
				val3.m_dir = ((((Vector3)(ref val2)).sqrMagnitude > 0.0001f) ? (-((Vector3)(ref val2)).normalized) : Vector3.forward);
				val3.SetAttacker(_character);
				_targetDestructible.Damage(val3);
				WearDownAxe();
				RaiseSkill();
			}
		}

		internal bool TryGetUnsavedSkill(out int level, out float progress)
		{
			level = _skill;
			progress = _skillProgress;
			return _skillUnsaved;
		}

		private int CurrentSkill()
		{
			if (!_skillUnsaved)
			{
				ZDO zDO = _nview.GetZDO();
				_skill = WoodcutterInteraction.SkillOf(zDO);
				_skillProgress = zDO.GetFloat("WoodcutterNPC_SkillProgress", 0f);
			}
			return _skill;
		}

		private void RaiseSkill()
		{
			CurrentSkill();
			bool num = WoodcutterLogic.RaiseSkill(ref _skill, ref _skillProgress, Plugin.SkillGainRate * Game.m_skillGainRate);
			if (num || _skillProgress > 0f)
			{
				_skillUnsaved = true;
			}
			if (num || Time.time >= _nextSkillSave)
			{
				SaveSkill();
			}
		}

		private void SaveSkill()
		{
			if (_skillUnsaved)
			{
				_skillUnsaved = false;
				_nextSkillSave = Time.time + 10f;
				FlushWear();
				ZDO zDO = _nview.GetZDO();
				zDO.Set("WoodcutterNPC_Skill", _skill);
				zDO.Set("WoodcutterNPC_SkillProgress", _skillProgress);
			}
		}

		private void TickMovingToItem()
		{
			//IL_0035: 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_0045: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_pickupTarget == (Object)null || _pickupTarget.m_itemData == null)
			{
				_pickupTarget = null;
				_state = State.Idle;
				return;
			}
			Vector3 val = ((Component)_pickupTarget).transform.position - ((Component)this).transform.position;
			val.y = 0f;
			if (((Vector3)(ref val)).magnitude <= 1.5f)
			{
				_character.SetMoveDir(Vector3.zero);
				if (_itemChaseDeadline == float.MaxValue)
				{
					_itemChaseDeadline = Time.time + 6f;
				}
				PickupResult pickupResult = TryCollectItem(_pickupTarget);
				if (pickupResult != PickupResult.NotReadyYet || !(Time.time < _itemChaseDeadline))
				{
					if (pickupResult != PickupResult.Collected)
					{
						Avoid((MonoBehaviour)(object)_pickupTarget);
					}
					_pickupTarget = null;
					_state = State.Idle;
					_nextSearchTime = 0f;
				}
			}
			else if (IsBlocked())
			{
				Avoid((MonoBehaviour)(object)_pickupTarget);
				_pickupTarget = null;
				_state = State.Idle;
			}
			else
			{
				WalkTowards(((Component)_pickupTarget).transform.position);
			}
		}

		private void TickScanningAfterFell()
		{
			//IL_0017: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_container == (Object)null)
			{
				_state = State.Idle;
				return;
			}
			Collider[] array = Physics.OverlapSphere(_chainAnchor, 25f);
			TreeLog val = null;
			float num = float.MaxValue;
			bool flag = false;
			bool flag2 = false;
			Collider[] array2 = array;
			foreach (Collider val2 in array2)
			{
				TreeLog componentInParent = ((Component)val2).GetComponentInParent<TreeLog>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					if (HasUsableAxe && componentInParent.m_minToolTier <= _axe.m_shared.m_toolTier && IsSpeciesAllowed((MonoBehaviour)(object)componentInParent) && !IsClaimedByOther((MonoBehaviour)(object)componentInParent))
					{
						Vector3 val3 = ((Component)componentInParent).transform.position - ((Component)this).transform.position;
						float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
						if (sqrMagnitude < num)
						{
							num = sqrMagnitude;
							val = componentInParent;
						}
					}
					continue;
				}
				ItemDrop componentInParent2 = ((Component)val2).GetComponentInParent<ItemDrop>();
				if (!((Object)(object)componentInParent2 == (Object)null) && componentInParent2.m_itemData != null)
				{
					switch (TryCollectItem(componentInParent2))
					{
					case PickupResult.NotReadyYet:
						flag = true;
						break;
					case PickupResult.InventoryFull:
						flag2 = true;
						flag = true;
						break;
					}
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				SetTarget((MonoBehaviour)(object)val, (IDestructible)(object)val);
				_state = State.MovingToTarget;
			}
			else if (!flag || flag2 || Time.time > _scanUntil)
			{
				_state = State.Idle;
				_nextSearchTime = 0f;
			}
		}

		private PickupResult TryCollectItem(ItemDrop drop)
		{
			//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)
			if (!drop.CanPickup(true))
			{
				drop.RequestOwn();
				return PickupResult.NotReadyYet;
			}
			if (WoodcutterAxeSlot.AddItem(_container.GetInventory(), drop.m_itemData.Clone()))
			{
				ZNetView val = (ZNetView)ItemDropNetViewField.GetValue(drop);
				if ((int)val != 0)
				{
					val.Destroy();
				}
				return PickupResult.Collected;
			}
			return PickupResult.InventoryFull;
		}

		private void TickRecall()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: 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_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: 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_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			if (!_recalling)
			{
				_recalling = true;
				_recallBestDistance = float.MaxValue;
				_recallStuckSince = Time.time;
				StartWalking();
				ClearTarget();
				_pickupTarget = null;
				_state = State.Idle;
			}
			Vector3 recallTarget = _interaction.RecallTarget;
			Vector3 val = recallTarget - ((Component)this).transform.position;
			val.y = 0f;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude <= 1.5f)
			{
				Arrive();
				return;
			}
			if (magnitude < _recallBestDistance - 0.3f)
			{
				_recallBestDistance = magnitude;
				_recallStuckSince = Time.time;
			}
			IsBlocked();
			float noProgressLimit = (_mover.FollowingPath ? 30f : 8f);
			if (WoodcutterLogic.ShouldTeleportRecall(Time.time - _moveAnchorTime, 8f, Time.time - _recallStuckSince, noProgressLimit))
			{
				float y = default(float);
				if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.FindFloor(recallTarget + Vector3.up * 2f, ref y))
				{
					recallTarget.y = y;
				}
				Vector3 position = recallTarget + Vector3.up * 0.2f;
				((Component)this).transform.position = position;
				Rigidbody component = ((Component)this).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.position = position;
					component.linearVelocity = Vector3.zero;
				}
				Arrive();
			}
			else
			{
				WalkTowards(_interaction.RecallTarget);
			}
			void Arrive()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				_character.SetMoveDir(Vector3.zero);
				_interaction.ClearRecall();
				_recalling = false;
			}
		}

		private void TickReturningHome()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_interaction == (Object)null)
			{
				_state = State.Idle;
				return;
			}
			Vector3 val = _interaction.HomeSpot - ((Component)this).transform.position;
			val.y = 0f;
			if (((Vector3)(ref val)).magnitude <= 1.5f || IsBlocked())
			{
				_character.SetMoveDir(Vector3.zero);
				_state = State.Idle;
			}
			else
			{
				WalkTowards(_interaction.HomeSpot);
			}
		}

		private void CountLoad(out int used, out int total)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			Inventory val = (((Object)(object)_container != (Object)null) ? _container.GetInventory() : null);
			total = 17;
			used = 0;
			if (val == null)
			{
				return;
			}
			foreach (ItemData allItem in val.GetAllItems())
			{
				if (allItem.m_gridPos != WoodcutterAxeSlot.Position)
				{
					used++;
				}
			}
		}

		private bool IsLoadFull()
		{
			CountLoad(out var used, out var total);
			return WoodcutterLogic.ShouldDeposit(used, total);
		}

		private bool ShouldGoDeposit()
		{
			if ((Object)(object)_interaction != (Object)null && _interaction.HasPost && Time.time >= _nextDepositTry)
			{
				return IsLoadFull();
			}
			return false;
		}

		private void TickDepositing()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0051: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_interaction == (Object)null || !_interaction.HasPost)
			{
				_state = State.Idle;
				return;
			}
			Vector3 val = _interaction.ZoneCenter - ((Component)this).transform.position;
			val.y = 0f;
			Vector3 val2 = _interaction.HomeSpot - ((Component)this).transform.position;
			val2.y = 0f;
			if (((Vector3)(ref val)).magnitude <= 3f || ((Vector3)(ref val2)).magnitude <= 1.5f)
			{
				Unload();
			}
			else if (IsBlocked())
			{
				if (((Vector3)(ref val)).magnitude <= 6f)
				{
					Unload();
					return;
				}
				_character.SetMoveDir(Vector3.zero);
				_nextDepositTry = Time.time + 5f;
				_state = State.Idle;
			}
			else
			{
				WalkTowards(_interaction.HomeSpot);
			}
		}

		private void Unload()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			_character.SetMoveDir(Vector3.zero);
			WoodcutterHirePost postInstance = _interaction.PostInstance;
			Inventory val = (((Object)(object)_container != (Object)null) ? _container.GetInventory() : null);
			if ((Object)(object)postInstance == (Object)null || val == null)
			{
				_nextDepositTry = Time.time + 5f;
				_state = State.Idle;
				return;
			}
			FlushWear();
			WoodcutterHirePost.DepositResult num = postInstance.DepositFrom(val, WoodcutterAxeSlot.Position);
			_nextDepositTry = Time.time + 5f;
			if (num == WoodcutterHirePost.DepositResult.Busy)
			{
				_state = State.WaitingForStorage;
			}
			else if (IsLoadFull())
			{
				_interaction.SetStorageFull(full: true);
				if (!_storageFullNotified)
				{
					_storageFullNotified = true;
					WoodcutterNotifications.Send("notify_storage_full", _interaction.Name);
				}
				_state = State.WaitingForStorage;
			}
			else
			{
				_interaction.SetStorageFull(full: false);
				_storageFullNotified = false;
				_nextDepositTry = 0f;
				_state = State.Idle;
				_nextSearchTime = 0f;
			}
		}

		private void TickWaitingForStorage()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			_character.SetMoveDir(Vector3.zero);
			if ((Object)(object)_interaction == (Object)null || !_interaction.HasPost || !IsLoadFull())
			{
				_interaction?.SetStorageFull(ful