Decompiled source of TrueHardcore v3.2.0

plugins/HardcoreRebalance.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
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 HarmonyLib;
using SideLoader;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("HardcoreRebalance")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HardcoreRebalance")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("42fa9a70-4056-4212-8387-b19532e9b8ae")]
[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 HardcoreRebalance;

internal static class CombatAnims
{
	[HarmonyPatch(typeof(CharacterInventory), "EquipItem", new Type[]
	{
		typeof(Equipment),
		typeof(bool)
	})]
	public class CharacterInventory_EquipItem
	{
		[HarmonyPrefix]
		public static bool Prefix(CharacterInventory __instance, Equipment _itemToEquip, bool _playAnim, ref Character ___m_character)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Invalid comparison between Unknown and I4
			Character val = ___m_character;
			if (Object.op_Implicit((Object)(object)val) && val.IsLocalPlayer)
			{
				if (allowEquip)
				{
					allowEquip = false;
					return true;
				}
				Equipment val2;
				if (_itemToEquip == null)
				{
					val2 = null;
					return false;
				}
				val2 = _itemToEquip;
				if (!val.InCombat && !HardcoreRebalanceBase.PickupAnimStored)
				{
					return true;
				}
				if (val2 != null && (int)val2.EquipSlot == 0)
				{
					val.SpellCastAnim((SpellCastType)1, (SpellCastModifier)0, 0);
					((MonoBehaviour)HardcoreRebalanceBase.Instance).StartCoroutine(DelayEquip(0.7f, __instance, _itemToEquip, _playAnim));
					return false;
				}
				if (val2 != null && (int)val2.EquipSlot == 1)
				{
					val.SpellCastAnim((SpellCastType)27, (SpellCastModifier)0, 0);
					((MonoBehaviour)HardcoreRebalanceBase.Instance).StartCoroutine(DelayEquip(2.5f, __instance, _itemToEquip, _playAnim));
					return false;
				}
				if (val2 != null && (int)val2.EquipSlot == 3)
				{
					val.SpellCastAnim((SpellCastType)3, (SpellCastModifier)0, 0);
					((MonoBehaviour)HardcoreRebalanceBase.Instance).StartCoroutine(DelayEquip(2f, __instance, _itemToEquip, _playAnim));
					return false;
				}
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(CharacterInventory), "TakeItem", new Type[]
	{
		typeof(Item),
		typeof(bool)
	})]
	public class CharacterInventory_TakeItem
	{
		[HarmonyPrefix]
		public static void Prefix(CharacterInventory __instance, Item takenItem, ref bool _tryToEquip, ref Character ___m_character)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Invalid comparison between Unknown and I4
			Character val = ___m_character;
			if (!Object.op_Implicit((Object)(object)val) || !val.IsLocalPlayer || !_tryToEquip)
			{
				return;
			}
			if (takenItem is Equipment)
			{
				Equipment val2 = (Equipment)(object)((takenItem is Equipment) ? takenItem : null);
				if ((val2 != null && (int)val2.EquipSlot == 0) || (val2 != null && (int)val2.EquipSlot == 1) || (val2 != null && (int)val2.EquipSlot == 3))
				{
					_tryToEquip = false;
				}
			}
			else
			{
				Equipment val2 = null;
			}
		}
	}

	[HarmonyPatch(typeof(InteractionTriggerBase), "TryActivateBasicAction", new Type[]
	{
		typeof(Character),
		typeof(int)
	})]
	public class InteractionTriggerBase_TryActivateBasicAction
	{
		[HarmonyPrefix]
		public static bool Prefix(InteractionTriggerBase __instance, Character _character, int _toggleState)
		{
			if (PhotonNetwork.isNonMasterClientInRoom || !Object.op_Implicit((Object)(object)_character))
			{
				return true;
			}
			EventActivator currentTriggerManager = __instance.CurrentTriggerManager;
			if (Object.op_Implicit((Object)(object)((currentTriggerManager is InteractionActivator) ? currentTriggerManager : null)))
			{
				EventActivator currentTriggerManager2 = __instance.CurrentTriggerManager;
				InteractionActivator val = (InteractionActivator)(object)((currentTriggerManager2 is InteractionActivator) ? currentTriggerManager2 : null);
				if (val.BasicInteraction != null)
				{
					IInteraction basicInteraction = val.BasicInteraction;
					if (basicInteraction is InteractionOpenContainer)
					{
						if (_character.InCombat)
						{
							_character.CharacterUI.ShowInfoNotification("It's dangerous to loot in combat...");
							_character.SendSheathe(false);
							_character.SpellCastAnim((SpellCastType)41, (SpellCastModifier)0, 0);
						}
						else if (HardcoreRebalanceBase.PickupAnimStored)
						{
							_character.SpellCastAnim((SpellCastType)7, (SpellCastModifier)0, 0);
						}
						return true;
					}
					if (basicInteraction is InteractionTake)
					{
						if (_character.InCombat)
						{
							_character.SendSheathe(false);
							_character.SpellCastAnim((SpellCastType)7, (SpellCastModifier)0, 0);
						}
						else if (HardcoreRebalanceBase.PickupAnimStored)
						{
							_character.SpellCastAnim((SpellCastType)5, (SpellCastModifier)0, 0);
						}
						return true;
					}
				}
			}
			return true;
		}
	}

	private static bool allowEquip;

	private static IEnumerator DelayEquip(float timeToEquip, CharacterInventory inventory, Equipment _itemToEquip, bool _playAnim)
	{
		inventory.m_character.StatusEffectMngr.AddStatusEffect(HardcoreEffects.CombatEquiping.ToString());
		if (inventory.m_character.InCombat)
		{
			inventory.m_character.CharacterUI.ShowInfoNotification("Dangerous to change gear in combat...");
		}
		if (!inventory.m_character.Sheathed)
		{
			inventory.m_character.SendSheathe(false);
		}
		yield return (object)new WaitForSeconds(timeToEquip);
		if (inventory.m_character.m_currentAnim.m_Name == VanillaAnimIDs.bandageAnim || inventory.m_character.m_currentAnim.m_Name == VanillaAnimIDs.setupGroundAnim || inventory.m_character.m_currentAnim.m_Name == VanillaAnimIDs.fastAnim)
		{
			allowEquip = true;
			inventory.EquipItem(_itemToEquip, false);
		}
	}
}
internal class ContentTweks
{
	[HarmonyPatch(typeof(InteractionTriggerBase), "TryActivateBasicAction", new Type[]
	{
		typeof(Character),
		typeof(int)
	})]
	public class InteractionTriggerBase_TryActivateBasicAction
	{
		[HarmonyPrefix]
		public static bool Prefix(InteractionTriggerBase __instance, Character _character, int _toggleState)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_character) || !_character.IsLocalPlayer)
			{
				return true;
			}
			EventActivator currentTriggerManager = __instance.CurrentTriggerManager;
			if (Object.op_Implicit((Object)(object)((currentTriggerManager is InteractionActivator) ? currentTriggerManager : null)))
			{
				EventActivator currentTriggerManager2 = __instance.CurrentTriggerManager;
				InteractionActivator val = (InteractionActivator)(object)((currentTriggerManager2 is InteractionActivator) ? currentTriggerManager2 : null);
				if (val.BasicInteraction != null && val.BasicInteraction is InteractionToggleContraption && Vector3.Distance(_character.CenterPosition, CabalLeverPos) < leverDist)
				{
					_character.CharacterUI.ShowInfoNotification("The lever is stuck...");
					return false;
				}
			}
			return true;
		}
	}

	private static Vector3 CabalLeverPos = new Vector3(-1.6f, 12.5f, 44f);

	private static float leverDist = 2f;
}
public static class CraftingLimits
{
	[HarmonyPatch(typeof(CraftingMenu), "TryCraft")]
	public class CraftingMenu_TryCraft
	{
		[HarmonyPrefix]
		public static bool Prefix(CraftingMenu __instance)
		{
			if ((Object)(object)((__instance != null) ? ((UIElement)__instance).LocalCharacter : null) != (Object)null && ((UIElement)__instance).LocalCharacter.IsLocalPlayer)
			{
				bool flag = false;
				if (Object.op_Implicit((Object)(object)((ItemDisplay)__instance.m_recipeResultDisplay).RefItem) || !HardcoreRebalanceBase.CraftLimitsStored)
				{
					return true;
				}
				if (__instance.m_ingredientSelectors.Length <= 1)
				{
					flag = true;
				}
				else
				{
					int num = 0;
					for (int i = 0; i < __instance.m_ingredientSelectors.Length; i++)
					{
						IngredientSelector obj = __instance.m_ingredientSelectors[i];
						if (obj == null)
						{
							continue;
						}
						CompatibleIngredient assignedIngredient = obj.AssignedIngredient;
						if (assignedIngredient == null)
						{
							continue;
						}
						_ = assignedIngredient.ItemID;
						if (true)
						{
							num++;
							if (ExceptionIDs.CraftExceptions.Values.Contains(__instance.m_ingredientSelectors[i].AssignedIngredient.ItemID) || __instance.m_ingredientSelectors[i].AssignedIngredient.ItemPrefab.Name.Contains("Lantern") || __instance.m_ingredientSelectors[i].AssignedIngredient.ItemPrefab.Name.Contains("Tsar"))
							{
								flag = true;
								break;
							}
						}
					}
					if (num == 1)
					{
						flag = true;
					}
				}
				if (flag)
				{
					return true;
				}
				int num2 = ((__instance.m_lastRecipeIndex != -1) ? __instance.m_complexeRecipes[__instance.m_lastRecipeIndex].Key : __instance.m_lastFreeRecipeIndex);
				if (num2 != -1)
				{
					int num3 = 0;
					while (true)
					{
						int num4 = num3;
						Recipe obj2 = __instance.m_allRecipes[num2];
						if (!(num4 < ((obj2 == null) ? null : obj2.Results?.Length)))
						{
							break;
						}
						ItemReferenceQuantity obj3 = __instance.m_allRecipes[num2].Results[num3];
						if (obj3 != null && obj3.ItemID < -1)
						{
							Debug.Log((object)("itemID: " + __instance.m_allRecipes[num2].Results[num3].ItemID));
							((UIElement)__instance).LocalCharacter.CharacterUI.ShowInfoNotification("Mod craft allowed.");
							return true;
						}
						num3++;
					}
				}
				((UIElement)__instance).LocalCharacter.CharacterUI.ShowInfoNotification("No recipe known...");
				return false;
			}
			return true;
		}
	}

