Decompiled source of MyDirtyHoe v1.1.4

plugins/MyDirtyHoe/MyDirtyHoe.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using MyDirtyHoe.ConsoleCommands;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("MyDirtyHoe")]
[assembly: AssemblyDescription("https://discord.gg/khjfYmQ4fX")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MyDirtyHoe")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("1.1.4")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.4.0")]
public class KeyUtils
{
	public static bool IgnoreKeyPresses(bool extra = false)
	{
		if (!extra)
		{
			if (!((Object)(object)ZNetScene.instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !Minimap.IsOpen() && !Console.IsVisible() && !TextInput.IsVisible() && !ZNet.instance.InPasswordDialog())
			{
				Chat instance = Chat.instance;
				if (instance == null || !instance.HasFocus())
				{
					return Menu.IsVisible();
				}
			}
			return true;
		}
		if (!((Object)(object)ZNetScene.instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !Minimap.IsOpen() && !Console.IsVisible() && !TextInput.IsVisible() && !ZNet.instance.InPasswordDialog())
		{
			Chat instance2 = Chat.instance;
			if ((instance2 == null || !instance2.HasFocus()) && !StoreGui.IsVisible() && !InventoryGui.IsVisible() && !Menu.IsVisible())
			{
				TextViewer instance3 = TextViewer.instance;
				if (instance3 == null)
				{
					return false;
				}
				return instance3.IsVisible();
			}
		}
		return true;
	}

	public static bool CheckKeyDown(string value)
	{
		try
		{
			return Input.GetKeyDown(value.ToLower());
		}
		catch
		{
			return false;
		}
	}

	public static bool CheckKeyHeld(string value, bool req = true)
	{
		try
		{
			return Input.GetKey(value.ToLower());
		}
		catch
		{
			return !req;
		}
	}
}
namespace MyDirtyHoe
{
	internal class Harmony_Patches
	{
		[HarmonyPatch(typeof(TerrainOp), "Awake")]
		private static class TerrainOp_Patch
		{
			private static void Prefix(TerrainOp __instance)
			{
				if (__instance.m_settings.m_level)
				{
					Settings settings = __instance.m_settings;
					settings.m_levelRadius += MyDirtyHoeMod.lastTotalDelta;
				}
				if (__instance.m_settings.m_raise)
				{
					Settings settings2 = __instance.m_settings;
					settings2.m_raiseRadius += MyDirtyHoeMod.lastTotalDelta;
				}
				if (__instance.m_settings.m_smooth)
				{
					Settings settings3 = __instance.m_settings;
					settings3.m_smoothRadius += MyDirtyHoeMod.lastTotalDelta;
				}
				if (__instance.m_settings.m_paintCleared)
				{
					Settings settings4 = __instance.m_settings;
					settings4.m_paintRadius += MyDirtyHoeMod.lastTotalDelta;
				}
			}
		}

		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		private static class SFXFix
		{
			private static void Postfix()
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("sfx_Potion_stamina_Start");
				try
				{
					prefab.GetComponentInChildren<AudioSource>().outputAudioMixerGroup = AudioMan.instance.m_ambientMixer;
				}
				catch
				{
					Logger.LogError((object)"AudioMan.instance.m_ambientMixer could not be assigned on outputAudioMixerGroup");
				}
			}
		}

		[HarmonyPatch(typeof(TerrainComp), "DoOperation")]
		private static class DoOperation_Patch
		{
			private static bool Prefix(Vector3 pos, Settings modifier, bool ___m_initialized)
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				if (!___m_initialized)
				{
					return false;
				}
				if (!modifier.m_smooth || !KeyUtils.CheckKeyHeld(MyDirtyHoeMod.modKey.Value))
				{
					return true;
				}
				MyDirtyHoeMod.ResetTerrain(pos, (MyDirtyHoeMod.toolRadius.Value > 0f) ? MyDirtyHoeMod.toolRadius.Value : modifier.GetRadius());
				return false;
			}
		}

		[HarmonyPatch(typeof(TerrainOp), "OnPlaced")]
		private static class OnPlaced_Patch
		{
			private static bool Prefix(Settings ___m_settings)
			{
				if (!___m_settings.m_smooth || !KeyUtils.CheckKeyHeld(MyDirtyHoeMod.modKey.Value))
				{
					return true;
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(Terminal), "InputText")]
		private static class InputText_Patch
		{
			private static bool Prefix(Terminal __instance)
			{
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				if (MyDirtyHoeMod.modEnabled.Value != MyDirtyHoeMod.Toggle.On)
				{
					return true;
				}
				string text = ((TMP_InputField)__instance.m_input).text.ToLower();
				if (text.Equals("hoe reload"))
				{
					((BaseUnityPlugin)MyDirtyHoeMod.context).Config.Reload();
					((BaseUnityPlugin)MyDirtyHoeMod.context).Config.Save();
					Traverse.Create((object)__instance).Method("AddString", new object[1] { text }).GetValue();
					Traverse.Create((object)__instance).Method("AddString", new object[1] { ((BaseUnityPlugin)MyDirtyHoeMod.context).Info.Metadata.Name + " config reloaded" }).GetValue();
					return false;
				}
				if (text.StartsWith(MyDirtyHoeMod.consoleCommand.Value + " "))
				{
					if (float.TryParse(text.Split(new char[1] { ' ' })[1], out var result))
					{
						int num = MyDirtyHoeMod.ResetTerrain(((Component)Player.m_localPlayer).transform.position, result);
						Traverse.Create((object)__instance).Method("AddString", new object[1] { text }).GetValue();
						if (MyDirtyHoeMod.resetMessage.Value.Length > 0 && MyDirtyHoeMod.resetMessage.Value.Contains("{0}"))
						{
							Traverse.Create((object)__instance).Method("AddString", new object[1] { string.Format(MyDirtyHoeMod.resetMessage.Value, num) }).GetValue();
						}
					}
					else
					{
						Traverse.Create((object)__instance).Method("AddString", new object[1] { "Format error. Usage: " + MyDirtyHoeMod.consoleCommand.Value + " <radius>" }).GetValue();
					}
					return false;
				}
				return true;
			}
		}
	}
	internal class Heightmap_Patches
	{
		[HarmonyPatch(typeof(TerrainComp))]
		private static class Heightmap_Patch
		{
			[HarmonyTranspiler]
			[HarmonyPatch("LevelTerrain")]
			public static IEnumerable<CodeInstruction> TerrainCompLevelTerrainTranspiler(IEnumerable<CodeInstruction> instructions)
			{
				foreach (CodeInstruction instruction in instructions)
				{
					if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)(-8f)))
					{
						yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Min", (Type[])null, (Type[])null));
					}
					else if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)8f))
					{
						yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Max", (Type[])null, (Type[])null));
					}
					else
					{
						yield return instruction;
					}
				}
			}

			[HarmonyTranspiler]
			[HarmonyPatch("RaiseTerrain")]
			public static IEnumerable<CodeInstruction> TerrainCompRaiseTerrainTranspiler(IEnumerable<CodeInstruction> instructions)
			{
				foreach (CodeInstruction instruction in instructions)
				{
					if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)(-8f)))
					{
						yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Min", (Type[])null, (Type[])null));
					}
					else if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)8f))
					{
						yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Max", (Type[])null, (Type[])null));
					}
					else
					{
						yield return instruction;
					}
				}
			}

			[HarmonyTranspiler]
			[HarmonyPatch("ApplyToHeightmap")]
			public static IEnumerable<CodeInstruction> TerrainCompApplyToHeightmapTranspiler(IEnumerable<CodeInstruction> instructions)
			{
				int i = 0;
				foreach (CodeInstruction instruction in instructions)
				{
					if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)(-8f)))
					{
						yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Min", (Type[])null, (Type[])null));
					}
					else if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)8f))
					{
						if (i == 0)
						{
							yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "MinAbs", (Type[])null, (Type[])null));
						}
						else
						{
							yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Max", (Type[])null, (Type[])null));
						}
						i++;
					}
					else
					{
						yield return instruction;
					}
				}
			}
		}
	}
	[BepInPlugin("MagicMike.MyDirtyHoe", "MyDirtyHoe", "1.1.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	internal class MyDirtyHoeMod : BaseUnityPlugin
	{
		internal enum Toggle
		{
			On = 1,
			Off = 0
		}

		internal enum Shape
		{
			Circle,
			Square
		}

		internal const string PluginName = "MyDirtyHoe";

		internal const string PluginVersion = "1.1.4";

		internal const string Author = "MagicMike";

		private const string PluginGUID = "MagicMike.MyDirtyHoe";

		public const string modLink = "https://discord.gg/khjfYmQ4fX";

		public static MyDirtyHoeMod context;

		public AssetBundle magicBundle;

		private GameObject effectNoise;

		private GameObject _gameObject;

		private CustomItem _customItem;

		private CustomPiece _customPiece;

		private CustomPieceTable _customPieceTable;

		private CustomStatusEffect _hoeStamina;

		public EffectList buildHoe;

		public EffectList buildCultivater;

		public EffectList buildStone;

		public static ConfigEntry<Toggle> modEnabled;

		public static ConfigEntry<Toggle> enableSE;

		public static ConfigEntry<Toggle> enableHeightmap;

		public static ConfigEntry<Shape> toolShape;

		public static ConfigEntry<bool> useScrollWheel;

		public static ConfigEntry<string> scrollModKey;

		public static ConfigEntry<string> increaseHotKey;

		public static ConfigEntry<string> decreaseHotKey;

		public static ConfigEntry<float> scrollWheelScale;

		public static ConfigEntry<float> hotkeyScale;

		public static ConfigEntry<float> hotKeyRadius;

		public static ConfigEntry<float> toolRadius;

		public static ConfigEntry<string> hotKey;

		public static ConfigEntry<string> modKey;

		public static ConfigEntry<string> consoleCommand;

		public static ConfigEntry<string> resetMessage;

		public static ConfigEntry<float> MaxHeight;

		public static ConfigEntry<float> MinHeight;

		public static ConfigEntry<float> forestRadius;

		public static ConfigEntry<float> pieceRadius;

		public static ConfigEntry<bool> durabilityDrain;

		public static ConfigEntry<bool> staminaUsage;

		public static ConfigEntry<bool> resourceCosts;

		public static ConfigEntry<bool> needWorkbench;

		public static float lastOriginalRadius;

		public static float lastModdedRadius;

		public static float lastTotalDelta;

		private Harmony harmony = new Harmony("MagicMike.MyDirtyHoe");

		public static float Min()
		{
			return MinHeight.Value;
		}

		public static float MinAbs()
		{
			return Math.Abs(MinHeight.Value);
		}

		public static float Max()
		{
			return MaxHeight.Value;
		}

		private void Awake()
		{
			InitConfig();
			if (modEnabled.Value == Toggle.On)
			{
				LoadAssets();
				if (enableSE.Value == Toggle.On)
				{
					LoadStatusEffect();
				}
				LoadTable();
				PrefabManager.OnVanillaPrefabsAvailable += LoadSFX;
				PrefabManager.OnVanillaPrefabsAvailable += LoadPrefabs;
				AddCommands();
				((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
				((BaseUnityPlugin)this).Config.SettingChanged += delegate(object sender, SettingChangedEventArgs args)
				{
					SettingChanged(((BaseUnityPlugin)this).Config, args);
				};
				harmony = Harmony.CreateAndPatchAll(typeof(Harmony_Patches).Assembly, "MagicMike.MyDirtyHoe");
				if (!IsHeadless() && enableHeightmap.Value != 0)
				{
					harmony = Harmony.CreateAndPatchAll(typeof(Heightmap_Patches).Assembly, "MagicMike.MyDirtyHoe");
				}
			}
		}

		private void OnDestroy()
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}

		private void Update()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || !((Character)Player.m_localPlayer).InPlaceMode() || Hud.IsPieceSelectionVisible())
			{
				if (lastOriginalRadius != 0f)
				{
					lastOriginalRadius = 0f;
					lastModdedRadius = 0f;
					lastTotalDelta = 0f;
					SetRadius(0f);
				}
				return;
			}
			if (useScrollWheel.Value && KeyUtils.CheckKeyHeld(scrollModKey.Value, req: false) && Input.mouseScrollDelta.y != 0f)
			{
				SetRadius(Input.mouseScrollDelta.y * scrollWheelScale.Value);
			}
			else if (KeyUtils.CheckKeyDown(increaseHotKey.Value))
			{
				SetRadius(hotkeyScale.Value);
			}
			else if (KeyUtils.CheckKeyDown(decreaseHotKey.Value))
			{
				SetRadius(0f - hotkeyScale.Value);
			}
			if (modEnabled.Value == Toggle.On && !KeyUtils.IgnoreKeyPresses(extra: true) && KeyUtils.CheckKeyDown(hotKey.Value) && Object.op_Implicit((Object)(object)Player.m_localPlayer))
			{
				int num = ResetTerrain(((Component)Player.m_localPlayer).transform.position, hotKeyRadius.Value);
				if (resetMessage.Value.Length > 0 && resetMessage.Value.Contains("{0}"))
				{
					((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(resetMessage.Value, num), 0, (Sprite)null);
				}
			}
		}

		private void InitConfig()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0048: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			//IL_00fa: 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_010c: Expected O, but got Unknown
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Expected O, but got Unknown
			//IL_013a: 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_014c: Expected O, but got Unknown
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: 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_0190: Expected O, but got Unknown
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Expected O, but got Unknown
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Expected O, but got Unknown
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Expected O, but got Unknown
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: 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_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_025c: Expected O, but got Unknown
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Expected O, but got Unknown
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Expected O, but got Unknown
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Expected O, but got Unknown
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Expected O, but got Unknown
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Expected O, but got Unknown
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Expected O, but got Unknown
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Expected O, but got Unknown
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Expected O, but got Unknown
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Expected O, but got Unknown
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Expected O, but got Unknown
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Expected O, but got Unknown
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Expected O, but got Unknown
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Expected O, but got Unknown
			//IL_0449: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: 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_0462: Expected O, but got Unknown
			//IL_0462: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Expected O, but got Unknown
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bb: Expected O, but got Unknown
			//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Expected O, but got Unknown
			//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0500: Unknown result type (might be due to invalid IL or missing references)
			//IL_0507: Unknown result type (might be due to invalid IL or missing references)
			//IL_0514: Expected O, but got Unknown
			//IL_0514: Unknown result type (might be due to invalid IL or missing references)
			//IL_051e: Expected O, but got Unknown
			//IL_0554: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: Unknown result type (might be due to invalid IL or missing references)
			//IL_0560: Unknown result type (might be due to invalid IL or missing references)
			//IL_056d: Expected O, but got Unknown
			//IL_056d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0577: Expected O, but got Unknown
			//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c6: Expected O, but got Unknown
			//IL_05c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d0: Expected O, but got Unknown
			//IL_05f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0600: Unknown result type (might be due to invalid IL or missing references)
			//IL_060d: Expected O, but got Unknown
			//IL_060d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0617: Expected O, but got Unknown
			//IL_063b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0640: Unknown result type (might be due to invalid IL or missing references)
			//IL_0647: Unknown result type (might be due to invalid IL or missing references)
			//IL_0654: Expected O, but got Unknown
			//IL_0654: Unknown result type (might be due to invalid IL or missing references)
			//IL_065e: Expected O, but got Unknown
			//IL_0682: Unknown result type (might be due to invalid IL or missing references)
			//IL_0687: Unknown result type (might be due to invalid IL or missing references)
			//IL_068e: Unknown result type (might be due to invalid IL or missing references)
			//IL_069b: Expected O, but got Unknown
			//IL_069b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Expected O, but got Unknown
			//IL_06c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e2: Expected O, but got Unknown
			//IL_06e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ec: Expected O, but got Unknown
			context = this;
			modEnabled = ((BaseUnityPlugin)this).Config.Bind<Toggle>("01 - General Settings", "Enable Dirty Hoe", Toggle.On, new ConfigDescription("Enable this plugin. (Logout required).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = 4
			} }));
			enableSE = ((BaseUnityPlugin)this).Config.Bind<Toggle>("01 - General Settings", "Enable Status Effect", Toggle.On, new ConfigDescription("Enable the status effect while using the hoe. (Restart required).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = 3
			} }));
			enableHeightmap = ((BaseUnityPlugin)this).Config.Bind<Toggle>("01 - General Settings", "Enable Heightmap Settings", Toggle.On, new ConfigDescription("Enable this heightmap settings. (Logout required).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = 2
			} }));
			toolShape = ((BaseUnityPlugin)this).Config.Bind<Shape>("01 - General Settings", "Flatten Tool Shape", Shape.Circle, new ConfigDescription("Use the Circle or Square shape when flattening terrain.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 1
			} }));
			useScrollWheel = ((BaseUnityPlugin)this).Config.Bind<bool>("02 - Hoe Radius", "Use Scroll Wheel", true, new ConfigDescription("Use scroll wheel to modify radius. (Logout required).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 6
			} }));
			scrollWheelScale = ((BaseUnityPlugin)this).Config.Bind<float>("02 - Hoe Radius", "Scroll Wheel Scale", 0.2f, new ConfigDescription("Scroll wheel change scale.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 5
			} }));
			scrollModKey = ((BaseUnityPlugin)this).Config.Bind<string>("02 - Hoe Radius", "Scroll ModKey", "left ctrl", new ConfigDescription("Modifer key to allow scroll wheel change. (Logout required).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 4
			} }));
			increaseHotKey = ((BaseUnityPlugin)this).Config.Bind<string>("02 - Hoe Radius", "Increase HotKey", "", new ConfigDescription("Hotkey to increase radius. (Logout required).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 3
			} }));
			decreaseHotKey = ((BaseUnityPlugin)this).Config.Bind<string>("02 - Hoe Radius", "Decrease HotKey", "", new ConfigDescription("Hotkey to decrease radius. (Logout required).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 2
			} }));
			hotkeyScale = ((BaseUnityPlugin)this).Config.Bind<float>("02 - Hoe Radius", "Hotkey Scale", 0.2f, new ConfigDescription("Change the hotkey scale.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 1
			} }));
			hotKeyRadius = ((BaseUnityPlugin)this).Config.Bind<float>("03 - Terrain Reset", "Hot Key Radius", 150f, new ConfigDescription("Reset radius for hotkey command.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 150f), new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 6
			} }));
			toolRadius = ((BaseUnityPlugin)this).Config.Bind<float>("03 - Terrain Reset", "Tool Radius", 0f, new ConfigDescription("Reset radius for tool. Set to 0 to use the tool's actual radius.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 5
			} }));
			hotKey = ((BaseUnityPlugin)this).Config.Bind<string>("03 - Terrain Reset", "Hot Key", "", new ConfigDescription("Hotkey to reset terrain. (Logout required).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 4
			} }));
			modKey = ((BaseUnityPlugin)this).Config.Bind<string>("03 - Terrain Reset", "Mod Key", "left alt", new ConfigDescription("Modifer key to reset terrain when using the level ground tool. (Logout required).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 3
			} }));
			consoleCommand = ((BaseUnityPlugin)this).Config.Bind<string>("03 - Terrain Reset", "Console Command", "resetterrain", new ConfigDescription("Console command to reset terrain. Usage: <command> <radius>. (Logout required).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = 2
			} }));
			resetMessage = ((BaseUnityPlugin)this).Config.Bind<string>("03 - Terrain Reset", "Reset Message", "{0} edits reset.", new ConfigDescription("Reset message. {0} is replaced by the number of edits. Set to empty to disable message. (Logout required).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = 1
			} }));
			MaxHeight = ((BaseUnityPlugin)this).Config.Bind<float>("04 - Heightmap", "Max Height", 200f, new ConfigDescription("How high you can stack up relative to the heightmap's original position. (Logout required).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 200f), new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = 2
			} }));
			MinHeight = ((BaseUnityPlugin)this).Config.Bind<float>("04 - Heightmap", "Min Height", -200f, new ConfigDescription("How far you can dig down relative to the heightmap's original position. (Logout required).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-200f, -1f), new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = 1
			} }));
			forestRadius = ((BaseUnityPlugin)this).Config.Bind<float>("05 - Removal Settings", "Forest Remove Radius", 20f, new ConfigDescription("Radius to set when using the remove_forestry console command. Please be very careful with this! (Logout required).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = 2
			} }));
			pieceRadius = ((BaseUnityPlugin)this).Config.Bind<float>("05 - Removal Settings", "Piece Remove Radius", 20f, new ConfigDescription("Radius to set when using the remove_pieces console command. Please be very careful with this! (Logout required).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = 1
			} }));
			durabilityDrain = ((BaseUnityPlugin)this).Config.Bind<bool>("06 - Misc Settings", "Enable Durability Drain", false, new ConfigDescription("Enable durability drain for the hoe.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = 4
			} }));
			staminaUsage = ((BaseUnityPlugin)this).Config.Bind<bool>("06 - Misc Settings", "Enable Stamina Usage", false, new ConfigDescription("Enable stamina usage for the hoe.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = 3
			} }));
			resourceCosts = ((BaseUnityPlugin)this).Config.Bind<bool>("06 - Misc Settings", "Enable Resource Costs", false, new ConfigDescription("Enable resource costs for the hoe. Only applies to raising terrain and paving terrain.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = 2
			} }));
			needWorkbench = ((BaseUnityPlugin)this).Config.Bind<bool>("06 - Misc Settings", "Workbench Requirement", false, new ConfigDescription("Enable requirement of stone-cutter workbench for paving terrain.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				Order = 1
			} }));
		}

		private void SettingChanged(ConfigFile sender, SettingChangedEventArgs args)
		{
			InitConfig();
			bool square = true;
			if (toolShape.Value == Shape.Circle)
			{
				square = false;
			}
			PrefabManager.Instance.GetPrefab("mm_flatten").GetComponent<TerrainOp>().m_settings.m_square = square;
			PrefabManager.Instance.GetPrefab("mm_cultivate_flatten").GetComponent<TerrainOp>().m_settings.m_square = square;
			PrefabManager.Instance.GetPrefab("mm_paved_flatten").GetComponent<TerrainOp>().m_settings.m_square = square;
			GameObject prefab = PrefabManager.Instance.GetPrefab("DirtyHoe");
			if (durabilityDrain.Value)
			{
				prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_useDurabilityDrain = 1f;
			}
			else
			{
				prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_useDurabilityDrain = 0f;
			}
			if (staminaUsage.Value)
			{
				prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_attack.m_attackStamina = 5f;
			}
			else
			{
				prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_attack.m_attackStamina = 0f;
			}
			GameObject prefab2 = PrefabManager.Instance.GetPrefab("mm_paved_smooth");
			GameObject prefab3 = PrefabManager.Instance.GetPrefab("mm_paved_flatten");
			GameObject prefab4 = PrefabManager.Instance.GetPrefab("mm_paint_paved");
			CraftingStation prefab5 = Cache.GetPrefab<CraftingStation>("piece_stonecutter");
			if (needWorkbench.Value)
			{
				prefab2.GetComponent<Piece>().m_craftingStation = prefab5;
				prefab3.GetComponent<Piece>().m_craftingStation = prefab5;
				prefab4.GetComponent<Piece>().m_craftingStation = prefab5;
			}
			else
			{
				prefab2.GetComponent<Piece>().m_craftingStation = null;
				prefab3.GetComponent<Piece>().m_craftingStation = null;
				prefab4.GetComponent<Piece>().m_craftingStation = null;
			}
		}

		public void LoadAssets()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			try
			{
				magicBundle = AssetUtils.LoadAssetBundleFromResources("mydirtyhoe", Assembly.GetExecutingAssembly());
				effectNoise = magicBundle.LoadAsset<GameObject>("sfx_Potion_stamina_Start");
				CustomPrefab val = new CustomPrefab(effectNoise, false);
				PrefabManager.Instance.AddPrefab(val);
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Exception caught while loading bundle: " + ex.Message));
			}
		}

		public void LoadStatusEffect()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			SE_Stats val = magicBundle.LoadAsset<SE_Stats>("SE_Hoe_Stamina");
			_hoeStamina = new CustomStatusEffect((StatusEffect)(object)val, false);
			ItemManager.Instance.AddStatusEffect(_hoeStamina);
		}

		private void LoadTable()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			_gameObject = magicBundle.LoadAsset<GameObject>("_DirtyHoePieceTable");
			GameObject gameObject = _gameObject;
			PieceTableConfig val = new PieceTableConfig();
			val.CanRemovePieces = false;
			val.UseCategories = false;
			val.UseCustomCategories = true;
			val.CustomCategories = new string[1] { "Paint" };
			_customPieceTable = new CustomPieceTable(gameObject, val);
			PieceManager.Instance.AddPieceTable(_customPieceTable);
			LoadHoeTool();
		}

		private void LoadHoeTool()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0051: 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_0061: 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_0070: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			_gameObject = magicBundle.LoadAsset<GameObject>("DirtyHoe");
			GameObject gameObject = _gameObject;
			ItemConfig val = new ItemConfig();
			val.Amount = 1;
			val.CraftingStation = "piece_workbench";
			val.RepairStation = "piece_workbench";
			val.MinStationLevel = 1;
			val.Requirements = (RequirementConfig[])(object)new RequirementConfig[2]
			{
				new RequirementConfig
				{
					Item = "Wood",
					Amount = 1,
					AmountPerLevel = 1
				},
				new RequirementConfig
				{
					Item = "Stone",
					Amount = 1,
					AmountPerLevel = 1
				}
			};
			_customItem = new CustomItem(gameObject, false, val);
			if (durabilityDrain.Value)
			{
				_gameObject.GetComponent<ItemDrop>().m_itemData.m_shared.m_useDurabilityDrain = 1f;
			}
			if (staminaUsage.Value)
			{
				_gameObject.GetComponent<ItemDrop>().m_itemData.m_shared.m_attack.m_attackStamina = 5f;
			}
			if (enableSE.Value == Toggle.On)
			{
				_gameObject.GetComponent<ItemDrop>().m_itemData.m_shared.m_equipStatusEffect = _hoeStamina.StatusEffect;
			}
			ItemManager.Instance.AddItem(_customItem);
		}

		private void LoadSFX()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			try
			{
				GameObject prefab = Cache.GetPrefab<GameObject>("sfx_build_hoe");
				GameObject prefab2 = Cache.GetPrefab<GameObject>("sfx_build_cultivator");
				GameObject prefab3 = Cache.GetPrefab<GameObject>("sfx_build_hammer_stone");
				EffectList val = new EffectList();
				val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
				{
					new EffectData
					{
						m_prefab = prefab
					}
				};
				buildHoe = val;
				val = new EffectList();
				val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
				{
					new EffectData
					{
						m_prefab = prefab2
					}
				};
				buildCultivater = val;
				val = new EffectList();
				val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
				{
					new EffectData
					{
						m_prefab = prefab3
					}
				};
				buildStone = val;
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Error while running OnVanillaLoad SFX: " + ex.Message));
			}
			finally
			{
				Logger.LogMessage((object)"Loading Dirty Hoe SFX...");
				PrefabManager.OnVanillaPrefabsAvailable -= LoadSFX;
			}
		}

		private void LoadPrefabs()
		{
			try
			{
				AddSmooth();
				AddFlatten();
				AddLower();
				AddRaise();
				AddCultivateSmooth();
				AddCultivateFlatten();
				AddHoePavedSmooth();
				AddHoePavedFlatten();
				AddHoeDirtPath();
				AddPaintDirt();
				AddPaintCultivate();
				AddPaintPaved();
				AddPaintGrass();
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Error while running OnVanillaLoad Prefabs: " + ex.Message));
			}
			finally
			{
				Logger.LogMessage((object)"Loading Dirty Hoe Prefabs...");
				PrefabManager.OnVanillaPrefabsAvailable -= LoadPrefabs;
			}
		}

		private void AddCommands()
		{
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new RemoveForestry());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new RemovePieces());
		}

		public static bool IsHeadless()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			return (int)SystemInfo.graphicsDeviceType == 4;
		}

		private void AddSmooth()
		{
			//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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			_gameObject = magicBundle.LoadAsset<GameObject>("mm_smooth");
			_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
			{
				PieceTable = "_DirtyHoePieceTable",
				Category = "Misc"
			});
			_gameObject.GetComponent<Piece>().m_placeEffect = buildHoe;
			PieceManager.Instance.AddPiece(_customPiece);
		}

		private void AddFlatten()
		{
			//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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			_gameObject = magicBundle.LoadAsset<GameObject>("mm_flatten");
			_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
			{
				PieceTable = "_DirtyHoePieceTable",
				Category = "Misc"
			});
			_gameObject.GetComponent<Piece>().m_placeEffect = buildHoe;
			if (toolShape.Value == Shape.Circle)
			{
				_gameObject.GetComponent<TerrainOp>().m_settings.m_square = false;
			}
			else
			{
				_gameObject.GetComponent<TerrainOp>().m_settings.m_square = true;
			}
			PieceManager.Instance.AddPiece(_customPiece);
		}

		private void AddLower()
		{
			//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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			_gameObject = magicBundle.LoadAsset<GameObject>("mm_lower");
			_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
			{
				PieceTable = "_DirtyHoePieceTable",
				Category = "Misc"
			});
			_gameObject.GetComponent<Piece>().m_placeEffect = buildStone;
			PieceManager.Instance.AddPiece(_customPiece);
		}

		private void AddRaise()
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			_gameObject = magicBundle.LoadAsset<GameObject>("mm_raise");
			if (resourceCosts.Value)
			{
				GameObject gameObject = _gameObject;
				PieceConfig val = new PieceConfig();
				val.PieceTable = "_DirtyHoePieceTable";
				val.Category = "Misc";
				val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
				{
					new RequirementConfig
					{
						Item = "Stone",
						Amount = 2
					}
				};
				_customPiece = new CustomPiece(gameObject, true, val);
			}
			else
			{
				_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
				{
					PieceTable = "_DirtyHoePieceTable",
					Category = "Misc"
				});
			}
			_gameObject.GetComponent<Piece>().m_placeEffect = buildHoe;
			PieceManager.Instance.AddPiece(_customPiece);
		}

		private void AddCultivateSmooth()
		{
			//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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			_gameObject = magicBundle.LoadAsset<GameObject>("mm_cultivate_smooth");
			_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
			{
				PieceTable = "_DirtyHoePieceTable",
				Category = "Misc"
			});
			_gameObject.GetComponent<Piece>().m_placeEffect = buildCultivater;
			PieceManager.Instance.AddPiece(_customPiece);
		}

		private void AddCultivateFlatten()
		{
			//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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			_gameObject = magicBundle.LoadAsset<GameObject>("mm_cultivate_flatten");
			_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
			{
				PieceTable = "_DirtyHoePieceTable",
				Category = "Misc"
			});
			_gameObject.GetComponent<Piece>().m_placeEffect = buildCultivater;
			if (toolShape.Value == Shape.Circle)
			{
				_gameObject.GetComponent<TerrainOp>().m_settings.m_square = false;
			}
			else
			{
				_gameObject.GetComponent<TerrainOp>().m_settings.m_square = true;
			}
			PieceManager.Instance.AddPiece(_customPiece);
		}

		private void AddHoePavedSmooth()
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			_gameObject = magicBundle.LoadAsset<GameObject>("mm_paved_smooth");
			if (resourceCosts.Value)
			{
				GameObject gameObject = _gameObject;
				PieceConfig val = new PieceConfig();
				val.PieceTable = "_DirtyHoePieceTable";
				val.Category = "Misc";
				val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
				{
					new RequirementConfig
					{
						Item = "Stone",
						Amount = 1
					}
				};
				_customPiece = new CustomPiece(gameObject, true, val);
			}
			else
			{
				_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
				{
					PieceTable = "_DirtyHoePieceTable",
					Category = "Misc"
				});
			}
			_gameObject.GetComponent<Piece>().m_placeEffect = buildHoe;
			PieceManager.Instance.AddPiece(_customPiece);
		}

		private void AddHoePavedFlatten()
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			_gameObject = magicBundle.LoadAsset<GameObject>("mm_paved_flatten");
			if (resourceCosts.Value)
			{
				GameObject gameObject = _gameObject;
				PieceConfig val = new PieceConfig();
				val.PieceTable = "_DirtyHoePieceTable";
				val.Category = "Misc";
				val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
				{
					new RequirementConfig
					{
						Item = "Stone",
						Amount = 1
					}
				};
				_customPiece = new CustomPiece(gameObject, true, val);
			}
			else
			{
				_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
				{
					PieceTable = "_DirtyHoePieceTable",
					Category = "Misc"
				});
			}
			_gameObject.GetComponent<Piece>().m_placeEffect = buildHoe;
			if (toolShape.Value == Shape.Circle)
			{
				_gameObject.GetComponent<TerrainOp>().m_settings.m_square = false;
			}
			else
			{
				_gameObject.GetComponent<TerrainOp>().m_settings.m_square = true;
			}
			PieceManager.Instance.AddPiece(_customPiece);
		}

		private void AddHoeDirtPath()
		{
			//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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			_gameObject = magicBundle.LoadAsset<GameObject>("mm_dirt_path");
			_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
			{
				PieceTable = "_DirtyHoePieceTable",
				Category = "Misc"
			});
			_gameObject.GetComponent<Piece>().m_placeEffect = buildHoe;
			PieceManager.Instance.AddPiece(_customPiece);
		}

		private void AddPaintDirt()
		{
			//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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			_gameObject = magicBundle.LoadAsset<GameObject>("mm_paint_dirt");
			_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
			{
				PieceTable = "_DirtyHoePieceTable",
				Category = "Paint"
			});
			_gameObject.GetComponent<Piece>().m_placeEffect = buildCultivater;
			PieceManager.Instance.AddPiece(_customPiece);
		}

		private void AddPaintCultivate()
		{
			//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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			_gameObject = magicBundle.LoadAsset<GameObject>("mm_paint_cultivate");
			_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
			{
				PieceTable = "_DirtyHoePieceTable",
				Category = "Paint"
			});
			_gameObject.GetComponent<Piece>().m_placeEffect = buildCultivater;
			PieceManager.Instance.AddPiece(_customPiece);
		}

		private void AddPaintPaved()
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			_gameObject = magicBundle.LoadAsset<GameObject>("mm_paint_paved");
			if (resourceCosts.Value)
			{
				GameObject gameObject = _gameObject;
				PieceConfig val = new PieceConfig();
				val.PieceTable = "_DirtyHoePieceTable";
				val.Category = "Paint";
				val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
				{
					new RequirementConfig
					{
						Item = "Stone",
						Amount = 1
					}
				};
				_customPiece = new CustomPiece(gameObject, true, val);
			}
			else
			{
				_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
				{
					PieceTable = "_DirtyHoePieceTable",
					Category = "Paint"
				});
			}
			_gameObject.GetComponent<Piece>().m_placeEffect = buildCultivater;
			PieceManager.Instance.AddPiece(_customPiece);
		}

		private void AddPaintGrass()
		{
			//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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			_gameObject = magicBundle.LoadAsset<GameObject>("mm_paint_grass");
			_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
			{
				PieceTable = "_DirtyHoePieceTable",
				Category = "Paint"
			});
			_gameObject.GetComponent<Piece>().m_placeEffect = buildCultivater;
			PieceManager.Instance.AddPiece(_customPiece);
		}

		public static int ResetTerrain(Vector3 center, float radius)
		{
			//IL_0008: 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_005f: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			List<Heightmap> list = new List<Heightmap>();
			Heightmap.FindHeightmap(center, radius + 100f, list);
			foreach (TerrainModifier allInstance in TerrainModifier.GetAllInstances())
			{
				Vector3 position = ((Component)allInstance).transform.position;
				ZNetView component = ((Component)allInstance).GetComponent<ZNetView>();
				if (!((Object)(object)component != (Object)null) || !component.IsValid() || !component.IsOwner() || !(Utils.DistanceXZ(position, center) <= radius))
				{
					continue;
				}
				num++;
				foreach (Heightmap item in list)
				{
					if (item.TerrainVSModifier(allInstance))
					{
						item.Poke(true);
					}
				}
				component.Destroy();
			}
			using (List<Heightmap>.Enumerator enumerator3 = list.GetEnumerator())
			{
				int num2 = default(int);
				int num3 = default(int);
				while (enumerator3.MoveNext())
				{
					TerrainComp val = TerrainComp.FindTerrainCompiler(((Component)enumerator3.Current).transform.position);
					if (!Object.op_Implicit((Object)(object)val))
					{
						continue;
					}
					Traverse val2 = Traverse.Create((object)val);
					if (!val2.Field("m_initialized").GetValue<bool>())
					{
						continue;
					}
					enumerator3.Current.WorldToVertex(center, ref num2, ref num3);
					bool[] value = val2.Field("m_modifiedHeight").GetValue<bool[]>();
					float[] value2 = val2.Field("m_levelDelta").GetValue<float[]>();
					float[] value3 = val2.Field("m_smoothDelta").GetValue<float[]>();
					bool[] value4 = val2.Field("m_modifiedPaint").GetValue<bool[]>();
					Color[] value5 = val2.Field("m_paintMask").GetValue<Color[]>();
					int value6 = val2.Field("m_width").GetValue<int>();
					int num4 = 0;
					bool flag = false;
					int num5 = value6 + 1;
					for (int i = 0; i < num5; i++)
					{
						for (int j = 0; j < num5; j++)
						{
							int num6 = i * num5 + j;
							if (value[num6] && !(CoordDistance(num2, num3, j, i) > radius))
							{
								num++;
								num4++;
								flag = true;
								value[num6] = false;
								value2[num6] = 0f;
								value3[num6] = 0f;
							}
						}
					}
					num5 = value6;
					for (int k = 0; k < num5; k++)
					{
						for (int l = 0; l < num5; l++)
						{
							int num7 = k * num5 + l;
							if (value4[num7] && !(CoordDistance(num2, num3, l, k) > radius))
							{
								flag = true;
								value4[num7] = false;
								value5[num7] = Color.clear;
							}
						}
					}
					if (flag)
					{
						val2.Field("m_modifiedHeight").SetValue((object)value);
						val2.Field("m_levelDelta").SetValue((object)value2);
						val2.Field("m_smoothDelta").SetValue((object)value3);
						val2.Field("m_modifiedPaint").SetValue((object)value4);
						val2.Field("m_paintMask").SetValue((object)value5);
						val2.Method("Save", Array.Empty<object>()).GetValue();
						enumerator3.Current.Poke(true);
					}
				}
			}
			if (num > 0 && Object.op_Implicit((Object)(object)ClutterSystem.instance))
			{
				ClutterSystem.instance.ResetGrass(center, radius);
			}
			return num;
		}

		private static float CoordDistance(float x, float y, float rx, float ry)
		{
			float num = x - rx;
			float num2 = y - ry;
			return Mathf.Sqrt(num * num + num2 * num2);
		}

		private void SetRadius(float delta)
		{
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			Traverse obj = Traverse.Create((object)Player.m_localPlayer).Field("m_buildPieces");
			object obj2;
			if (obj == null)
			{
				obj2 = null;
			}
			else
			{
				PieceTable value = obj.GetValue<PieceTable>();
				obj2 = ((value != null) ? value.GetSelectedPiece() : null);
			}
			Piece val = (Piece)obj2;
			if (val == null)
			{
				return;
			}
			TerrainOp val2 = ((val != null) ? ((Component)val).gameObject.GetComponent<TerrainOp>() : null);
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			float num = 0f;
			float num2 = Mathf.Max(lastModdedRadius + delta, 0f);
			lastTotalDelta += delta;
			if (lastOriginalRadius == 0f)
			{
				if (val2.m_settings.m_level && num < val2.m_settings.m_levelRadius)
				{
					num = val2.m_settings.m_levelRadius;
					num2 = Mathf.Max(val2.m_settings.m_levelRadius + delta, 0f);
				}
				if (val2.m_settings.m_raise && num < val2.m_settings.m_raiseRadius)
				{
					num = val2.m_settings.m_raiseRadius;
					num2 = Mathf.Max(val2.m_settings.m_raiseRadius + delta, 0f);
				}
				if (val2.m_settings.m_smooth && num < val2.m_settings.m_smoothRadius)
				{
					num = val2.m_settings.m_smoothRadius;
					num2 = Mathf.Max(val2.m_settings.m_smoothRadius + delta, 0f);
				}
				if (val2.m_settings.m_paintCleared && num < val2.m_settings.m_paintRadius)
				{
					num = val2.m_settings.m_paintRadius;
					num2 = Mathf.Max(val2.m_settings.m_paintRadius + delta, 0f);
				}
				lastOriginalRadius = num;
			}
			lastModdedRadius = num2;
			if (lastOriginalRadius > 0f && lastModdedRadius > 0f)
			{
				GameObject value2 = Traverse.Create((object)Player.m_localPlayer).Field("m_placementGhost").GetValue<GameObject>();
				Transform val3 = ((value2 != null) ? value2.transform.Find("_GhostOnly") : null);
				if ((Object)(object)val3 != (Object)null)
				{
					val3.localScale = new Vector3(lastModdedRadius / lastOriginalRadius, lastModdedRadius / lastOriginalRadius, lastModdedRadius / lastOriginalRadius);
				}
			}
		}
	}
}
namespace MyDirtyHoe.ConsoleCommands
{
	public class RemoveForestry : ConsoleCommand
	{
		public override string Name => "remove_forestry";

