Decompiled source of OuthardAlchemyAndEnchanting v0.0.7

OuthardEnchanting.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using OutwardGameSettings.Managers;
using OutwardGameSettings.Utility.Helpers;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("OutwardEnchanter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OutwardEnchanter")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace OutwardGameSettings
{
	[BepInPlugin("gymmed.outwardgamesettings", "Outward Game Settings", "0.0.1")]
	public class OutwardGameSettings : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(ResourcesPrefabManager), "Load")]
		public class ResourcesPrefabManager_Load
		{
			private static void Postfix(ResourcesPrefabManager __instance)
			{
				EnchantmentsHelper.FixFilterRecipe();
			}
		}

		[HarmonyPatch(typeof(EnchantmentMenu), "TryEnchant")]
		public class Patch_TryEnchant
		{
			private static bool Prefix(EnchantmentMenu __instance)
			{
				if (!Object.op_Implicit((Object)(object)((SingleItemInventoryMenu)__instance).m_refItemInChest))
				{
					return true;
				}
				int enchantmentID = __instance.GetEnchantmentID();
				if (enchantmentID == -1 || ((SingleItemInventoryMenu)__instance).m_refItemInChest.IsEnchanted)
				{
					return true;
				}
				if ((Object)(object)ResourcesPrefabManager.Instance.GetEnchantmentPrefab(enchantmentID) == (Object)null)
				{
					return true;
				}
				if ((Object)(object)((SingleItemContainer)__instance.m_refEnchantmentStation).ContainedItem == (Object)null)
				{
					return true;
				}
				List<EnchantmentRecipeItem> availableEnchantmentRecipeItemsInInventory = EnchantmentsHelper.GetAvailableEnchantmentRecipeItemsInInventory(((SingleItemContainer)__instance.m_refEnchantmentStation).ContainedItem, ((UIElement)__instance).LocalCharacter.Inventory);
				if (RequireRecipeToAllowEnchant.Value && !EnchantmentsHelper.IsEnchantmentInList(enchantmentID, availableEnchantmentRecipeItemsInInventory))
				{
					((UIElement)__instance).m_characterUI.ShowInfoNotification("You need to have enchantment!");
					return false;
				}
				if (UseRecipeOnEnchanting.Value)
				{
					EnchantmentRecipeItem enchantmentInTheList = EnchantmentsHelper.GetEnchantmentInTheList(enchantmentID, availableEnchantmentRecipeItemsInInventory);
					if (Object.op_Implicit((Object)(object)enchantmentInTheList))
					{
						((UIElement)__instance).m_characterUI.ShowInfoNotification(((Item)enchantmentInTheList).Name + " has been used!");
						ItemManager.Instance.DestroyItem((Item)(object)enchantmentInTheList);
					}
				}
				return true;
			}
		}

		public const string GUID = "gymmed.outwardgamesettings";

		public const string NAME = "Outward Game Settings";

		public const string VERSION = "0.0.1";

		public static string prefix = "[GymMed-Game-Settings]";

		internal static ManualLogSource Log;

		public static ConfigEntry<bool> RequireRecipeToAllowEnchant;

		public static ConfigEntry<bool> UseRecipeOnEnchanting;

		public static ConfigEntry<int> EnchantingSuccessChance;

		public static ConfigEntry<bool> PlayAudioOnEnchantingDone;

		internal void Awake()
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogMessage((object)"Hello world from Outward Game Settings 0.0.1!");
			RequireRecipeToAllowEnchant = ((BaseUnityPlugin)this).Config.Bind<bool>("Enchanting Modifications", "RequireRecipeToAllowEnchant", true, "Allow enchanting only if enchantment is on character?");
			UseRecipeOnEnchanting = ((BaseUnityPlugin)this).Config.Bind<bool>("Enchanting Modifications", "UseRecipeOnEnchanting", true, "Remove recipe after using it on enchanting?");
			EnchantingSuccessChance = ((BaseUnityPlugin)this).Config.Bind<int>("Enchanting Modifications", "EnchantingSuccessChance", 50, "What is success chance(%) of enchanting?");
			PlayAudioOnEnchantingDone = ((BaseUnityPlugin)this).Config.Bind<bool>("Enchanting Modifications", "PlayAudioOnEnchantingDone", true, "Play additional audio on enchanting failed/success?");
			new Harmony("gymmed.outwardgamesettings").PatchAll();
		}

		internal void Update()
		{
		}

		public static void LogMessage(string message)
		{
			Log.LogMessage((object)(prefix + " " + message));
		}
	}
}
namespace OutwardGameSettings.Utility.Helpers
{
	public class ConfigsHelper
	{
		public static int GetPercentageValueFromConfig(int originalValue)
		{
			if (originalValue < 0)
			{
				return 0;
			}
			if (originalValue > 100)
			{
				return 100;
			}
			return originalValue;
		}
	}
	public class EnchantmentsHelper
	{
		public static List<EnchantmentRecipeItem> GetAvailableEnchantmentRecipeItemsInInventory(Item item, CharacterInventory inventory)
		{
			List<EnchantmentRecipeItem> allItemsOfType = ItemsHelper.GetAllItemsOfType<EnchantmentRecipeItem>(ItemsHelper.GetUniqueItemsInInventory(inventory));
			List<EnchantmentRecipeItem> list = new List<EnchantmentRecipeItem>();
			foreach (EnchantmentRecipeItem item2 in allItemsOfType)
			{
				EnchantmentRecipe[] recipes = item2.Recipes;
				for (int i = 0; i < recipes.Length; i++)
				{
					if (recipes[i].GetHasMatchingEquipment(item))
					{
						list.Add(item2);
					}
				}
			}
			return list;
		}