	internal static void Awake()
	{
		SL.OnGameplayResumedAfterLoading += StartingRecipe;
	}

	private static void StartingRecipe()
	{
		foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
		{
			if (!item.IsLocalPlayer)
			{
				continue;
			}
			foreach (string value2 in ExceptionIDs.StartingRecipees.Values)
			{
				if (!item.ControlledCharacter.Inventory.RecipeKnowledge.IsRecipeLearned(value2))
				{
					RecipeManager.Instance.m_recipes.TryGetValue(value2, out var value);
					item.ControlledCharacter.Inventory.RecipeKnowledge.LearnRecipe(value);
				}
			}
		}
		SL.OnGameplayResumedAfterLoading -= StartingRecipe;
	}
}
internal static class DeathMortality
{
	[HarmonyPatch(typeof(DefeatScenariosManager), "OnAllPlayersDefeated")]
	public class DefeatScenariosManager_OnAllPlayersDefeated
	{
		[HarmonyPrefix]
		public static void Prefix(DefeatScenariosManager __instance)
		{
			if (!CharacterManager.Instance.GetFirstLocalCharacter().IsWorldHost)
			{
				return;
			}
			foreach (Character value in CharacterManager.Instance.Characters.Values)
			{
				if (value.IsAI && value.Stats.CurrentHealth > 0f)
				{
					value.Stats.AffectHealth(value.Stats.MaxHealth * HardcoreBalance.deathEnemyHealMult);
				}
			}
			Item itemPrefab = ResourcesPrefabManager.Instance.GetItemPrefab(-2057);
			foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
			{
				Character controlledCharacter = item.ControlledCharacter;
				int num = 0;
				int num2 = Random.Range(1, 11);
				num = (controlledCharacter.HardcoreMode ? ((num2 <= 4) ? 1 : ((num2 <= 9) ? 2 : 3)) : ((num2 <= 7) ? 1 : ((num2 <= 9) ? 2 : 3)));
				controlledCharacter.Inventory.GenerateItem(itemPrefab, num, false);
				foreach (Item ownedItem in controlledCharacter.Inventory.GetOwnedItems(-2057))
				{
					controlledCharacter.Inventory.TakeItemToPouch(ownedItem);
				}
				((MonoBehaviour)HardcoreRebalanceBase.Instance).StartCoroutine(MoveToPouch(controlledCharacter));
				int num3 = Random.Range(500, 2500);
				controlledCharacter.Inventory.OnCharacterReceivedHit((float)num3, false);
			}
		}
	}