		public override string Help => "removes trees, shrubs, rocks etc in a " + MyDirtyHoeMod.forestRadius.Value + "m radius";

		public override void Run(string[] args)
		{
			//IL_0036: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Invalid comparison between Unknown and I4
			//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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Invalid comparison between Unknown and I4
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			Game.instance.GetPlayerProfile().GetPlayerID();
			Player localPlayer = Player.m_localPlayer;
			TreeBase[] array = Object.FindObjectsOfType<TreeBase>();
			Destructible[] array2 = Object.FindObjectsOfType<Destructible>();
			Pickable[] array3 = Object.FindObjectsOfType<Pickable>();
			for (int i = 0; i < array.Length; i++)
			{
				if (Vector3.Distance(((Component)array[i]).transform.position, ((Component)localPlayer).transform.position) < MyDirtyHoeMod.forestRadius.Value)
				{
					((Component)array[i]).GetComponent<ZNetView>().Destroy();
				}
			}
			for (int j = 0; j < array2.Length; j++)
			{
				if (((int)array2[j].m_destructibleType == 2 || (int)array2[j].m_destructibleType == 1) && Vector3.Distance(((Component)array2[j]).transform.position, ((Component)localPlayer).transform.position) < MyDirtyHoeMod.forestRadius.Value)
				{
					((Component)array2[j]).GetComponent<ZNetView>().Destroy();
				}
			}
			for (int k = 0; k < array3.Length; k++)
			{
				if (Vector3.Distance(((Component)array3[k]).transform.position, ((Component)localPlayer).transform.position) < MyDirtyHoeMod.forestRadius.Value)
				{
					((Component)array3[k]).GetComponent<ZNetView>().Destroy();
				}
			}
		}
	}
	public class RemovePieces : ConsoleCommand
	{
		public static List<Vector3> treeRadiuses = new List<Vector3>();