		public static List<EnchantmentRecipe> GetAvailableEnchantmentRecipies(Item item)
		{
			List<EnchantmentRecipe> enchantmentRecipes = RecipeManager.Instance.GetEnchantmentRecipes();
			List<EnchantmentRecipe> list = new List<EnchantmentRecipe>();
			foreach (EnchantmentRecipe item2 in enchantmentRecipes)
			{
				if (item2.GetHasMatchingEquipment(item))
				{
					list.Add(item2);
				}
			}
			return list;
		}

		public static List<EnchantmentRecipe> GetMissingEnchantments(List<EnchantmentRecipe> availableEnchantments, List<EnchantmentRecipe> haveEnchantments)
		{
			List<EnchantmentRecipe> list = new List<EnchantmentRecipe>();
			bool flag = false;
			foreach (EnchantmentRecipe availableEnchantment in availableEnchantments)
			{
				foreach (EnchantmentRecipe haveEnchantment in haveEnchantments)
				{
					if (availableEnchantment.RecipeID == haveEnchantment.RecipeID)
					{
						flag = true;
					}
				}
				if (flag)
				{
					flag = false;
				}
				else
				{
					list.Add(availableEnchantment);
				}
			}
			return list;
		}

		public static bool IsEnchantmentInList(int enchantmentId, List<EnchantmentRecipeItem> enchantmentItems)
		{
			foreach (EnchantmentRecipeItem enchantmentItem in enchantmentItems)
			{
				EnchantmentRecipe[] recipes = enchantmentItem.Recipes;
				for (int i = 0; i < recipes.Length; i++)
				{
					if (recipes[i].RecipeID == enchantmentId)
					{
						return true;
					}
				}
			}
			return false;
		}

		public static EnchantmentRecipeItem GetEnchantmentInTheList(int enchantmentId, List<EnchantmentRecipeItem> enchantmentItems)
		{
			foreach (EnchantmentRecipeItem enchantmentItem in enchantmentItems)
			{
				EnchantmentRecipe[] recipes = enchantmentItem.Recipes;
				for (int i = 0; i < recipes.Length; i++)
				{
					if (recipes[i].RecipeID == enchantmentId)
					{
						return enchantmentItem;
					}
				}
			}
			return null;
		}