	[HarmonyPatch(typeof(DefeatScenariosManager), "DefeatHardcoreDeath")]
	public class DefeatScenariosManager_DefeatHardcoreDeath
	{
		[HarmonyPrefix]
		public static bool Prefix(DefeatScenariosManager __instance)
		{
			if (CharacterManager.Instance.GetFirstLocalCharacter().HardcoreMode)
			{
				bool flag = true;
				foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
				{
					if (flag)
					{
						Character controlledCharacter = item.ControlledCharacter;
						if (controlledCharacter != null && controlledCharacter.StatusEffectMngr.GetStatusLevel(HardcoreEffects.Mortality.ToString()) >= 5)
						{
							flag = false;
						}
					}
				}
				Debug.Log((object)"STOP DEATH CHECK ---------------------");
				if (flag)
				{
					Debug.Log((object)"STOPING PERMADEATH-----------------------------------------");
					GetNewScenario(__instance);
					return false;
				}
				return true;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(CharacterUI), "ShowMenu", new Type[] { typeof(MenuScreens) })]
	public class CharacterUI_ShowMenu
	{
		[HarmonyPrefix]
		public static void Prefix(CharacterUI __instance, MenuScreens _menu)
		{
			Character targetCharacter = __instance.TargetCharacter;
			if (!((Object)(object)targetCharacter == (Object)null) && targetCharacter.IsLocalPlayer)
			{
				CheckMortality();
			}
		}
	}

	private static bool reviver;

	public static List<Character> allPlayers;

	private static int onlinePlayersNo;

	internal static void Awake()
	{
		SL.OnGameplayResumedAfterLoading += Fixer;
	}

	private static void Fixer()
	{
		Debug.Log((object)"CHECKING MORTALITY----");
		CheckMortality();
	}

	private static void CheckMortality()
	{
		foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
		{
			Character controlledCharacter = item.ControlledCharacter;
			if (!controlledCharacter.IsLocalPlayer || !controlledCharacter.Inventory.OwnsItem(-2057))
			{
				continue;
			}
			int num = controlledCharacter.Inventory.ItemCount(-2057);
			for (int i = 0; i < num; i++)
			{
				controlledCharacter.StatusEffectMngr.AddStatusEffect(HardcoreEffects.Mortality.ToString());
			}
			controlledCharacter.Inventory.RemoveItem(-2057, num);
			bool flag = false;
			foreach (Blessings value in Enum.GetValues(typeof(Blessings)))
			{
				if (((CharacterKnowledge)controlledCharacter.Inventory.SkillKnowledge).IsItemLearned((int)value))
				{
					Item itemFromItemID = ((CharacterKnowledge)controlledCharacter.Inventory.SkillKnowledge).GetItemFromItemID((int)value);
					ItemManager.Instance.DestroyItem(itemFromItemID);
					((CharacterKnowledge)controlledCharacter.Inventory.SkillKnowledge).RemoveItem(itemFromItemID);
					flag = true;
				}
			}
			if (flag)
			{
				controlledCharacter.CharacterUI.ShowInfoNotification("Blessings lost");
			}
		}
	}

	private static IEnumerator MoveToPouch(Character xplayer)
	{
		yield return (object)new WaitForSeconds(0.1f);
		foreach (Item ownedItem in xplayer.Inventory.GetOwnedItems(-2057))
		{
			xplayer.Inventory.TakeItemToPouch(ownedItem);
		}
	}

	public static void GetNewScenario(DefeatScenariosManager defeatManager)
	{
		DefeatScenario val = defeatManager.m_scerariosContainer.ChooseScenario();
		defeatManager.ForceDefeat(val);
	}
}
public static class ExceptionIDs
{
	private const string CRYSTAL_POWDER_RECIPE_UID = "-SEtMHRqWUmvrmyvryV8Ng";

	public static readonly Dictionary<string, string> StartingRecipees = new Dictionary<string, string>
	{
		["Crystal Powder"] = "-SEtMHRqWUmvrmyvryV8Ng",
		["Trinket of Elatt"] = "com.iggy.trinketrecipe"
	};

	public static readonly Dictionary<string, int> CraftExceptions = new Dictionary<string, int>
	{
		["Explorer Lantern"] = 5100000,
		["Old Lantern"] = 5100010,
		["Glowstone Lantern"] = 5100020,
		["Firefly Lantern"] = 5100030,
		["Lantern of Souls"] = 5100080,
		["Coil Lantern"] = 5100090,
		["Virgin Lantern"] = 5100100,
		["Djinn’s Lamp"] = 5100110,
		["Calixa’s Relic"] = 6600225,
		["Elatt’s Relic"] = 6600222,
		["Gep’s Generosity"] = 6600220,
		["Haunted Memory"] = 6600224,
		["Leyline Figment"] = 6600226,
		["Pearlbird’s Courage"] = 6600221,
		["Scourge’s Tears"] = 6600223,
		["Vendavel's Hospitality"] = 6600227,
		["Flowering Corruption"] = 6600228,
		["Metalized Bones"] = 6600230,
		["Enchanted Mask"] = 6600229,
		["Noble’s Greed"] = 6600232,
		["Scarlet Whisper"] = 6600231,
		["Calygrey’s Wisdom"] = 6600233,
		["Hailfrost Claymore"] = 2100270,
		["Hailfrost Mace"] = 2020290,
		["Hailfrost Hammer"] = 2120240,
		["Hailfrost Axe"] = 2010250,
		["Hailfrost Greataxe"] = 2110230,
		["Hailfrost Spear"] = 2130280,
		["Hailfrost Halberd"] = 2150110,
		["Hailfrost Pistol"] = 5110270,
		["Hailfrost Knuckles"] = 2160200,
		["Hailfrost Sword"] = 2000280,
		["Hailfrost Dagger"] = 5110015,
		["Mysterious Blade"] = 2000320,
		["Mysterious Long Blade"] = 2100300,
		["Ceremonial Bow"] = 2200190,
		["Cracked Red Moon"] = 2150180,
		["Compasswood Staff"] = 2150030,
		["Scarred Dagger"] = 5110340,
		["De-powered Bludgeon"] = 2120270,
		["Unusual Knuckles"] = 2160230,
		["Strange Rusted Sword"] = 2000151
	};
}
public static class NightGates
{
	[HarmonyPatch(typeof(CharacterManager), "RequestAreaSwitch")]
	public class CharacterManager_RequestAreaSwitch
	{
		[HarmonyPrefix]
		public static bool Prefix(CharacterManager __instance, Character _character, Area _areaToSwitchTo, int _longTravelTime, int _spawnPoint, float _offset, string _overrideLocKey)
		{
			if (!HardcoreRebalanceBase.NightGatesStored)
			{
				return true;
			}
			Debug.Log((object)("Time is: " + EnvironmentConditions.Instance.TimeOfDay));
			if (EnvironmentConditions.Instance.TimeOfDay > 20f || EnvironmentConditions.Instance.TimeOfDay < 4f)
			{
				bool flag = false;
				if ((_areaToSwitchTo.SceneName == "CierzoNewTerrain" && SceneManagerHelper.ActiveSceneName == "ChersoneseNewTerrain") || (_areaToSwitchTo.SceneName == "Berg" && SceneManagerHelper.ActiveSceneName == "Emercar"))
				{
					flag = GetBribeStage(_character, 100);
				}
				else if (_areaToSwitchTo.SceneName == "Levant" && SceneManagerHelper.ActiveSceneName == "Abrassar")
				{
					flag = GetBribeStage(_character, 200);
				}
				else if (_areaToSwitchTo.SceneName == "Harmattan" && SceneManagerHelper.ActiveSceneName == "AntiqueField")
				{
					flag = GetBribeStage(_character, 140);
				}
				else
				{
					if (!(_areaToSwitchTo.SceneName == "Monsoon") || !(SceneManagerHelper.ActiveSceneName == "HallowedMarshNewTerrain"))
					{
						return true;
					}
					flag = GetBribeStage(_character, 80, isBoat: true);
				}
				if (flag)
				{
					return true;
				}
				return false;
			}
			return true;
		}
	}