		public static List<Piece> sPieces = new List<Piece>();

		public override string Name => "remove_pieces";

		public override string Help => "removes all structures around the player in a " + MyDirtyHoeMod.pieceRadius.Value + "m radius";

		public override void Run(string[] args)
		{
			//IL_0037: 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)
			Piece[] array = Object.FindObjectsOfType<Piece>();
			Game.instance.GetPlayerProfile().GetPlayerID();
			Player localPlayer = Player.m_localPlayer;
			GetNearbySPieces();
			for (int i = 0; i < array.Length; i++)
			{
				if (array[i].IsCreator() && Vector3.Distance(((Component)array[i]).transform.position, ((Component)localPlayer).transform.position) < MyDirtyHoeMod.pieceRadius.Value)
				{
					((Component)array[i]).GetComponent<ZNetView>().Destroy();
				}
			}
		}

		private static void GetNearbySPieces()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			sPieces.Clear();
			Piece.GetAllPiecesInRadius(((Component)localPlayer).transform.position, MyDirtyHoeMod.pieceRadius.Value, sPieces);
			sPieces = sPieces.Where((Piece p) => (int)p.m_category > 0).ToList();
			foreach (Piece sPiece in sPieces)
			{
				sPiece.SetCreator(Game.instance.GetPlayerProfile().GetPlayerID());
			}
		}
	}
}