		public static void FixFilterRecipe()
		{
			Item itemPrefab = ResourcesPrefabManager.Instance.GetItemPrefab("5800047");
			if ((Object)(object)itemPrefab == (Object)null)
			{
				return;
			}
			EnchantmentRecipeItem val = (EnchantmentRecipeItem)(object)((itemPrefab is EnchantmentRecipeItem) ? itemPrefab : null);
			if (Object.op_Implicit((Object)(object)val) && val.Recipes.Count() != 3)
			{
				EnchantmentRecipe enchantmentRecipeForID = RecipeManager.Instance.GetEnchantmentRecipeForID(52);
				EnchantmentRecipe enchantmentRecipeForID2 = RecipeManager.Instance.GetEnchantmentRecipeForID(53);
				EnchantmentRecipe enchantmentRecipeForID3 = RecipeManager.Instance.GetEnchantmentRecipeForID(54);
				if (!((Object)(object)enchantmentRecipeForID == (Object)null) && !((Object)(object)enchantmentRecipeForID2 == (Object)null) && !((Object)(object)enchantmentRecipeForID3 == (Object)null))
				{
					EnchantmentRecipe[] recipes = (EnchantmentRecipe[])(object)new EnchantmentRecipe[3] { enchantmentRecipeForID, enchantmentRecipeForID2, enchantmentRecipeForID3 };
					val.Recipes = recipes;
				}
			}
		}
	}
	public class ItemsHelper
	{
		public static List<T> GetAllItemsOfType<T>(List<Item> items) where T : Item
		{
			List<T> list = new List<T>();
			foreach (Item item in items)
			{
				T val = (T)(object)((item is T) ? item : null);
				if (val != null)
				{
					list.Add(val);
				}
			}
			return list;
		}

		public static List<Item> GetUniqueItemsInInventory(CharacterInventory inventory)
		{
			ItemContainer pouch = inventory.Pouch;
			List<Item> first = ((pouch != null) ? pouch.GetContainedItems() : null);
			List<Item> second = new List<Item>();
			if (inventory.HasABag)
			{
				second = ((ItemContainer)inventory.EquippedBag.Container).GetContainedItems();
			}
			return first.Union(second).ToList();
		}
	}
}
namespace OutwardGameSettings.Patches
{
	[HarmonyPatch(typeof(EnchantmentTable), "DoneEnchanting")]
	public class Patch_DoneEnchanting
	{
		private static bool Prefix(EnchantmentTable __instance)
		{
			int percentageValueFromConfig = ConfigsHelper.GetPercentageValueFromConfig(OutwardGameSettings.EnchantingSuccessChance.Value);
			if (percentageValueFromConfig != 100 && new Random().Next(1, 101) > percentageValueFromConfig)
			{
				__instance.ActivateFX(false);
				if (!PhotonNetwork.isNonMasterClientInRoom)
				{
					__instance.LockPillars(false);
				}
				__instance.ConsumeIncenses();
				__instance.m_pendingEnchantment = null;
				__instance.m_remainingEnchantTime = -999f;
				FieldInfo field = typeof(EnchantmentTable).GetField("OnDoneEnchanting", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field != null && field.GetValue(__instance) is EventHandler eventHandler)
				{
					eventHandler(__instance, EventArgs.Empty);
				}
				Enchantment pendingEnchantment = __instance.PendingEnchantment;
				if (((pendingEnchantment != null) ? pendingEnchantment.Name : null) != null && (Object)/*isinst with value type is only supported in some contexts*/ != (Object)null)
				{
					Item obj = ((ItemContainer)__instance).m_containedItems.Values[0];
					Equipment val = (Equipment)(object)((obj is Equipment) ? obj : null);
					NotificationsManager.Instance.BroadcastGlobalSideNotification(__instance.PendingEnchantment.Name + " on " + ((Item)val).DisplayName + " failed!");
				}
				else
				{
					NotificationsManager.Instance.BroadcastGlobalSideNotification("Enchanting failed!");
				}
				if (OutwardGameSettings.PlayAudioOnEnchantingDone.Value)
				{
					Global.AudioManager.PlaySoundAtPosition((Sounds)11145, ((Component)__instance).transform, 0f, 1f, 1f, 1f, 1f);
				}
				return false;
			}
			Enchantment pendingEnchantment2 = __instance.PendingEnchantment;
			if (((pendingEnchantment2 != null) ? pendingEnchantment2.Name : null) != null && (Object)/*isinst with value type is only supported in some contexts*/ != (Object)null)
			{
				Item obj2 = ((ItemContainer)__instance).m_containedItems.Values[0];
				Equipment val2 = (Equipment)(object)((obj2 is Equipment) ? obj2 : null);
				NotificationsManager.Instance.BroadcastGlobalSideNotification(__instance.PendingEnchantment.Name + " on " + ((Item)val2).DisplayName + " succeeded!");
			}
			else
			{
				NotificationsManager.Instance.BroadcastGlobalSideNotification("Enchanting succeeded!");
			}
			if (OutwardGameSettings.PlayAudioOnEnchantingDone.Value)
			{
				Global.AudioManager.PlaySoundAtPosition((Sounds)13130, ((Component)__instance).transform, 0f, 1f, 1f, 1f, 1f);
			}
			return true;
		}
	}
}
namespace OutwardGameSettings.Managers
{
	public class NotificationsManager
	{
		private static NotificationsManager _instance;