	private static int BribeAttempt;

	private static Coroutine bribeCO;

	private static bool GetBribeStage(Character _character, int bribeCost, bool isBoat = false)
	{
		if (BribeAttempt == 0)
		{
			if (isBoat)
			{
				_character.CharacterUI.ShowInfoNotification("No sailing at night...unless...");
			}
			else
			{
				_character.CharacterUI.ShowInfoNotification("Gates are closed at night...unless...");
			}
		}
		else if (BribeAttempt == 1)
		{
			if (isBoat)
			{
				_character.CharacterUI.ShowInfoNotification("Convince boatman for " + bribeCost + " silver?");
			}
			else
			{
				_character.CharacterUI.ShowInfoNotification("Bribe guard for " + bribeCost + " silver?");
			}
		}
		else if (BribeAttempt == 2)
		{
			if (isBoat)
			{
				_character.CharacterUI.ShowInfoNotification("Wanna pay? Convince boatman for " + bribeCost + " silver?");
			}
			else
			{
				_character.CharacterUI.ShowInfoNotification("Wanna pay? Bribe guard for " + bribeCost + " silver?");
			}
		}
		if (bribeCO != null)
		{
			((MonoBehaviour)HardcoreRebalanceBase.Instance).StopCoroutine(bribeCO);
			bribeCO = null;
		}
		bribeCO = ((MonoBehaviour)HardcoreRebalanceBase.Instance).StartCoroutine(resetBribe());
		if (BribeAttempt == 3)
		{
			BribeAttempt = 0;
			if (_character.Inventory.AvailableMoney > bribeCost)
			{
				_character.Inventory.RemoveMoney(bribeCost, false);
				return true;
			}
			_character.CharacterUI.ShowInfoNotification("Not enough silver...");
			_character.Knock(true);
			return false;
		}
		if (BribeAttempt < 3)
		{
			BribeAttempt++;
		}
		return false;
	}

	private static IEnumerator resetBribe()
	{
		yield return (object)new WaitForSeconds(5f);
		BribeAttempt = 0;
	}
}
internal class Tester
{
}
public enum HardcoreItems
{
	ElattCleanse = -2051,
	ElattTrinket = -2052,
	ElattPiece = -2053,
	MortalAdd = -2057
}
public enum Blessings
{
	BlessingWisdom = -2054,
	BlessingPower = -2055,
	BlessingCourage = -2056
}
public enum HardcoreEffects
{
	EnemyHealing,
	Mortality,
	CombatEquiping,
	TrapAware
}
public static class VanillaAnimIDs
{
	public static int bandageAnim = 1097271049;

	public static int setupGroundAnim = 429652511;

	public static int pickupAnim = 916061048;

	public static int fastAnim = -226441022;
}
public static class HardcoreBalance
{
	public static int trinketDropChance = 1;

	public static float deathEnemyHealMult = 0.6f;

	public static int flintBreakChance = 30;

	public static float reviveTimer = 4f;

	public static float timeToEquip = 2f;
}
public static class EventsManager
{
	[HarmonyPatch(typeof(NetworkLevelLoader), "UnPauseGameplay")]
	public class NetworkLevelLoader_UnPauseGameplay
	{
		[HarmonyPostfix]
		public static void Postfix(NetworkLevelLoader __instance, string _identifier)
		{
			if (HardcoreRebalanceBase.PerCityStashStored)
			{
				_cachedStash = null;
			}
		}
	}

	[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPatch(typeof(ItemContainer), "ShowContent")]
	public class ItemContainer_ShowContent
	{
		[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
		public static void Reversefix(ItemContainer __instance, Character _character)
		{
		}
	}

	[HarmonyPatch(typeof(TreasureChest), "ShowContent")]
	public class TreasureChest_ShowContent
	{
		[HarmonyPrefix]
		public static bool Prefix(TreasureChest __instance, Character _character)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			if (!HardcoreRebalanceBase.PerCityStashStored)
			{
				return true;
			}
			if ((int)((ItemContainer)__instance).SpecialType == 4 && TryGetStash(_character, out var stash))
			{
				_character.CharacterUI.StashPanel.SetStash(stash);
			}
			ItemContainer_ShowContent.Reversefix((ItemContainer)(object)__instance, _character);
			return false;
		}
	}

	[HarmonyPatch(typeof(TreasureChest), "InitDrops")]
	public class TreasureChest_InitDrops
	{
		[HarmonyPostfix]
		public static void Postfix(TreasureChest __instance)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if (HardcoreRebalanceBase.PerCityStashStored)
			{
				_ = ((ItemContainer)__instance).SpecialType;
				_ = 4;
			}
		}
	}

