Decompiled source of ErenshorQoL v1.9.25

ErenshorQoL.dll

Decompiled 4 days ago
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ErenshorQoL")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+37a86486b7ec314f4a08c632a7b07123deba55a3")]
[assembly: AssemblyProduct("ErenshorQoL")]
[assembly: AssemblyTitle("ErenshorQoL")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace ErenshorQoL
{
	[BepInPlugin("Brumdail.ErenshorQoLMod", "Erenshor Quality of Life Mods", "1.9.23.0000")]
	[BepInProcess("Erenshor.exe")]
	public class ErenshorQoLMod : BaseUnityPlugin
	{
		public enum Toggle
		{
			Off,
			On
		}

		internal class AcceptableShortcuts : AcceptableValueBase
		{
			public AcceptableShortcuts()
				: base(typeof(KeyboardShortcut))
			{
			}

			public override object Clamp(object value)
			{
				return value;
			}

			public override bool IsValid(object value)
			{
				return true;
			}

			public override string ToDescriptionString()
			{
				return "# Acceptable values: " + string.Join(", ", UnityInput.Current.SupportedKeyCodes);
			}
		}

		public class AutoPet
		{
			public static void AutoSendPet(string activatedFrom)
			{
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Invalid comparison between Unknown and I4
				bool flag = (Object)(object)GameData.PlayerControl.Myself.MyCharmedNPC != (Object)null;
				bool flag2 = (Object)(object)GameData.PlayerControl.CurrentTarget != (Object)null;
				NPC myCharmedNPC = GameData.PlayerControl.Myself.MyCharmedNPC;
				Character currentTarget = GameData.PlayerControl.CurrentTarget;
				bool flag3 = false;
				if (flag2 && flag && (Object)(object)GameData.PlayerControl.CurrentTarget != (Object)null && GameData.PlayerControl.CurrentTarget.AggressiveTowards.Contains(GameData.PlayerControl.Myself.MyFaction) && (int)GameData.PlayerControl.CurrentTarget.MyFaction != 13 && !GameData.PlayerControl.CurrentTarget.Invulnerable)
				{
					flag3 = true;
				}
				if (flag && flag2 && flag3 && ((Object)(object)myCharmedNPC.CurrentAggroTarget == (Object)null || (Object)(object)myCharmedNPC.CurrentAggroTarget != (Object)(object)currentTarget) && flag2)
				{
					myCharmedNPC.CurrentAggroTarget = currentTarget;
				}
			}

			public static void AutoBackoffPet(string activatedFrom)
			{
				if ((Object)(object)GameData.PlayerControl.Myself.MyCharmedNPC != (Object)null && (Object)(object)GameData.PlayerControl.Myself.MyCharmedNPC.CurrentAggroTarget != (Object)null)
				{
					GameData.PlayerControl.Myself.MyCharmedNPC.CurrentAggroTarget = null;
					UpdateSocialLog.LogAdd(GameData.PlayerControl.Myself.MyCharmedNPC.NPCName.ToString() + " says: backing off...");
				}
			}
		}

		public class AutoAttack
		{
			public static void EnableAutoAttack(string activatedFrom)
			{
				//IL_004e: 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_006e: Invalid comparison between Unknown and I4
				bool flag = false;
				if (flag)
				{
					UpdateSocialLog.LogAdd("Auto-Attack On " + activatedFrom + " - GameData.Autoattacking is: {GameData.Autoattacking}", "lightblue");
				}
				if (!((Object)(object)GameData.PlayerControl.CurrentTarget != (Object)null) || !GameData.PlayerControl.CurrentTarget.AggressiveTowards.Contains(GameData.PlayerControl.Myself.MyFaction) || (int)GameData.PlayerControl.CurrentTarget.MyFaction == 13 || GameData.PlayerControl.CurrentTarget.Invulnerable)
				{
					return;
				}
				PlayerCombat component = ((Component)GameData.PlayerControl.Myself).GetComponent<PlayerCombat>();
				if ((Object)(object)component != (Object)null)
				{
					MethodInfo methodInfo = AccessTools.Method(typeof(PlayerCombat), "ToggleAttack", (Type[])null, (Type[])null);
					if (methodInfo != null)
					{
						methodInfo.Invoke(component, null);
					}
					if (flag)
					{
						UpdateSocialLog.LogAdd("Activeated Auto-Attack On " + activatedFrom + " - GameData.Autoattacking is: {GameData.Autoattacking}", "orange");
					}
				}
			}
		}

		[HarmonyPatch(typeof(TypeText))]
		[HarmonyPatch("CheckCommands")]
		public class QoLCommands
		{
			private static void HelpMods()
			{
				UpdateSocialLog.LogAdd("QoL Modded commands: ", "lightblue");
				UpdateSocialLog.LogAdd("/bank - Opens the bank window", "lightblue");
				UpdateSocialLog.LogAdd("/forge - Opens the forge (blacksmithing) window", "lightblue");
				UpdateSocialLog.LogAdd("/auction - Opens the auction hall window", "lightblue");
				UpdateSocialLog.LogAdd("/allscenes - Lists all scenes", "lightblue");
			}

			private static void HelpPlayer()
			{
				UpdateSocialLog.LogAdd("\nPlayers commands:", "yellow");
				UpdateSocialLog.LogAdd("/players - Get a list of players in zone", "yellow");
				UpdateSocialLog.LogAdd("/whisper PlayerName Msg - Send a private message", "yellow");
				UpdateSocialLog.LogAdd("/group - Send a message to your group (wait, attack, guard, etc)", "yellow");
				UpdateSocialLog.LogAdd("/dance - boogie down.", "yellow");
				UpdateSocialLog.LogAdd("/keyring - List held keys", "yellow");
				UpdateSocialLog.LogAdd("/showmap - Toggle the Map", "yellow");
				UpdateSocialLog.LogAdd("/ruleset - Display server modifiers", "yellow");
				UpdateSocialLog.LogAdd("/all players || /all pla - List all players in Erenshor", "yellow");
				UpdateSocialLog.LogAdd("/portsim SimName - Teleport specified SimPlayer to player", "yellow");
				UpdateSocialLog.LogAdd("/shout - Message the entire zone", "yellow");
				UpdateSocialLog.LogAdd("/friend - Target SimPlayer is a FRIEND of this character. Their progress will be loosely tied to this character's progress.", "yellow");
				UpdateSocialLog.LogAdd("/time1 - Set Day/Night Cycle to normal speed. ");
				UpdateSocialLog.LogAdd("/time10, /time25, /time50 - Set TimeScale multiplier to 10x 25x or 50x speed.", "yellow");
				UpdateSocialLog.LogAdd("/time - See what time it is. ");
				UpdateSocialLog.LogAdd("/loc - Output player location X, Y, Z values", "yellow");
				UpdateSocialLog.LogAdd("Hotkeys:", "yellow");
				UpdateSocialLog.LogAdd("o - options", "yellow");
				UpdateSocialLog.LogAdd("i - inventory", "yellow");
				UpdateSocialLog.LogAdd("b - skills and spells book", "yellow");
				UpdateSocialLog.LogAdd("c - consider opponent", "yellow");
				UpdateSocialLog.LogAdd("h - greet your target", "yellow");
				UpdateSocialLog.LogAdd("q - autoattack toggle", "yellow");
				UpdateSocialLog.LogAdd("tab - cycle target", "yellow");
				UpdateSocialLog.LogAdd("spacebar - jump", "yellow");
				UpdateSocialLog.LogAdd("escape (hold) - exit to menu", "yellow");
			}

			private static void HelpGM()
			{
				UpdateSocialLog.LogAdd("\nGM commands: *not available in the demo build", "orange");
				UpdateSocialLog.LogAdd("/iamadev - Enable Dev Controls", "orange");
				UpdateSocialLog.LogAdd("/allitem - List all items", "orange");
				UpdateSocialLog.LogAdd("/item000, /item100, .../item 800  - List Items x00 through x99", "orange");
				UpdateSocialLog.LogAdd("/blessit - Bless item on mouse cursor", "orange");
				UpdateSocialLog.LogAdd("/additem 12 - (12: Cloth Sleeves) Add item to inventory; use /allitem or /item#00 to get item codes)", "orange");
				UpdateSocialLog.LogAdd("/cheater 35 (level 1-35) - OVERWRITE character level and load random level-appropriate equipment (CAUTION: Current character equipment and level will be overwritten!!)", "red");
				UpdateSocialLog.LogAdd("/loadset 35 (level 1-35) - Sets targetted SimPlayer to level and gear for level (CAUTION: Current character equipment and level will be overwritten!!)", "red");
				UpdateSocialLog.LogAdd("/bedazzl - Targetted SimPlayer gets equipment randomly upgraded to sparkly", "orange");
				UpdateSocialLog.LogAdd("/setnude - Targetted SimPlayer loses all equipment", "orange");
				UpdateSocialLog.LogAdd("/hpscale 1.0 (multiplier) - NPC HP scale modifier. You must zone to activate this modifier", "orange");
				UpdateSocialLog.LogAdd("/livenpc - List living NPCs in zone", "orange");
				UpdateSocialLog.LogAdd("/levelup - Maxes target's Earned XP", "orange");
				UpdateSocialLog.LogAdd("/level-- - Reduce target's level by 1", "orange");
				UpdateSocialLog.LogAdd("/simlocs - Report sim zone population", "orange");
				UpdateSocialLog.LogAdd("/sivakme - Add Sivakrux coin to inventory", "orange");
				UpdateSocialLog.LogAdd("/fastdev - Increases player RunSpeed to 24", "orange");
				UpdateSocialLog.LogAdd("/resists - Add 33 to all base resists", "orange");
				UpdateSocialLog.LogAdd("/raining - Changes atmosphere to raining", "orange");
				UpdateSocialLog.LogAdd("/thunder - Changes atmosphere to thunderstorm", "orange");
				UpdateSocialLog.LogAdd("/bluesky - Changes atmosphere to blue sky", "orange");
				UpdateSocialLog.LogAdd("/dosunny - Toggles sun", "orange");
				UpdateSocialLog.LogAdd("/cantdie - Target stays at max HP", "orange");
				UpdateSocialLog.LogAdd("/devkill - Kill current target", "orange");
				UpdateSocialLog.LogAdd("/killall - Kill all spawned NPCs", "orange");
				UpdateSocialLog.LogAdd("/add50xp - Add 50 xp to the player", "orange");
				UpdateSocialLog.LogAdd("/debugxp - Add 1000 xp to the player", "orange");
				UpdateSocialLog.LogAdd("/respec - Proficiency Points Reset", "orange");
				UpdateSocialLog.LogAdd("/specs - List targetted SimPlayer's proficiency points", "orange");
				UpdateSocialLog.LogAdd("/dospec - Targetted SimPlayer has proficiency points reset", "orange");
				UpdateSocialLog.LogAdd("/addphse - Applies Cave Lung debuff to the player", "red");
				UpdateSocialLog.LogAdd("/bombard - Applies a myriad of detrimental spells to the target.", "orange");
				UpdateSocialLog.LogAdd("/invisme - Toggle Dev Invis", "orange");
				UpdateSocialLog.LogAdd("/toscene Stowaway - Teleport to the named scene (may need to use Unstuck Me). Check scenes with /simlocs or use this list of Scenes: Stowaway, Tutorial, Abyssal, Azure, AzynthiClear, Blight, Bonepits, Brake, Braxonia, Braxonian, Duskenlight, Elderstone, FernallaField, Hidden, Krakengard, Loomingwood, Lost Cellar, Malaroth, PrielPlateau, Ripper, Rockshade, Rottenfoot, SaltedStrand, Silkengrass, Soluna, Underspine, Vitheo, VitheosEnd, Willowwatch, Windwashed", "orange");
				UpdateSocialLog.LogAdd("/invinci - Make player invincible", "orange");
				UpdateSocialLog.LogAdd("/faction 5 - Modify player's faction standing of the target's faction. Use negative numbers to decrease faction.", "orange");
			}

			private static void HelpOther()
			{
				UpdateSocialLog.LogAdd("\nOther GM commands: *not available in the demo build", "orange");
				UpdateSocialLog.LogAdd("/viewgec - View the total global economy", "orange");
				UpdateSocialLog.LogAdd("/resetec - Rest the total global economy to 0", "orange");
				UpdateSocialLog.LogAdd("/stoprev - Set party to relaxed state or report who is in combat", "orange");
				UpdateSocialLog.LogAdd("/gamepad - Gamepad Control Enabled (experimental)", "orange");
				UpdateSocialLog.LogAdd("/control - Toggle between modern and standard controls", "orange");
				UpdateSocialLog.LogAdd("/steamid - Lists which AppID and build is running)", "orange");
				UpdateSocialLog.LogAdd("/gamerdr - NPC shouts about GamesRadar release date", "orange");
				UpdateSocialLog.LogAdd("/testnre - Causes a Null Reference Exception for testing", "orange");
				UpdateSocialLog.LogAdd("/force2h - Target SimPlayer forced to use two-handed weapon", "orange");
				UpdateSocialLog.LogAdd("/ascview - View target SimPlayer ascensions", "orange");
				UpdateSocialLog.LogAdd("/limit20, /limit30, /limit60 - Sets target frame rate", "orange");
				UpdateSocialLog.LogAdd("/preview - Enable Demonstration Mode (CAUTION: Save Files will be overwritten!!)", "red");
				UpdateSocialLog.LogAdd("/rocfest - Enable RocFest Demonstration Mode (CAUTION: Save Files will be overwritten!!)", "red");
				UpdateSocialLog.LogAdd("/saveloc - Output Save Data location", "orange");
				UpdateSocialLog.LogAdd("/droneme - Toggle Drone Mode for Camera (/droneme again to turn off)", "orange");
				UpdateSocialLog.LogAdd("/debugap - List NPCs attacking the player", "orange");
				UpdateSocialLog.LogAdd("/spychar - List information about the target", "orange");
				UpdateSocialLog.LogAdd("/spyloot - List loot information about the target", "orange");
				UpdateSocialLog.LogAdd("/nodechk - List Nodes in the current zone", "orange");
				UpdateSocialLog.LogAdd("/yousolo - Removes SimPlayer from group", "orange");
				UpdateSocialLog.LogAdd("/dismiss - Dismiss SimPlayer from group", "orange");
				UpdateSocialLog.LogAdd("/allgrps - List group data", "orange");
				UpdateSocialLog.LogAdd("/delachv - Clear Achievements", "red");
				UpdateSocialLog.LogAdd("/bkquest - Load Back Quest Achievements", "orange");
			}

			private static bool Prefix()
			{
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0193: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
				if (QoLCommandsToggle.Value == Toggle.On)
				{
					bool flag = true;
					bool flag2 = true;
					bool flag3 = false;
					bool flag4 = true;
					bool flag5 = true;
					bool flag6 = true;
					if (GameData.TextInput.typed.text.Length >= 5 && flag && GameData.TextInput.typed.text.Substring(0, 5).ToLower() == "/bank")
					{
						if ((Object)(object)GameData.ItemOnCursor == (Object)null || (Object)(object)GameData.ItemOnCursor == (Object)(object)GameData.PlayerInv.Empty)
						{
							GameData.BankUI.OpenBank(((Component)GameData.PlayerControl).transform.position);
						}
						else
						{
							UpdateSocialLog.LogAdd("Remove item from cursor before interacting with a vendor.", "yellow");
						}
						GameData.TextInput.typed.text = "";
						GameData.TextInput.CDFrames = 10f;
						GameData.TextInput.InputBox.SetActive(false);
						GameData.PlayerTyping = false;
						return false;
					}
					if (GameData.TextInput.typed.text.Length >= 6 && flag2 && GameData.TextInput.typed.text.Substring(0, 6).ToLower() == "/forge")
					{
						if ((Object)(object)GameData.ItemOnCursor == (Object)null || (Object)(object)GameData.ItemOnCursor == (Object)(object)GameData.PlayerInv.Empty)
						{
							GameData.PlayerAud.PlayOneShot(GameData.Misc.SmithingOpen, GameData.PlayerAud.volume * GameData.SFXVol);
							GameData.Smithing.OpenWindow(((Component)GameData.PlayerControl).transform.position);
						}
						else
						{
							UpdateSocialLog.LogAdd("Remove item from cursor before interacting with a vendor.", "yellow");
						}
						GameData.TextInput.typed.text = "";
						GameData.TextInput.CDFrames = 10f;
						GameData.TextInput.InputBox.SetActive(false);
						GameData.PlayerTyping = false;
						return false;
					}
					if (GameData.TextInput.typed.text.Length >= 7 && flag3)
					{
						_ = GameData.TextInput.typed.text.Substring(0, 7).ToLower() == "/vendor";
					}
					if (GameData.TextInput.typed.text.Length >= 8 && flag4 && !GameData.GM.DemoBuild && GameData.TextInput.typed.text.Substring(0, 8).ToLower() == "/auction")
					{
						if ((Object)(object)GameData.ItemOnCursor == (Object)null || (Object)(object)GameData.ItemOnCursor == (Object)(object)GameData.PlayerInv.Empty)
						{
							GameData.AHUI.OpenAuctionHouse(((Component)GameData.PlayerControl).transform.position);
						}
						else
						{
							UpdateSocialLog.LogAdd("Remove item from cursor before interacting with a vendor.", "yellow");
						}
						GameData.TextInput.typed.text = "";
						GameData.TextInput.CDFrames = 10f;
						GameData.TextInput.InputBox.SetActive(false);
						GameData.PlayerTyping = false;
						return false;
					}
					if (GameData.TextInput.typed.text.Length >= 10 && flag5 && GameData.TextInput.typed.text.Substring(0, 10).ToLower() == "/allscenes")
					{
						StringBuilder stringBuilder = new StringBuilder("Stowaway, Tutorial");
						ZoneAtlasEntry[] atlas = ZoneAtlas.Atlas;
						foreach (ZoneAtlasEntry val in atlas)
						{
							stringBuilder.Append(", " + val.ZoneName);
						}
						string text = stringBuilder.ToString();
						UpdateSocialLog.LogAdd("Zone Names: " + text);
						GameData.TextInput.typed.text = "";
						GameData.TextInput.CDFrames = 10f;
						GameData.TextInput.InputBox.SetActive(false);
						GameData.PlayerTyping = false;
						return false;
					}
					if (GameData.TextInput.typed.text.Length >= 5 && flag6)
					{
						bool flag7 = false;
						bool flag8 = false;
						bool flag9 = false;
						bool flag10 = false;
						bool flag11 = false;
						if (GameData.TextInput.typed.text.Length >= 12)
						{
							flag10 = GameData.TextInput.typed.text.Substring(0, 12).ToLower() == "/help player";
						}
						else if (GameData.TextInput.typed.text.Length >= 11)
						{
							flag9 = GameData.TextInput.typed.text.Substring(0, 11).ToLower() == "/help other";
						}
						else if (GameData.TextInput.typed.text.Length >= 10)
						{
							flag8 = GameData.TextInput.typed.text.Substring(0, 10).ToLower() == "/help mods";
						}
						else if (GameData.TextInput.typed.text.Length >= 8)
						{
							flag7 = GameData.TextInput.typed.text.Substring(0, 8).ToLower() == "/help gm";
						}
						else if (GameData.TextInput.typed.text.Length >= 5)
						{
							flag11 = GameData.TextInput.typed.text.Substring(0, 5).ToLower() == "/help";
						}
						if (flag7 || flag8 || flag9 || flag10 || flag11)
						{
							if (flag7)
							{
								HelpGM();
							}
							else if (flag8)
							{
								HelpMods();
							}
							else if (flag9)
							{
								HelpOther();
							}
							else if (flag10)
							{
								HelpPlayer();
							}
							else if (flag11)
							{
								GameData.Misc.OpenCloseHelp();
								HelpOther();
								HelpGM();
								HelpPlayer();
								HelpMods();
								UpdateSocialLog.LogAdd("\nUse /help mods, /help gm, /help player, or /help other for the individual lists,", "orange");
							}
							GameData.TextInput.typed.text = "";
							GameData.TextInput.CDFrames = 10f;
							GameData.TextInput.InputBox.SetActive(false);
							GameData.PlayerTyping = false;
							return false;
						}
					}
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(UseSkill))]
		[HarmonyPatch("DoSkill")]
		public class AutoOnSkill
		{
			private static void Prefix()
			{
				if (AutoPetToggle.Value == Toggle.On && AutoPetOnSkillToggle.Value == Toggle.On)
				{
					AutoPet.AutoSendPet("Skill");
				}
				if (AutoAttackToggle.Value == Toggle.On && AutoAttackOnSkillToggle.Value == Toggle.On)
				{
					AutoAttack.EnableAutoAttack("Skill");
				}
			}
		}

		[HarmonyPatch(typeof(NPC))]
		[HarmonyPatch("AggroOn")]
		public class AutoOnAggro
		{
			private static void Postfix()
			{
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Expected O, but got Unknown
				if ((AutoPetToggle.Value == Toggle.On || AutoAttackToggle.Value == Toggle.On) && GameData.AttackingPlayer != null && GameData.AttackingPlayer.Count > 0 && (Object)(object)GameData.PlayerControl.CurrentTarget == (Object)null)
				{
					NPC obj = GameData.AttackingPlayer.First();
					Character val = (Character)AccessTools.Field(typeof(NPC), "Myself").GetValue(obj);
					if ((Object)(object)val != (Object)null && val.Alive && (Object)(object)GameData.PlayerControl.CurrentTarget == (Object)null)
					{
						val.TargetMe();
						GameData.PlayerControl.CurrentTarget = val;
					}
				}
				if (AutoPetToggle.Value == Toggle.On && (Object)(object)GameData.PlayerControl.CurrentTarget != (Object)null && AutoPetOnAggro.Value == Toggle.On)
				{
					AutoPet.AutoSendPet("Aggro");
				}
				if (AutoAttackToggle.Value == Toggle.On && (Object)(object)GameData.PlayerControl.CurrentTarget != (Object)null && AutoAttackOnAggro.Value == Toggle.On)
				{
					AutoAttack.EnableAutoAttack("Aggro");
				}
			}
		}

		[HarmonyPatch(typeof(PlayerCombat))]
		[HarmonyPatch("ToggleAttack")]
		private class AutoOnAutoattack
		{
			private static void Postfix()
			{
				if (AutoPetToggle.Value == Toggle.On)
				{
					if (AutoPetOnSkillToggle.Value == Toggle.On && GameData.Autoattacking)
					{
						AutoPet.AutoSendPet("AutoAttack");
					}
					if (AutoPetOnSkillToggle.Value == Toggle.On && !GameData.Autoattacking)
					{
						AutoPet.AutoBackoffPet("AutoAttack");
					}
				}
			}
		}

		[HarmonyPatch(typeof(AuctionHouseUI))]
		[HarmonyPatch("OpenListItem")]
		public class AutoPriceYourItem
		{
			private static void Postfix(AuctionHouseUI __instance)
			{
				if (AutoPriceItem.Value == Toggle.On)
				{
					int num = 0;
					num = GameData.SlotToBeListed.MyItem.ItemValue * 6 - 1;
					GameData.AHUI.ListPrice.text = $"{num}";
				}
			}
		}

		internal const string ModName = "ErenshorQoLMod";

		internal const string ModVersion = "1.9.23.0000";

		internal const string ModTitle = "Erenshor Quality of Life Mods";

		internal const string ModDescription = "Erenshor Quality of Life Mods";

		internal const string Author = "Brumdail";

		private const string ModGUID = "Brumdail.ErenshorQoLMod";

		private static string ConfigFileName = "Brumdail.ErenshorQoLMod.cfg";

		private static string ConfigFileFullPath = Paths.ConfigPath + Path.DirectorySeparatorChar + ConfigFileName;

		public bool appliedConfigChange;

		internal static ErenshorQoLMod context = null;

		private readonly Harmony harmony = new Harmony("Brumdail.ErenshorQoLMod");

		public static readonly ManualLogSource ErenshorQoLLogger = Logger.CreateLogSource("ErenshorQoLMod");

		internal static ConfigEntry<Toggle> AutoLootToggle = null;

		internal static ConfigEntry<Toggle> AutoLootDebug = null;

		internal static ConfigEntry<float> AutoLootDistance = null;

		internal static ConfigEntry<int> AutoLootMinimum = null;

		internal static ConfigEntry<Toggle> QoLCommandsToggle = null;

		internal static ConfigEntry<Toggle> AutoAttackToggle = null;

		internal static ConfigEntry<Toggle> AutoAttackOnSkillToggle = null;

		internal static ConfigEntry<Toggle> AutoAttackOnAggro = null;

		internal static ConfigEntry<Toggle> AutoPetToggle = null;

		internal static ConfigEntry<Toggle> AutoPetOnSkillToggle = null;

		internal static ConfigEntry<Toggle> AutoPetOnAggro = null;

		internal static ConfigEntry<Toggle> AutoPetOnAutoAttackToggle = null;

		internal static ConfigEntry<Toggle> AutoPriceItem = null;

		internal static ConfigEntry<Toggle> AutoLootToBankToggle = null;

		internal static bool _configApplied;

		private void Awake()
		{
			context = this;
			Utilities.GenerateConfigs();
			harmony.PatchAll();
			SetupWatcher();
		}

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
		}

		private void Update()
		{
		}

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

		private void ReadConfigValues(object sender, FileSystemEventArgs e)
		{
			if (!File.Exists(ConfigFileFullPath))
			{
				return;
			}
			try
			{
				((BaseUnityPlugin)this).Config.Reload();
				((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
			}
			catch
			{
				ErenshorQoLLogger.LogError((object)("There was an issue loading your " + ConfigFileName));
				ErenshorQoLLogger.LogError((object)"Please check your config entries for spelling and format!");
			}
		}

		internal ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description)
		{
			return ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, description);
		}

		internal ConfigEntry<T> config<T>(string group, string name, T value, string description)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			return ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()));
		}
	}
	public class Utilities
	{
		public static readonly ManualLogSource ErenshorUtilitiesLogger = Logger.CreateLogSource("ErenshorQoLUtilities");

		internal static void ApplyConfig()
		{
			ErenshorQoLMod._configApplied = true;
		}

		internal static void GenerateConfigs()
		{
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Expected O, but got Unknown
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Expected O, but got Unknown
			ErenshorQoLMod.QoLCommandsToggle = ErenshorQoLMod.context.config("2 - QoL Commands", "Enable QoL Commands", ErenshorQoLMod.Toggle.On, "Enable additional Quality of Life commands like /bank, /sell, /auction, updated /help etc.");
			ErenshorQoLMod.AutoAttackToggle = ErenshorQoLMod.context.config("3 - Auto Attack", "Enable Auto Attack", ErenshorQoLMod.Toggle.Off, "Enable automatically turning on auto-attack.");
			ErenshorQoLMod.AutoAttackOnSkillToggle = ErenshorQoLMod.context.config("3 - Auto Attack", "Auto Attack on Skill Use", ErenshorQoLMod.Toggle.Off, "Automatically start attacking when a skill is used.");
			ErenshorQoLMod.AutoAttackOnAggro = ErenshorQoLMod.context.config("3 - Auto Attack", "Auto Target,Attack on Aggro", ErenshorQoLMod.Toggle.Off, "Automatically target and start attacking when the group gains aggro.");
			ErenshorQoLMod.AutoPetToggle = ErenshorQoLMod.context.config("4 - Auto Pet", "Enable Auto Pet Command", ErenshorQoLMod.Toggle.Off, "Enable automatically commanding the pet to attack.");
			ErenshorQoLMod.AutoPetOnSkillToggle = ErenshorQoLMod.context.config("4 - Auto Pet", "Auto Pet Command on Skill Use", ErenshorQoLMod.Toggle.Off, "Automatically command the pet to attack when a skill is used.");
			ErenshorQoLMod.AutoPetOnAggro = ErenshorQoLMod.context.config("4 - Auto Pet", "Auto Pet Command on Skill Use", ErenshorQoLMod.Toggle.Off, "Automatically command the pet to attack when the group gains aggro.");
			ErenshorQoLMod.AutoPetOnAutoAttackToggle = ErenshorQoLMod.context.config("4 - Auto Pet", "Auto Pet Command on Auto Attack", ErenshorQoLMod.Toggle.On, "Automatically command the pet to attack when auto-attack is enabled.");
			ErenshorQoLMod.AutoPriceItem = ErenshorQoLMod.context.config("6 - Auto Price Item", "Auto Set AH Item Price", ErenshorQoLMod.Toggle.On, "Automatically start with the highest sellable auction house price when adding an item.");
			ConfigDefinition val = new ConfigDefinition("1 - AutoLoot", "Enable AutoLoot");
			ConfigDefinition val2 = new ConfigDefinition("1 - AutoLoot", "Auto Loot Distance");
			ConfigDefinition val3 = new ConfigDefinition("1 - AutoLoot", "Auto Loot Minimum Threshold");
			ConfigDefinition val4 = new ConfigDefinition("1 - AutoLoot", "AutoLoot Debug Messages");
			ConfigDefinition val5 = new ConfigDefinition("1 - AutoLoot", "Enable AutoLooting into the Bank");
			if (!ErenshorQoLMod.context.appliedConfigChange)
			{
				if (((BaseUnityPlugin)ErenshorQoLMod.context).Config.ContainsKey(val))
				{
					((BaseUnityPlugin)ErenshorQoLMod.context).Config.Remove(val);
					ErenshorUtilitiesLogger.LogInfo((object)"Removed obsolete setting: 'Enable AutoLoot'");
				}
				if (((BaseUnityPlugin)ErenshorQoLMod.context).Config.ContainsKey(val2))
				{
					((BaseUnityPlugin)ErenshorQoLMod.context).Config.Remove(val2);
					ErenshorUtilitiesLogger.LogInfo((object)"Removed obsolete setting: 'Auto Loot Distance'");
				}
				if (((BaseUnityPlugin)ErenshorQoLMod.context).Config.ContainsKey(val3))
				{
					((BaseUnityPlugin)ErenshorQoLMod.context).Config.Remove(val3);
					ErenshorUtilitiesLogger.LogInfo((object)"Removed obsolete setting: 'Auto Loot Minimum Threshold'");
				}
				if (((BaseUnityPlugin)ErenshorQoLMod.context).Config.ContainsKey(val4))
				{
					((BaseUnityPlugin)ErenshorQoLMod.context).Config.Remove(val4);
					ErenshorUtilitiesLogger.LogInfo((object)"Removed obsolete setting: 'AutoLoot Debug Messages'");
				}
				if (((BaseUnityPlugin)ErenshorQoLMod.context).Config.ContainsKey(val5))
				{
					((BaseUnityPlugin)ErenshorQoLMod.context).Config.Remove(val5);
					ErenshorUtilitiesLogger.LogInfo((object)"Removed obsolete setting: 'Enable AutoLooting into the Bank'");
				}
				if (ErenshorQoLMod.AutoAttackToggle.Value == ErenshorQoLMod.Toggle.On)
				{
					ErenshorQoLMod.AutoAttackToggle.Value = ErenshorQoLMod.Toggle.Off;
				}
				if (ErenshorQoLMod.AutoPetToggle.Value == ErenshorQoLMod.Toggle.On)
				{
					ErenshorQoLMod.AutoPetToggle.Value = ErenshorQoLMod.Toggle.Off;
				}
				ErenshorQoLMod.context.appliedConfigChange = true;
			}
		}
	}
}