		public static NotificationsManager Instance
		{
			get
			{
				if (_instance == null)
				{
					_instance = new NotificationsManager();
				}
				return _instance;
			}
		}

		private NotificationsManager()
		{
		}

		public void BroadcastGlobalSideNotification(string message)
		{
			Character val = null;
			foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
			{
				val = item.ControlledCharacter;
				if ((Object)(object)val?.CharacterUI != (Object)null)
				{
					val.CharacterUI.ShowInfoNotification(message);
				}
			}
		}

		public void BroadcastGlobalTopNotification(string message)
		{
			Character val = null;
			foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
			{
				val = item.ControlledCharacter;
				object obj;
				if (val == null)
				{
					obj = null;
				}
				else
				{
					CharacterUI characterUI = val.CharacterUI;
					obj = ((characterUI != null) ? characterUI.NotificationPanel : null);
				}
				if ((Object)obj != (Object)null)
				{
					val.CharacterUI.NotificationPanel.ShowNotification(message);
				}
			}
		}
	}
}

OuthardEraser.dll

Decompiled 3 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Wip")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Wip")]
[assembly: AssemblyCopyright("Copyright ©  2019")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f88dcfe5-655e-48a7-a41d-4a5d75b024df")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace EraserElixir
{
	[BepInPlugin("fr.lasyan3.eraserelixir", "EraserElixir", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class PotionResetSkills : BaseUnityPlugin
	{
		private const string ID = "fr.lasyan3.eraserelixir";

		private const string NAME = "EraserElixir";

		private const string VERSION = "1.0.1";

		public static PotionResetSkills Instance;

		public ManualLogSource MyLogger => ((BaseUnityPlugin)this).Logger;

		internal void Awake()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Instance = this;
				new Harmony("fr.lasyan3.eraserelixir").PatchAll();
				MyLogger.LogDebug((object)"Awaken");
			}
			catch (Exception ex)
			{
				MyLogger.LogError((object)("Awake: " + ex.Message));
			}
		}

		private void SL_BeforePacksLoaded()
		{
		}
	}
}
namespace EraserElixir.Hooks
{
	[HarmonyPatch(typeof(Item), "OnUse")]
	public class RemoveSkillsOnUse
	{
		[HarmonyPrefix]
		public static bool OnUse(Item __instance, Character _targetChar)
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)_targetChar != (Object)null && __instance.ItemID == 4300191)
				{
					SkillSchool[] obj = (SkillSchool[])AccessTools.Field(typeof(SkillTreeHolder), "m_skillTrees").GetValue(SkillTreeHolder.Instance);
					int num = 0;
					SkillSchool[] array = obj;
					foreach (SkillSchool val in array)
					{
						int num2 = 42;
						foreach (BaseSkillSlot skillSlot in val.SkillSlots)
						{
							if (skillSlot is SkillSlot)
							{
								if (skillSlot.IsBreakthrough)
								{
									num2 = val.SkillSlots.IndexOf(skillSlot);
								}
								SkillSlot val2 = (SkillSlot)skillSlot;
								if (_targetChar.Inventory.LearnedSkill((Item)(object)val2.Skill) && val.SkillSlots.IndexOf(skillSlot) >= num2)
								{
									Item itemFromItemID = ((CharacterKnowledge)_targetChar.Inventory.SkillKnowledge).GetItemFromItemID(((Item)val2.Skill).ItemID);
									ItemManager.Instance.DestroyItem(itemFromItemID.UID);
									num++;
									if (skillSlot.IsBreakthrough)
									{
										AccessTools.Field(typeof(PlayerCharacterStats), "m_usedBreakthroughCount").SetValue(_targetChar.PlayerStats, _targetChar.PlayerStats.UsedBreakthroughCount - 1);
									}
								}
							}
							else
							{
								if (!(skillSlot is SkillSlotFork))
								{
									continue;
								}
								if (skillSlot.IsBreakthrough)
								{
									num2 = val.SkillSlots.IndexOf(skillSlot);
								}
								SkillSlot[] skillsToChooseFrom = ((SkillSlotFork)skillSlot).SkillsToChooseFrom;
								foreach (SkillSlot val3 in skillsToChooseFrom)
								{
									if (_targetChar.Inventory.LearnedSkill((Item)(object)val3.Skill) && val.SkillSlots.IndexOf(skillSlot) >= num2)
									{
										Item itemFromItemID2 = ((CharacterKnowledge)_targetChar.Inventory.SkillKnowledge).GetItemFromItemID(((Item)val3.Skill).ItemID);
										ItemManager.Instance.DestroyItem(itemFromItemID2.UID);
										num++;
										if (skillSlot.IsBreakthrough)
										{
											AccessTools.Field(typeof(PlayerCharacterStats), "m_usedBreakthroughCount").SetValue(_targetChar.PlayerStats, _targetChar.PlayerStats.UsedBreakthroughCount - 1);
										}
									}
								}
							}
						}
					}
					_targetChar.CharacterUI.ShowInfoNotification(string.Format("Your mind has been freed from the weight of your desires and is ready for new discoveries...", num), __instance.ItemIcon);
					__instance.RemoveQuantity(1);
					return false;
				}
			}
			catch (Exception ex)
			{
				PotionResetSkills.Instance.MyLogger.LogError((object)("Item_OnUse: " + ex.Message));
			}
			return true;
		}
	}
}