	[HarmonyPatch(typeof(CharacterKnowledge), "AddItem")]
	public class CharacterKnowledge_AddItem
	{
		[HarmonyPostfix]
		public static void Postfix(CharacterKnowledge __instance, Item _item, ref Character ___m_character)
		{
			Character val = ___m_character;
			if ((Object)(object)val != (Object)null && val.IsLocalPlayer && _item.ItemID == -2051)
			{
				int num = 4;
				if (val.HardcoreMode)
				{
					num = 2;
				}
				val.StatusEffectMngr.ReduceStatusLevel(HardcoreEffects.Mortality.ToString(), num);
				ItemManager.Instance.DestroyItem(_item.UID);
				((CharacterKnowledge)val.Inventory.SkillKnowledge).RemoveItem(_item);
			}
		}
	}

	[HarmonyPatch(typeof(Item), "Use", new Type[] { typeof(Character) })]
	public class Item_Usage
	{
		[HarmonyPrefix]
		public static bool Prefix(Item __instance, Character _character)
		{
			if (!_character.IsLocalPlayer)
			{
				return true;
			}
			if (__instance.ItemID == -2052)
			{
				int num = 10;
				_character.StatusEffectMngr.ReduceStatusLevel(HardcoreEffects.Mortality.ToString(), num);
				_character.Inventory.RemoveItem(-2052, 1);
				_character.SpellCastAnim((SpellCastType)25, (SpellCastModifier)0, 0);
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(BasicDeployable), "TryDeploying", new Type[] { typeof(Character) })]
	public class BasicDeployable_TryDeploying
	{
		[HarmonyPrefix]
		public static bool Prefix(BasicDeployable __instance, Character _usingCharacter)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_usingCharacter == (Object)null || !_usingCharacter.IsLocalPlayer)
			{
				return true;
			}
			if (AreaManager.Instance.GetIsCurrentAreaTownOrCity() && ((ItemExtension)__instance).Item.IsSleepKit)
			{
				float num = Vector3.Distance(levantSlums, ((Component)_usingCharacter).transform.position);
				if (SceneManagerHelper.ActiveSceneName == "Levant" && num < 30f)
				{
					return true;
				}
				_usingCharacter.CharacterUI.ShowInfoNotification("Vagrancy is not allowed");
				return false;
			}
			return true;
		}
	}

	private enum CampingActivities
	{
		None = 0,
		Sleep = 2,
		Guard = 4,
		Repair = 8
	}

	[HarmonyPatch(typeof(RestingMenu), "Show")]
	public class RestingMenu_Show
	{
		[HarmonyPrefix]
		public static void Prefix(RestingMenu __instance)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			if (!HardcoreRebalanceBase.CampingGuardStored)
			{
				return;
			}
			Debug.Log((object)"Showing Menu----");
			foreach (Transform item in ((Component)__instance.m_restingActivitiesHolder).transform)
			{
				Transform val = item;
				CampingActivities[] array = new CampingActivities[3]
				{
					CampingActivities.Sleep,
					CampingActivities.Guard,
					CampingActivities.Repair
				};
				for (int i = 0; i < array.Length; i++)
				{
					_ = array[i];
					if (((Object)((Component)val).gameObject).name.Contains(CampingActivities.Guard.ToString()))
					{
						((Component)val).gameObject.SetActive(false);
					}
				}
			}
			Debug.Log((object)"Disabling Guard----");
		}
	}

	[HarmonyPatch(typeof(Item), "OnUse")]
	public class Item_OnUse
	{
		[HarmonyPostfix]
		public static void Postfix(Item __instance, Character _targetChar)
		{
			if (__instance.ItemID == 5600010 && ((EffectSynchronizer)__instance).OwnerCharacter.IsLocalPlayer && Random.Range(1, 101) <= HardcoreBalance.flintBreakChance)
			{
				__instance.RemoveQuantity(1);
				__instance.m_ownerCharacter.CharacterUI.ShowInfoNotification("Flint and Steel broke on use.");
			}
		}
	}

	[HarmonyPatch(typeof(Character), "UpdateReviveInteraction")]
	public class Character_UpdateReviveInteraction
	{
		[HarmonyPostfix]
		public static void Prefix(Character __instance)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				Transform val = ((Component)__instance).transform.Find("ReviveInteraction");
				if ((Object)(object)val != (Object)null)
				{
					((InteractionBase)((Component)val).GetComponent<InteractionRevive>()).HoldActivationTime = HardcoreBalance.reviveTimer;
				}
			}
		}
	}

	[HarmonyPatch(typeof(DefeatCoinLost), "Activate")]
	public class DefeatCoinLost_Activate
	{
		[HarmonyPrefix]
		public static void Prefix(DefeatCoinLost __instance, Character _affectedCharacter, ref int ___m_minLostCoins, ref int ___m_maxLostCoins, ref int ___m_minPercentLost, ref int ___m_maxPerentLost)
		{
			if ((Object)(object)_affectedCharacter != (Object)null && _affectedCharacter.IsLocalPlayer)
			{
				Debug.Log((object)"lossing COINS");
				___m_minLostCoins = 50;
				___m_maxLostCoins = 500;
				___m_minPercentLost = 30;
				___m_maxPerentLost = 90;
			}
		}
	}

	[HarmonyPatch(typeof(DefeatDamageEquipment), "Activate")]
	public class DefeatDamageEquipment_Activate
	{
		[HarmonyPrefix]
		public static void Prefix(DefeatDamageEquipment __instance, Character _affectedCharacter, ref int ___m_minDamage, ref int ___m_maxDamage)
		{
			if ((Object)(object)_affectedCharacter != (Object)null && _affectedCharacter.IsLocalPlayer)
			{
				Debug.Log((object)"breaking ARMOR");
				___m_minDamage = 100;
				___m_maxDamage = 800;
			}
		}
	}

	[HarmonyPatch(typeof(CharacterEquipment), "RepairEquipment")]
	public class CharacterEquipmen_RepairEquipment
	{
		[HarmonyPrefix]
		public static void Prefix(CharacterEquipment __instance, bool _forceRepair, ref EquipmentSlot[] ___m_equipmentSlots)
		{
			if (__instance.m_character.IsLocalPlayer && ___m_equipmentSlots != null)
			{
				EquipmentSlot[] array = ___m_equipmentSlots;
				foreach (EquipmentSlot val in array)
				{
					if ((Object)(object)val != (Object)null && (Object)(object)val.EquippedItem != (Object)null && val.HasItemEquipped)
					{
						Debug.Log((object)("SHOULD REPAIR: " + val.SlotName));
						((Item)val.EquippedItem).RepairedInRest = true;
					}
				}
			}
			else
			{
				Debug.Log((object)"HARD ERROR ---------------");
			}
		}
	}

	[HarmonyPatch(typeof(CharacterEquipment), "RepairEquipmentAfterRest")]
	public class CharacterEquipmen_RepairEquipmentAfterRest
	{
		[HarmonyPrefix]
		public static void Prefix(CharacterEquipment __instance, ref EquipmentSlot[] ___m_equipmentSlots)
		{
			if (__instance.m_character.IsLocalPlayer && ___m_equipmentSlots != null)
			{
				EquipmentSlot[] array = ___m_equipmentSlots;
				foreach (EquipmentSlot val in array)
				{
					if ((Object)(object)val != (Object)null && (Object)(object)val.EquippedItem != (Object)null && val.HasItemEquipped && ((Item)val.EquippedItem).CurrentDurability <= 0f)
					{
						((Item)val.EquippedItem).RepairedInRest = false;
						Debug.Log((object)("BROKEN ITEM: " + val.SlotName));
					}
				}
			}
			else
			{
				Debug.Log((object)"HARD ERROR ---------------");
			}
		}
	}

	[HarmonyPatch(typeof(ItemDropper), "GenerateItem")]
	public class ItemDropper_GenerateItem
	{
		[HarmonyPrefix]
		public static void Prefix(ItemDropper __instance, ItemContainer _container, BasicItemDrop _itemDrop, int _spawnAmount)
		{
			if ((Object)(object)player != (Object)null && player.IsWorldHost && Random.Range(1, 200) <= HardcoreBalance.trinketDropChance)
			{
				ItemManager.Instance.GenerateItemNetwork(-2053).ChangeParent(((Component)_container).transform);
			}
		}
	}

	public static AreaManager areaManager;

	public static Character player;

	private static bool reviver = false;

	public static List<Character> allPlayers;

	private static int onlinePlayersNo;

	private static List<Character> oversleptPlayers;

	private static List<Character> wellPlayers;

	private static Vector3 levantSlums = new Vector3(-160f, 4.4f, 66f);

	private static int minAmbush = 20;

	private static bool startStash;

	private static readonly Dictionary<AreaEnum, (string UID, Vector3[] Positions)> CityStashData = new Dictionary<AreaEnum, (string, Vector3[])>
	{
		[(AreaEnum)100] = ("ImqRiGAT80aE2WtUHfdcMw", (Vector3[])(object)new Vector3[2]
		{
			new Vector3(-367.85f, -1488.25f, 596.277f),
			new Vector3(-373.539f, -1488.25f, 583.187f)
		}),
		[(AreaEnum)500] = ("ImqRiGAT80aE2WtUHfdcMw", (Vector3[])(object)new Vector3[2]
		{
			new Vector3(-386.62f, -1493.132f, 773.86f),
			new Vector3(-372.41f, -1493.132f, 773.86f)
		}),
		[(AreaEnum)200] = ("ImqRiGAT80aE2WtUHfdcMw", (Vector3[])(object)new Vector3[1]
		{
			new Vector3(-371.628f, -1493.41f, 569.91f)
		}),
		[(AreaEnum)300] = ("ZbPXNsPvlUeQVJRks3zBzg", (Vector3[])(object)new Vector3[2]
		{
			new Vector3(-369.28f, -1502.535f, 592.85f),
			new Vector3(-380.53f, -1502.535f, 593.08f)
		}),
		[(AreaEnum)400] = ("ImqRiGAT80aE2WtUHfdcMw", (Vector3[])(object)new Vector3[4]
		{
			new Vector3(-178.672f, -1515.915f, 597.934f),
			new Vector3(-182.373f, -1515.915f, 606.291f),
			new Vector3(-383.484f, -1504.82f, 583.343f),
			new Vector3(-392.681f, -1504.82f, 586.551f)
		}),
		[(AreaEnum)601] = ("IqUugGqBBkaOcQdRmhnMng", (Vector3[])(object)new Vector3[0])
	};

	private static ItemContainer _cachedStash;

	internal static void Awake()
	{
		SL.OnGameplayResumedAfterLoading += startItemsKill;
		allPlayers = new List<Character>();
		oversleptPlayers = new List<Character>();
		wellPlayers = new List<Character>();
	}

	private static void startItemsKill()
	{
		SL.OnGameplayResumedAfterLoading -= startItemsKill;
		if (!PhotonNetwork.isNonMasterClientInRoom && !startStash)
		{
			startStash = true;
			QuestEventManager.Instance.AddEvent(QuestEventDictionary.GetQuestEvent("dlMPJtXDWU6R1YEfsezlSA"), 1);
			QuestEventManager.Instance.AddEvent(QuestEventDictionary.GetQuestEvent("ypT9_eYB6UK2gnAaqJVA3g"), 1);
			QuestEventManager.Instance.AddEvent(QuestEventDictionary.GetQuestEvent("EEdVb-dL10qjF70lw0UZKw"), 1);
			QuestEventManager.Instance.AddEvent(QuestEventDictionary.GetQuestEvent("1iyLYN6eXUCQY9ZjD0kd1w"), 1);
			QuestEventManager.Instance.AddEvent(QuestEventDictionary.GetQuestEvent("Q-U-VKV68Uezx3jM4ZB8Jg"), 1);
			QuestEventManager.Instance.AddEvent(QuestEventDictionary.GetQuestEvent("_P9lL0G5RUOfVC4ydwa1kQ"), 1);
		}
	}

	public static bool TryGetStash(Character character, out ItemContainer stash)
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Expected O, but got Unknown
		if ((Object)(object)_cachedStash == (Object)null && AreaManager.Instance.CurrentArea != null && CityStashData.TryGetValue((AreaEnum)AreaManager.Instance.CurrentArea.ID, out (string, Vector3[]) value))
		{
			_cachedStash = (ItemContainer)(TreasureChest)ItemManager.Instance.GetItem(value.Item1);
		}
		stash = _cachedStash;
		return (Object)(object)stash != (Object)null;
	}
}
public static class AIManager
{
	[HarmonyPatch(typeof(Character), "UpdateStability")]
	public class Character_UpdateStability
	{
		[HarmonyPrefix]
		public static bool Prefix(Character __instance)
		{
			if (!__instance.IsLocalPlayer)
			{
				return true;
			}
			if (__instance.Blocking)
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Character), "OnReceiveHit")]
	public class Character_OnReceiveHit
	{
		[HarmonyPrefix]
		public static void Prefix(Character __instance, Weapon _weapon, float _damage, DamageList _damageList, Vector3 _hitDir, Vector3 _hitPoint, float _angle, float _angleDir, Character _dealerChar, float _knockBack)
		{
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			if (!HardcoreRebalanceBase.EnemyHealingStored || !player.IsWorldHost || (Object)(object)_dealerChar == (Object)null)
			{
				return;
			}
			if (!__instance.IsAI && _dealerChar.IsAI && _knockBack > 1f)
			{
				_dealerChar.StatusEffectMngr.AddStatusEffect(HardcoreEffects.EnemyHealing.ToString());
			}
			else if (__instance.IsAI && !_dealerChar.IsAI && _knockBack > 1f)
			{
				if (__instance.StatusEffectMngr.HasStatusEffect(HardcoreEffects.EnemyHealing.ToString()))
				{
					__instance.StatusEffectMngr.RemoveStatusWithIdentifierName(HardcoreEffects.EnemyHealing.ToString());
				}
			}
			else
			{
				if (!__instance.IsAI || !_dealerChar.IsAI)
				{
					return;
				}
				foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
				{
					Character controlledCharacter = item.ControlledCharacter;
					if (Vector3.Distance(((Component)__instance).transform.position, ((Component)controlledCharacter).transform.position) < botDmgRange)
					{
						_damage *= botDmgMult;
						return;
					}
				}
				_damage = 0f;
			}
		}
	}

	[HarmonyPatch(typeof(Character), "StabilityHit")]
	public class Character_StabilityHit
	{
		[HarmonyPrefix]
		public static void Prefix(Character __instance, ref float _knockValue, float _angle, bool _block, Character _dealerChar)
		{
			if (Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)_dealerChar) && __instance.Blocking)
			{
				if (__instance.IsLocalPlayer)
				{
					_knockValue *= 1.4f;
				}
				else if (__instance.IsAI)
				{
					_knockValue *= 1.2f;
				}
			}
		}
	}

	[HarmonyPatch(typeof(Character), "StabilityHit")]
	public class Character_StabilityHitPost
	{
		[HarmonyPostfix]
		public static void Postfix(Character __instance, ref float _knockValue, float _angle, bool _block, Character _dealerChar)
		{
			if (Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)_dealerChar) && __instance.Blocking)
			{
				if (__instance.IsAI)
				{
					_dealerChar.StabilityHit(_knockValue / 2f, _angle * -1f, false, (Character)null);
				}
				if (__instance.IsLocalPlayer)
				{
					_dealerChar.StabilityHit(_knockValue / 3f, _angle * -1f, false, (Character)null);
				}
			}
		}
	}

	[HarmonyPatch(typeof(CharacterStats), "UseMana")]
	public class Character_UseMana
	{
		[HarmonyPostfix]
		public static void Postfix(CharacterStats __instance, Tag[] _tags, ref float _amount, ref Character ___m_character)
		{
			if (___m_character.IsLocalPlayer)
			{
				drainStability(___m_character, _amount, isMana: true);
			}
		}
	}

	[HarmonyPatch(typeof(AIPreset), "ApplyToCharAI")]
	private class AIFix
	{
		[HarmonyPostfix]
		public static void Postfix(CharacterAI _charAI)
		{
			if ((Object)(object)player != (Object)null && HardcoreRebalanceBase.EnhancedAIStored)
			{
				Debug.Log((object)"APPLYING Enhanced AI--------------");
				AICEnemyDetection[] componentsInChildren = ((Component)_charAI).GetComponentsInChildren<AICEnemyDetection>(true);
				foreach (AICEnemyDetection obj in componentsInChildren)
				{
					obj.GoodViewAngle = goodViewAngle;
					obj.ViewAngle = viewAngle;
					obj.LowViewRange = lowViewRange;
					obj.ViewRange = viewRange;
					obj.ViewVisDetect = viewVisDetect;
					obj.HearingDetect = hearingDetect;
					obj.HearingDetectRange = hearingDetectRange;
					obj.HearingCanDetect = true;
					obj.SuspiciousMult = suspiciousMult;
					obj.SuspiciousDelay = suspiciousDelay;
				}
			}
		}
	}

	private static Character player;

	private static Character[] players;

	private static List<Character> allPlayers;

	private static float goodViewAngle = 40f;

	private static float viewAngle = 160f;

	private static float viewRange = 80f;

	private static float viewVisDetect = 80f;

	private static float lowViewRange = 35f;

	private static float suspiciousMult = 20f;

	private static float suspiciousDelay = 10f;

	private static float hearingDetect = 30f;

	private static float hearingDetectRange = 40f;

	private static float chanceToSwitchTargetOnHurt = 80f;

	private static int playersNo = 0;

	private static int counterNum = 0;

	private static List<UID> enemyHOTs;

	private static List<int> enemyTimers;

	private static int botRegenTimer = 20;

	private static float botDmgRange = 40f;

	private static float botDmgMult = 0.2f;

	private static int pullEnemiesTimer = 3;

	private static Coroutine pullCO;

	internal static void Awake()
	{
		enemyHOTs = new List<UID>();
		enemyTimers = new List<int>();
		players = (Character[])(object)new Character[2];
		allPlayers = new List<Character>();
		SL.OnGameplayResumedAfterLoading += Fixer;
		SL.OnGameplayResumedAfterLoading += NerfStability;
	}

	private static void NerfStability()
	{
		foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
		{
			item.ControlledCharacter.Stats.m_stabilityRegen.BaseValue = 5f;
		}
	}

	private static void Fixer()
	{
		counterNum = 0;
		player = CharacterManager.Instance.GetFirstLocalCharacter();
		if (player.IsWorldHost)
		{
			if (pullCO != null)
			{
				((MonoBehaviour)HardcoreRebalanceBase.Instance).StopCoroutine(pullCO);
			}
			pullCO = ((MonoBehaviour)HardcoreRebalanceBase.Instance).StartCoroutine(EnemyPull());
			((MonoBehaviour)HardcoreRebalanceBase.Instance).StartCoroutine(EnemyHealer());
		}
	}

	private static IEnumerator EnemyHealer()
	{
		yield return (object)new WaitForSeconds(2f);
		List<Character> list = new List<Character>();
		CharacterManager.Instance.FindCharactersInRange(player.CenterPosition, botDmgRange, ref list);
		foreach (Character item in list)
		{
			if (item.IsAI && item.Alive && !item.IsDead && item.Stats.CurrentHealth > 2f)
			{
				item.Stats.AffectHealth(1000f);
			}
		}
	}

	private static IEnumerator EnemyPull()
	{
		while ((Object)(object)player != (Object)null)
		{
			foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
			{
				Character nplayer = item.ControlledCharacter;
				if (!((Object)(object)nplayer != (Object)null))
				{
					continue;
				}
				List<Character> list = new List<Character>();
				CharacterManager.Instance.FindCharactersInRange(nplayer.CenterPosition, botDmgRange, ref list);
				foreach (Character enemy in list)
				{
					yield return (object)new WaitForSeconds(Random.Range(0.1f, (float)pullEnemiesTimer));
					TargetingSystem targetingSystem = enemy.TargetingSystem;
					if ((Object)(object)((targetingSystem != null) ? targetingSystem.LockingPoint : null) != (Object)null && !enemy.IsAlly(nplayer) && enemy.IsAI && enemy.Stats.CurrentHealth > 0f && !Physics.Linecast(enemy.CenterPosition, ((Component)((Component)nplayer).gameObject.GetComponent<Collider>()).transform.position, Global.SightHideMask) && Random.Range(1, 3) == 1)
					{
						enemy.TargetingSystem.SwitchTarget(nplayer.LockingPoint);
					}
				}
			}
		}
	}

	private static void drainStability(Character player, float _amount, bool isMana = false)
	{
		_amount = ((!isMana) ? (_amount * 1f) : (_amount * 2.5f));
		if (_amount >= 30f)
		{
			_amount = 30f;
		}
		player.m_stability = Mathf.Clamp(player.m_stability - _amount, 0f, 100f);
		_ = player.Stability;
		_ = 1f;
	}
}
[BepInPlugin("com.iggy.hardcorere", "True Hardcore", "3.1.0")]
[BepInDependency("com.sinai.SideLoader", "3.7.7")]
public class HardcoreRebalanceBase : BaseUnityPlugin
{
	private const string GUID = "com.iggy.hardcorere";

