Decompiled source of ErenshorQoL v1.1.0

ErenshorQoL.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
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("Brumdail")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+cbfa7107a1c71ebfe08593abb92a0dd0f1967812")]
[assembly: AssemblyProduct("ErenshorQoL")]
[assembly: AssemblyTitle("ErenshorQoL")]
[assembly: AssemblyVersion("1.1.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;
		}
	}
}
namespace ErenshorQoL
{
	[BepInPlugin("erenshorqol.ErenshorMod", "Erenshor Quality of Life Modpack", "1.1.0")]
	[BepInProcess("Erenshor.exe")]
	public class ErenshorMod : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Character))]
		[HarmonyPatch("DoDeath")]
		public class AutoLoot
		{
			private static bool _isEnabled = true;

			public static bool IsEnabled
			{
				get
				{
					return _isEnabled;
				}
				set
				{
					_isEnabled = value;
				}
			}

			private static void Postfix()
			{
				//IL_0081: 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_00a7: 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)
				if (!_isEnabled)
				{
					return;
				}
				bool flag = false;
				float num = 30f;
				if (CorpseDataManager.AllCorpseData == null || CorpseDataManager.AllCorpseData.Count <= 0)
				{
					return;
				}
				CorpseData val = null;
				foreach (CorpseData allCorpseDatum in CorpseDataManager.AllCorpseData)
				{
					if (allCorpseDatum != null && (Object)(object)allCorpseDatum.MyNPC != (Object)null && (Object)(object)((Component)allCorpseDatum.MyNPC).transform != (Object)null)
					{
						if (val == null)
						{
							val = allCorpseDatum;
						}
						float num2 = Vector3.Distance(((Component)GameData.PlayerControl).transform.position, ((Component)val.MyNPC).transform.position);
						float num3 = Vector3.Distance(((Component)GameData.PlayerControl).transform.position, ((Component)allCorpseDatum.MyNPC).transform.position);
						if (num3 < num && num3 < num2)
						{
							val = allCorpseDatum;
						}
					}
				}
				if (val == null)
				{
					return;
				}
				if (flag)
				{
					Debug.Log((object)("Corpse: " + ((object)val).ToString()));
				}
				if (flag)
				{
					UpdateSocialLog.LogAdd("Corpse: " + ((object)val).ToString());
				}
				if (!((Object)(object)val.MyNPC != (Object)null))
				{
					return;
				}
				if (flag)
				{
					Debug.Log((object)("NPC: " + ((object)val.MyNPC).ToString()));
				}
				if (flag)
				{
					UpdateSocialLog.LogAdd("NPC: " + ((object)val.MyNPC).ToString());
				}
				LootTable component = ((Component)val.MyNPC).GetComponent<LootTable>();
				if ((Object)(object)component != (Object)null && component.ActualDrops.Count > 0)
				{
					if (flag)
					{
						Debug.Log((object)("LootTable: " + ((object)component).ToString()));
					}
					if (flag)
					{
						UpdateSocialLog.LogAdd("LootTable: " + ((object)component).ToString());
					}
					component.LoadLootTable();
					if (flag)
					{
						Debug.Log((object)("LoadedLootTable: " + ((object)component).ToString()));
					}
					if (flag)
					{
						UpdateSocialLog.LogAdd("LoadedLootTable: " + ((object)component).ToString());
					}
					GameData.LootWindow.LootAll();
				}
			}
		}

		[HarmonyPatch(typeof(TypeText))]
		[HarmonyPatch("CheckCommands")]
		private class QoLCommands
		{
			private static bool _isEnabled = true;

			public static bool IsEnabled
			{
				get
				{
					return _isEnabled;
				}
				set
				{
					_isEnabled = value;
				}
			}

			private static bool Prefix()
			{
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				//IL_034a: Unknown result type (might be due to invalid IL or missing references)
				if (_isEnabled)
				{
					bool flag = true;
					bool flag2 = false;
					bool flag3 = true;
					bool flag4 = false;
					bool flag5 = true;
					if (GameData.TextInput.typed.text.Length >= 9 && GameData.TextInput.typed.text.Substring(0, 9).ToLower() == "/autoloot")
					{
						AutoLoot.IsEnabled = !AutoLoot.IsEnabled;
						UpdateSocialLog.LogAdd("AutoLoot: " + AutoLoot.IsEnabled, "orange");
						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 && flag && GameData.TextInput.typed.text.Substring(0, 5).ToLower() == "/bank")
					{
						GameData.BankUI.OpenBank(((Component)GameData.PlayerControl).transform.position);
						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 && flag2)
					{
						if (GameData.TextInput.typed.text.Substring(0, 7).ToLower() == "/vendor" && (Object)(object)GameData.PlayerControl.CurrentTarget != (Object)null && GameData.PlayerControl.CurrentTarget.isNPC)
						{
							Character currentTarget = GameData.PlayerControl.CurrentTarget;
							if (!currentTarget.isVendor)
							{
								currentTarget.isVendor = true;
							}
							if ((Object)(object)((Component)currentTarget).GetComponent<VendorInventory>() == (Object)null)
							{
								List<Item> itemsForSale = ((Component)currentTarget).GetComponent<VendorInventory>().ItemsForSale;
								Object obj = Resources.Load("Bread");
								itemsForSale.Add((Item)(object)((obj is Item) ? obj : null));
								List<Item> itemsForSale2 = ((Component)currentTarget).GetComponent<VendorInventory>().ItemsForSale;
								Object obj2 = Resources.Load("Water");
								itemsForSale2.Add((Item)(object)((obj2 is Item) ? obj2 : null));
								for (int i = 0; i <= 11; i++)
								{
									if (i >= ((Component)currentTarget).GetComponent<VendorInventory>().ItemsForSale.Count)
									{
										List<Item> itemsForSale3 = ((Component)currentTarget).GetComponent<VendorInventory>().ItemsForSale;
										Object obj3 = Resources.Load("Empty");
										itemsForSale3.Add((Item)(object)((obj3 is Item) ? obj3 : null));
									}
								}
								UpdateSocialLog.LogAdd("Vendor setup for: " + ((Object)currentTarget).name, "yellow");
								GameData.TextInput.typed.text = "";
								GameData.TextInput.CDFrames = 10f;
								GameData.TextInput.InputBox.SetActive(false);
								GameData.PlayerTyping = false;
								return false;
							}
						}
						else
						{
							UpdateSocialLog.LogAdd("/vendor command requires an NPC target", "yellow");
						}
					}
					if (GameData.TextInput.typed.text.Length >= 8 && flag3 && GameData.TextInput.typed.text.Substring(0, 8).ToLower() == "/auction")
					{
						GameData.AHUI.OpenAuctionHouse(((Component)GameData.PlayerControl).transform.position);
						GameData.TextInput.typed.text = "";
						GameData.TextInput.CDFrames = 10f;
						GameData.TextInput.InputBox.SetActive(false);
						GameData.PlayerTyping = false;
						return false;
					}
					if (GameData.TextInput.typed.text.Length >= 9 && flag4 && GameData.TextInput.typed.text.Substring(0, 9).ToLower() == "/allscene")
					{
						return false;
					}
					if (GameData.TextInput.typed.text.Length >= 5 && flag5 && GameData.TextInput.typed.text.Substring(0, 5).ToLower() == "/help")
					{
						UpdateSocialLog.LogAdd("QoL Modded commands: ", "lightblue");
						UpdateSocialLog.LogAdd("/autoloot - Toggles the feature to automatically Loot All items from the nearest corpse each time a creature dies.", "lightblue");
						UpdateSocialLog.LogAdd("/bank - Opens the bank window", "lightblue");
						UpdateSocialLog.LogAdd("/auction - Opens the auction hall window", "lightblue");
						UpdateSocialLog.LogAdd("\nGM commands: *most not available in the demo build", "orange");
						UpdateSocialLog.LogAdd("/iamadev - Enable Dev Controls", "orange");
						UpdateSocialLog.LogAdd("/allitem - List all items", "orange");
						UpdateSocialLog.LogAdd("/additem 11823624 - Add item (use /allitem to get item codes)", "orange");
						UpdateSocialLog.LogAdd("/hpscale 1.0 (multiplier) - NPC HP scale modifier. You must zone to activate this modifier", "orange");
						UpdateSocialLog.LogAdd("/loadset 35 (level 1-35) - Sets targetted SimPlayer to level and gear for level", "orange");
						UpdateSocialLog.LogAdd("/livenpc - List living NPCs in zone", "orange");
						UpdateSocialLog.LogAdd("/levelup - Maxes target's Earned XP", "orange");
						UpdateSocialLog.LogAdd("/simlocs - Report sim zone population", "orange");
						UpdateSocialLog.LogAdd("/fastdev - Increases player RunSpeed to 24", "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("/gamepad - Gamepad Control Enabled (experimental)", "orange");
						UpdateSocialLog.LogAdd("/devkill - Kill current target", "orange");
						UpdateSocialLog.LogAdd("/preview - Enable Demonstration Mode (CAUTION: Save Files will be overwritten!!)", "red");
						UpdateSocialLog.LogAdd("/invisme - Toggle Dev Invis", "orange");
						UpdateSocialLog.LogAdd("/toscene Stowaway - Teleport to the named scene", "orange");
						UpdateSocialLog.LogAdd("/droneme - Toggle Drone Mode", "orange");
						UpdateSocialLog.LogAdd("/debugap - List NPCs attacking the player", "orange");
						UpdateSocialLog.LogAdd("/spychar - List information about the target", "orange");
						UpdateSocialLog.LogAdd("/nodechk - List Nodes in the current zone", "orange");
						UpdateSocialLog.LogAdd("/faction 5 - Modify player's faction standing of the target's faction. Use negative numbers to decrease faction.", "orange");
						UpdateSocialLog.LogAdd("/yousolo - Removes SimPlayer from group", "orange");
						UpdateSocialLog.LogAdd("/allgrps - List group data", "orange");
						UpdateSocialLog.LogAdd("/portsim SimName - Teleport specified SimPlayer to player", "orange");
						UpdateSocialLog.LogAdd("\nPlayers commands:", "yellow");
						UpdateSocialLog.LogAdd("/players - Get a list of players in zone", "yellow");
						UpdateSocialLog.LogAdd("/time - Get the current game time", "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("/all players || /all pla - List all players in Erenshor", "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("/time 1, /time10, /time25, /time50 - Set TimeScale multiplier", "yellow");
						UpdateSocialLog.LogAdd("Hotkeys:", "yellow");
						UpdateSocialLog.LogAdd("o - options", "yellow");
						UpdateSocialLog.LogAdd("i - inventory", "yellow");
						UpdateSocialLog.LogAdd("b - skill book", "yellow");
						UpdateSocialLog.LogAdd("b - spell book", "yellow");
						UpdateSocialLog.LogAdd("c - consider opponent", "yellow");
						UpdateSocialLog.LogAdd("h - greet your target", "yellow");
						UpdateSocialLog.LogAdd("q - autoattack toggle", "yellow");
						UpdateSocialLog.LogAdd("escape (hold) - exit to menu", "yellow");
						GameData.TextInput.typed.text = "";
						GameData.TextInput.CDFrames = 10f;
						GameData.TextInput.InputBox.SetActive(false);
						GameData.PlayerTyping = false;
						return false;
					}
				}
				return true;
			}
		}

		private readonly Harmony harmony = new Harmony("erenshorqol.ErenshorMod");

		private void Awake()
		{
			harmony.PatchAll();
		}
	}
}