OuthardRunes.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using SideLoader;
using SideLoader.SaveData;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("OutwardModTemplate")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OutwardModTemplate")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace HearthScrolls;

[BepInPlugin("iggy.hearthscrolls", "HearthScrolls", "1.0.1")]
public class HearthScrolls : BaseUnityPlugin
{
	[HarmonyPatch(typeof(ResourcesPrefabManager), "Load")]
	public class ResourcesPrefabManager_Load
	{
		private static void Postfix()
		{
		}
	}

	public const string GUID = "iggy.hearthscrolls";

	public const string NAME = "HearthScrolls";

	public const string VERSION = "1.0.1";

	internal static ManualLogSource Log;

	public static ConfigEntry<bool> ExampleConfig;

	public static HearthScrolls Instance { get; private set; }

	internal void Awake()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		Instance = this;
		RetreatCast.Init();
		new Harmony("iggy.hearthscrolls").PatchAll();
	}

	internal void Update()
	{
	}
}
public static class ItemIDs
{
	public static int RetreatScroll;

	public static string retreatTag;

	static ItemIDs()
	{
		RetreatScroll = 6600224;
		retreatTag = "RetreatTag";
	}
}
public class PlayerVisitSave : PlayerSaveExtension
{
	public float TotalGainedXP;

	public List<string> VisitedCities = new List<string>();

	public override void ApplyLoadedSave(Character character, bool isWorldHost)
	{
		RetreatCast.PlayerVisits = VisitedCities;
	}

	public override void Save(Character character, bool isWorldHost)
	{
		VisitedCities = RetreatCast.PlayerVisits;
	}
}
public static class RetreatCast
{
	[HarmonyPatch(typeof(Item), "Use", new Type[] { typeof(Character) })]
	public class Item_Usage
	{
		[HarmonyPrefix]
		public static void Postfix(Item __instance, Character _character)
		{
			if (!_character.IsLocalPlayer || __instance.ItemID != ItemIDs.RetreatScroll)
			{
				return;
			}
			if (KnowsCity())
			{
				if (_character.Inventory.BagWeightOver > 0f || _character.Inventory.PouchWeightOver > 0f)
				{
					_character.CharacterUI.ShowInfoNotification("Too heavy...");
				}
				else
				{
					((MonoBehaviour)HearthScrolls.Instance).StartCoroutine(checkRetreat(_character));
				}
			}
			else
			{
				_character.CharacterUI.ShowInfoNotification("Regional City Unknown.");
			}
		}
	}