	private const string NAME = "True Hardcore";

	private const string VERSION = "3.1.0";

	public static ConfigEntry<bool> EnhancedAI;

	public static ConfigEntry<bool> PickupAnim;

	public static ConfigEntry<bool> PerCityStash;

	public static ConfigEntry<bool> CampingGuard;

	public static ConfigEntry<bool> CraftLimits;

	public static ConfigEntry<bool> NightGates;

	public static ConfigEntry<bool> EnemyHealing;

	public static bool EnhancedAIStored;

	public static bool PickupAnimStored;

	public static bool PerCityStashStored;

	public static bool CampingGuardStored;

	public static bool CraftLimitsStored;

	public static bool NightGatesStored;

	public static bool EnemyHealingStored;

	public static string OptionsName = "Weenie Hut Jrs Options (RESTART REQUIRED)";

	public static HardcoreRebalanceBase Instance;

	internal void Awake()
	{
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		Instance = this;
		Debug.Log((object)"True Hardcoreawake");
		EnhancedAI = ((BaseUnityPlugin)this).Config.Bind<bool>(OptionsName, "Improve enemies AI", true, "Disable to: Remove Improved enemies sight, aggresiveness and hearing.");
		PickupAnim = ((BaseUnityPlugin)this).Config.Bind<bool>(OptionsName, "OoC Animations", true, "Disable to: Remove looting and equiping animations while out of combat");
		PerCityStash = ((BaseUnityPlugin)this).Config.Bind<bool>(OptionsName, "Per City Stash", true, "Disable to: Make stashes universal again, instead of per city.");
		CampingGuard = ((BaseUnityPlugin)this).Config.Bind<bool>(OptionsName, "Unsafe Camping", true, "Disable to: Allow players to guard while camping.");
		CraftLimits = ((BaseUnityPlugin)this).Config.Bind<bool>(OptionsName, "Crafting Limits", true, "Disable to: Allow VANILLA items to be crafted without recipee knowledge too. By default only MOD items can be crafted with no recipee.");
		NightGates = ((BaseUnityPlugin)this).Config.Bind<bool>(OptionsName, "Night Gates", true, "Disable to: Allow players to enter cities freely at night.");
		EnemyHealing = ((BaseUnityPlugin)this).Config.Bind<bool>(OptionsName, "Enemy Healing", true, "Disable to: Stop enemies from healing when damaging players.");
		_ = ((Component)this).gameObject;
		EventsManager.Awake();
		AIManager.Awake();
		CraftingLimits.Awake();
		DeathMortality.Awake();
		new Harmony("com.iggy.hardcorere").PatchAll();
	}

	internal void Start()
	{
		EnhancedAIStored = EnhancedAI.Value;
		PickupAnimStored = PickupAnim.Value;
		PerCityStashStored = PerCityStash.Value;
		CampingGuardStored = CampingGuard.Value;
		CraftLimitsStored = CraftLimits.Value;
		NightGatesStored = NightGates.Value;
		EnemyHealingStored = EnemyHealing.Value;
		Debug.Log((object)"True HardcoreLoaded");
	}
}
internal static class TrapAwareness
{
	[HarmonyPatch(typeof(TrapTrigger), "OnTriggerEnter")]
	public class TrapTrigger_OnTriggerEnter
	{
		[HarmonyPrefix]
		public static bool Prefix(TrapTrigger __instance, Collider _other)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Invalid comparison between Unknown and I4
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Invalid comparison between Unknown and I4
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			if (AreaManager.Instance.GetIsCurrentAreaTownOrCity())
			{
				return true;
			}
			if ((Object)(object)_other == (Object)null)
			{
				return true;
			}
			if ((Object)(object)NetworkLevelLoader.Instance == (Object)null || !NetworkLevelLoader.Instance.IsOverallLoadingDone)
			{
				if (!__instance.m_pendingActivation.Contains(_other))
				{
					__instance.m_pendingActivation.Add(_other);
				}
				return true;
			}
			Character component = ((Component)_other).GetComponent<Character>();
			if ((Object)(object)component == (Object)null || __instance.m_charactersInTrigger.Contains(component))
			{
				return true;
			}
			if (__instance.IgnoreFaction || ((int)__instance.m_targetType == 1 && Object.op_Implicit((Object)(object)component.OwnerPlayerSys)) || ((int)__instance.m_targetType == 2 && UnityEngineExtensions.Contains<Factions>(__instance.m_targetableFactions, component.Faction)))
			{
				if (component.StatusEffectMngr.HasStatusEffect(HardcoreEffects.TrapAware.ToString()))
				{
					return false;
				}
				Debug.Log((object)(component.Name + " Added Awareness"));
				component.StatusEffectMngr.AddStatusEffect(HardcoreEffects.TrapAware.ToString());
				return true;
			}
			return true;
		}
	}
}