	public static List<string> PlayerVisits = new List<string>();

	internal static void Init()
	{
		SL.OnGameplayResumedAfterLoading += CheckVisits;
	}

	private static void CheckVisits()
	{
		if (AreaManager.Instance.GetIsCurrentAreaTownOrCity() && !PlayerVisits.Contains(SceneManagerHelper.ActiveSceneName))
		{
			PlayerVisits.Add(SceneManagerHelper.ActiveSceneName);
		}
	}

	private static IEnumerator checkRetreat(Character player)
	{
		player.Animator.speed = 0.12f;
		float castTime = 0f;
		yield return (object)new WaitForSeconds(0.3f);
		for (; castTime < 3f; castTime += 1f * Time.deltaTime)
		{
			if ((int)player.CurrentSpellCast != 15)
			{
				break;
			}
			if (((Vector2)(ref player.CharacterControl.m_moveInput)).magnitude > 0.1f)
			{
				player.Knock(false);
				break;
			}
			yield return (object)new WaitForSeconds(0.05f);
		}
		player.Animator.speed = 1f;
		if (castTime >= 2f)
		{
			player.StatusEffectMngr.AddStatusEffect(ItemIDs.retreatTag);
			player.Inventory.RemoveItem(ItemIDs.RetreatScroll, 1);
			NetworkLevelLoader.Instance.RequestSwitchArea(AreaManager.Instance.GetArea(SendArea()).SceneName, 0, 1.5f, false);
		}
	}

	private static bool KnowsCity()
	{
		string activeSceneName = SceneManagerHelper.ActiveSceneName;
		if (activeSceneName.Contains("Cierzo") || activeSceneName.Contains("Chersonese"))
		{
			if (PlayerVisits.Contains("CierzoNewTerrain") || PlayerVisits.Contains("CierzoDestroyed"))
			{
				return true;
			}
		}
		else if (activeSceneName.Contains("Berg") || activeSceneName.Contains("Emercar"))
		{
			if (PlayerVisits.Contains("Berg"))
			{
				return true;
			}
		}
		else if (activeSceneName.Contains("Levant") || activeSceneName.Contains("Abrassar"))
		{
			if (PlayerVisits.Contains("Levant"))
			{
				return true;
			}
		}
		else if (activeSceneName.Contains("Monsoon") || activeSceneName.Contains("Hallowed"))
		{
			if (PlayerVisits.Contains("Monsoon"))
			{
				return true;
			}
		}
		else if (activeSceneName.Contains("Harmattan") || activeSceneName.Contains("Antique"))
		{
			if (PlayerVisits.Contains("Harmattan"))
			{
				return true;
			}
		}
		else if ((activeSceneName.Contains("Sirocco") || activeSceneName.Contains("Caldera")) && PlayerVisits.Contains("NewSirocco"))
		{
			return true;
		}
		return false;
	}

	private static AreaEnum SendArea()
	{
		string activeSceneName = SceneManagerHelper.ActiveSceneName;
		if (activeSceneName.Contains("Cierzo") || activeSceneName.Contains("Chersonese"))
		{
			if (!QuestEventManager.Instance.HasQuestEvent(QuestEventDictionary.GetQuestEvent("lDHL_XMS7kKEs0uOqrLQjw")))
			{
				return (AreaEnum)100;
			}
			return (AreaEnum)115;
		}
		if (!activeSceneName.Contains("Berg") && !activeSceneName.Contains("Emercar"))
		{
			if (!activeSceneName.Contains("Levant") && !activeSceneName.Contains("Abrassar"))
			{
				if (!activeSceneName.Contains("Monsoon") && !activeSceneName.Contains("Hallowed"))
				{
					if (!activeSceneName.Contains("Harmattan") && !activeSceneName.Contains("Antique"))
					{
						if (!activeSceneName.Contains("Sirocco") && !activeSceneName.Contains("Caldera"))
						{
							return (AreaEnum)101;
						}
						return (AreaEnum)601;
					}
					return (AreaEnum)400;
				}
				return (AreaEnum)200;
			}
			return (AreaEnum)300;
		}
		return (AreaEnum)500;
	}
}