Decompiled source of OuthardTrueHardcore v0.0.2

HardcoreFF.dll

Decompiled 2 months 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 Photon;
using SideLoader;
using SideLoader.Helpers;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("PvP")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PvP")]
[assembly: AssemblyCopyright("Copyright ©  2019")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8654b1db-7a3b-411b-9891-c0078b5dda2f")]
[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 PvP;

public class BattleRoyale : MonoBehaviour
{
	public static BattleRoyale Instance;

	public bool IsGameplayStarting = false;

	public bool IsGameplayEnding = false;

	public static int SupplyDropInterval = 120;

	public float LastSupplyDropTime = 0f;

	public int SupplyDropCounter = 0;

	public List<GameObject> ActiveItemContainers = new List<GameObject>();

	public List<GameObject> ActiveBeamObjects = new List<GameObject>();

	public GameObject beamObject;

	public static int EnemyDropInterval = 45;

	public float LastEnemySpawnTime = 0f;

	public List<Character> EnemyCharacters = new List<Character>();

	internal void Awake()
	{
		Instance = this;
	}

	internal void Update()
	{
		if (MenuManager.Instance.IsInMainMenuScene)
		{
			if (IsGameplayStarting)
			{
				IsGameplayStarting = false;
				((MonoBehaviour)this).StopAllCoroutines();
			}
			if (PvP.Instance.CurrentGame == PvP.GameModes.BattleRoyale)
			{
				PvP.Instance.CurrentGame = PvP.GameModes.NONE;
			}
		}
		if (!IsGameplayStarting && IsGameplayEnding && !PvPGUI.Instance.ShowGUI)
		{
			PvPGUI.Instance.ShowGUI = true;
		}
	}

	public bool CheckCanStart()
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		List<Factions> list = new List<Factions>();
		foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
		{
			if (!list.Contains(item.ControlledCharacter.Faction))
			{
				list.Add(item.ControlledCharacter.Faction);
			}
		}
		if (list.Count() > 1)
		{
			return true;
		}
		return false;
	}

	public void StartBattleRoyale(bool skipLoad = false)
	{
		((MonoBehaviour)RPCManager.Instance).photonView.RPC("RPCStartBattleRoyale", (PhotonTargets)0, new object[1] { skipLoad });
	}

	public IEnumerator SetupAfterSceneLoad(bool skipLoad = false)
	{
		if (!skipLoad)
		{
			while (!NetworkLevelLoader.Instance.IsSceneLoading)
			{
				yield return (object)new WaitForSeconds(0.1f);
			}
			while (!NetworkLevelLoader.Instance.IsOverallLoadingDone)
			{
				yield return (object)new WaitForSeconds(0.1f);
			}
		}
		SetupCharacters();
		while (NetworkLevelLoader.Instance.IsGameplayPaused)
		{
			yield return null;
		}
		yield return (object)new WaitForSeconds(1f);
		Debug.Log((object)"Setting up local scene...");
		LocalSceneSetup();
		if (!PhotonNetwork.isNonMasterClientInRoom)
		{
			Debug.Log((object)"Setting up as host...");
			HostSceneSetup();
		}
		Debug.Log((object)"Battle Royale is about to start, finalizing...");
		RPCManager.Instance.StartGameplayRPC(2, "A Battle Royale has begun!");
		EnemyDropInterval = Mathf.Clamp(45 - PlayerManager.Instance.GetRemainingPlayers().Count() * 2, 15, 45);
		Debug.Log((object)"Finalized!");
	}

	private void HostSceneSetup()
	{
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		while (ItemManager.Instance.WorldItems.Keys.Count() > 0)
		{
			ItemManager.Instance.DestroyItem(ItemManager.Instance.WorldItems.Keys[0]);
		}
		if (Templates.BR_Templates.SpawnLocations.ContainsKey(SceneManagerHelper.ActiveSceneName))
		{
			List<Vector3> list = Templates.BR_Templates.SpawnLocations[SceneManagerHelper.ActiveSceneName].ToList();
			{
				foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
				{
					Character controlledCharacter = item.ControlledCharacter;
					if (list.Count == 0)
					{
						list = Templates.BR_Templates.SpawnLocations[SceneManagerHelper.ActiveSceneName].ToList();
					}
					int index = Random.Range(0, list.Count());
					controlledCharacter.Teleport(list[index], ((Component)controlledCharacter).transform.rotation);
					list.RemoveAt(index);
					controlledCharacter.StatusEffectMngr.Purge();
				}
				return;
			}
		}
		PvP.Instance.StopGameplay("An error has occured! We seem to be in the wrong scene.");
	}

	private void LocalSceneSetup()
	{
		//IL_0218: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0306: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: Expected O, but got Unknown
		EnvironmentConditions.Instance.SetTimeOfDay(Templates.BR_Templates.TimeOfDayStarts[SceneManagerHelper.ActiveSceneName], false);
		if (Templates.BR_Templates.ObjectsToDeactivate.ContainsKey(SceneManagerHelper.ActiveSceneName))
		{
			foreach (string item in Templates.BR_Templates.ObjectsToDeactivate[SceneManagerHelper.ActiveSceneName])
			{
				GameObject val = GameObject.Find(item);
				if (val != null)
				{
					if (item == "JesusBeam")
					{
						beamObject = val;
					}
					val.SetActive(false);
				}
			}
		}
		if (Templates.BR_Templates.ObjectsToActivate.ContainsKey(SceneManagerHelper.ActiveSceneName))
		{
			foreach (string item2 in Templates.BR_Templates.ObjectsToActivate[SceneManagerHelper.ActiveSceneName])
			{
				GameObject val2 = GameObject.Find(item2);
				if (val2 != null)
				{
					val2.SetActive(true);
					continue;
				}
				GameObject val3 = FindInactiveObjectByName(item2);
				if (val3 != null)
				{
					val3.SetActive(true);
				}
			}
		}
		EnemyCharacters.Clear();
		foreach (Character item3 in CharacterManager.Instance.Characters.Values.Where((Character x) => x.IsAI && (int)x.Faction != 1))
		{
			EnemyCharacters.Add(item3);
			((Component)item3).gameObject.SetActive(false);
		}
		foreach (PlayerSystem item4 in Global.Lobby.PlayersInLobby.Where((PlayerSystem x) => x.IsLocalPlayer))
		{
			Character controlledCharacter = item4.ControlledCharacter;
			string text = "Pouch_" + UID.op_Implicit(controlledCharacter.UID);
			if (Object.op_Implicit((Object)(object)ItemManager.Instance.GetItem(text)))
			{
				ItemManager.Instance.DestroyItem(text);
			}
			ItemContainer val4 = null;
			if (Object.op_Implicit((Object)(object)controlledCharacter.Inventory.PouchPrefab))
			{
				Transform val5 = Object.Instantiate<Transform>(controlledCharacter.Inventory.PouchPrefab);
				val5.SetParent(((Component)this).transform, false);
				val4 = ((Component)val5).GetComponent<ItemContainer>();
				((Item)val4).SetKeepAlive();
				((Item)val4).UID = "CustomPouch_" + UID.op_Implicit(controlledCharacter.UID);
				((Item)val4).ProcessInit();
				At.SetField<CharacterInventory>(controlledCharacter.Inventory, "m_inventoryPouch", (object)val4);
				if (PhotonNetwork.isNonMasterClientInRoom)
				{
					((Item)val4).ForceUpdateParentChange();
				}
			}
			if (controlledCharacter.Inventory.MapKnowledge == null)
			{
				CharacterMapKnowledge val6 = new CharacterMapKnowledge();
				val6.Init();
				At.SetField<CharacterInventory>(controlledCharacter.Inventory, "m_mapKnowledge", (object)val6);
			}
			controlledCharacter.Inventory.Equipment.ProcessStart();
			SetupStarterPack(controlledCharacter);
			controlledCharacter.StatusEffectMngr.Purge();
		}
		UICompass[] array = Resources.FindObjectsOfTypeAll<UICompass>();
		foreach (UICompass val7 in array)
		{
			((UIElement)val7).Hide();
		}
	}

	private void SetupCharacters()
	{
		foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
		{
			CustomPlayerSetup(item.ControlledCharacter);
		}
	}

	private void CustomPlayerSetup(Character _char)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Expected O, but got Unknown
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Expected O, but got Unknown
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Expected O, but got Unknown
		CharacterSave val = SaveManager.Instance.CreateNewCharacterSave();
		((CharacterSaveData)val.PSave).NewSave = true;
		((CharacterSaveData)val.PSave).ManaPoint = 0;
		((CharacterSaveData)val.PSave).UID = UID.op_Implicit(_char.UID);
		val.PSave.Name = _char.Name;
		((CharacterSaveData)val.PSave).VisualData = _char.VisualData;
		val.PSave.Food = 1000f;
		val.PSave.Drink = 1000f;
		val.PSave.HardcoreMode = false;
		val.ApplyLoadedSaveToChar(_char);
		At.SetField<CharacterStats>(_char.Stats, "m_maxHealthStat", (object)new Stat(500f));
		At.SetField<CharacterStats>(_char.Stats, "m_maxStamina", (object)new Stat(200f));
		At.SetField<CharacterStats>(_char.Stats, "m_maxManaStat", (object)new Stat(75f));
		_char.Stats.GiveManaPoint(1);
		_char.Cheats.Invincible = false;
		_char.Cheats.IndestructibleEquipment = false;
		_char.Cheats.NotAffectedByWeightPenalties = false;
		_char.Cheats.NeedsEnabled = true;
		At.Invoke<CharacterStats>(_char.Stats, "UpdateVitalStats", Array.Empty<object>());
		_char.Stats.Reset();
		_char.Stats.RestoreAllVitals();
		if (At.GetField<CharacterQuickSlotManager>(_char.QuickSlotMngr, "m_quickSlots") is QuickSlot[] source)
		{
			for (int i = 0; i < source.Count(); i++)
			{
				_char.QuickSlotMngr.GetQuickSlot(i).Clear();
			}
		}
	}

	private void SetupStarterPack(Character _char)
	{
		Debug.Log((object)("SetupStarterPack for " + ((Object)((Component)_char).gameObject).name));
		Item val = ItemManager.Instance.GenerateItemNetwork(5300000);
		if ((Object)(object)val != (Object)null)
		{
			_char.Inventory.TakeItem(val.UID, false);
			At.Invoke<CharacterEquipment>(_char.Inventory.Equipment, "EquipWithoutAssociating", new object[2] { val, false });
			ItemContainer val2 = _char.Inventory.Pouch;
			ItemContainer componentInChildren = ((Component)val).GetComponentInChildren<ItemContainer>();
			if (componentInChildren != null)
			{
				val2 = componentInChildren;
			}
			AddItemsToContainer(Templates.BR_Templates.Weapons_Low, 1, ((Component)val2).transform);
			AddItemsToContainer(Templates.BR_Templates.Offhands_Low, 1, ((Component)val2).transform);
			AddItemsToContainer(Templates.BR_Templates.Supplies_Low, 5, ((Component)val2).transform);
			AddItemsToContainer(Templates.StarterSkills, Templates.StarterSkills.Count(), ((Component)val2).transform);
		}
	}

	public void UpdateBR()
	{
		if (!PhotonNetwork.isNonMasterClientInRoom)
		{
			WorldHostUpdate();
		}
	}

	private void WorldHostUpdate()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: Unknown result type (might be due to invalid IL or missing references)
		//IL_029a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Unknown result type (might be due to invalid IL or missing references)
		List<Factions> remainingTeams = PlayerManager.Instance.GetRemainingTeams();
		if (remainingTeams.Count() < 2)
		{
			Factions val = remainingTeams[0];
			string text = ((object)(Factions)(ref val)).ToString();
			if (!text.EndsWith("s"))
			{
				text += "s";
			}
			PvP.Instance.StopGameplay(text + " have won!");
		}
		if (LastSupplyDropTime <= 0f || Time.time - LastSupplyDropTime > (float)SupplyDropInterval)
		{
			LastSupplyDropTime = Time.time;
			SupplyDropCounter++;
			((MonoBehaviour)this).StartCoroutine(GenerateSupplyDrops());
		}
		if (!(Time.time - LastEnemySpawnTime > (float)EnemyDropInterval) || EnemyCharacters.Count() <= 0)
		{
			return;
		}
		LastEnemySpawnTime = Time.time;
		Character val2 = null;
		List<Character> list = EnemyCharacters.Where((Character x) => !((Component)x).gameObject.activeSelf).ToList();
		if (list.Count() <= 0)
		{
			return;
		}
		Character butcher = list.Find((Character x) => x.Name.ToLower().Contains("butcher"));
		if (SupplyDropCounter < 3 || !Object.op_Implicit((Object)(object)butcher))
		{
			if (Object.op_Implicit((Object)(object)butcher))
			{
				list.Remove(butcher);
			}
			int index = Random.Range(0, list.Count());
			val2 = list.ElementAt(index);
		}
		else
		{
			val2 = butcher;
		}
		if (!Object.op_Implicit((Object)(object)val2))
		{
			return;
		}
		if (val2.IsDead)
		{
			val2.Resurrect();
		}
		string activeSceneName = SceneManagerHelper.ActiveSceneName;
		List<Vector3> list2 = Templates.BR_Templates.SpawnLocations[activeSceneName];
		int index2 = Random.Range(0, list2.Count());
		Vector3 val3 = list2[index2];
		UID uID;
		if (PhotonNetwork.offlineMode)
		{
			RPCManager instance = RPCManager.Instance;
			uID = val2.UID;
			instance.SendSpawnEnemyRPC(((object)(UID)(ref uID)).ToString(), val3.x, val3.y, val3.z);
		}
		else
		{
			PhotonView photonView = ((MonoBehaviour)RPCManager.Instance).photonView;
			object[] array = new object[4];
			uID = val2.UID;
			array[0] = ((object)(UID)(ref uID)).ToString();
			array[1] = val3.x;
			array[2] = val3.y;
			array[3] = val3.z;
			photonView.RPC("SendSpawnEnemyRPC", (PhotonTargets)0, array);
		}
		if (val2.Name.ToLower().Contains("butcher"))
		{
			RPCManager.SendMessageToAll("The Butcher of Men has spawned!");
			EnemyCharacters.RemoveAll((Character x) => x.UID == butcher.UID);
		}
		PlayerManager.Instance.ChangeFactions(val2, (Factions)0);
	}

	public void EndBattleRoyale()
	{
		UICompass[] array = Resources.FindObjectsOfTypeAll<UICompass>();
		foreach (UICompass val in array)
		{
			((UIElement)val).Show(true);
		}
		try
		{
			if (PhotonNetwork.offlineMode)
			{
				RPCManager.Instance.RPCSendCleanup();
			}
			else
			{
				((MonoBehaviour)RPCManager.Instance).photonView.RPC("RPCSendCleanup", (PhotonTargets)0, new object[0]);
			}
			ActiveItemContainers.Clear();
			ActiveBeamObjects.Clear();
		}
		catch
		{
		}
		if (!PhotonNetwork.isNonMasterClientInRoom && !MenuManager.Instance.IsReturningToMainMenu && !MenuManager.Instance.IsInMainMenuScene)
		{
			IsGameplayEnding = true;
		}
	}

	public void AddItemsToContainer(List<int> _itemList, int _amountToAdd, Transform _container, bool _removeWhenAdded = true)
	{
		List<int> list = _itemList.ToList();
		for (int i = 0; i < _amountToAdd; i++)
		{
			if (list.Count() == 0)
			{
				break;
			}
			int index = Random.Range(0, list.Count());
			Item val = ItemManager.Instance.GenerateItemNetwork(list[index]);
			val.ChangeParent(_container);
			if (_removeWhenAdded)
			{
				list.RemoveAt(index);
			}
		}
	}

	private IEnumerator GenerateSupplyDrops()
	{
		if (ActiveItemContainers.Count() > 0)
		{
			if (PhotonNetwork.offlineMode)
			{
				RPCManager.Instance.RPCSendCleanup();
			}
			else
			{
				((MonoBehaviour)RPCManager.Instance).photonView.RPC("RPCSendCleanup", (PhotonTargets)0, new object[0]);
			}
			yield return (object)new WaitForSeconds(2f);
		}
		if (SupplyDropCounter == 1)
		{
			foreach (PlayerSystem ps in Global.Lobby.PlayersInLobby)
			{
				Character _char = ps.ControlledCharacter;
				TreasureChest stash = ((Component)ItemManager.Instance.GenerateItemNetwork(1000110)).GetComponent<TreasureChest>();
				((Component)stash).transform.position = ((Component)_char).transform.position + new Vector3(1.5f, 0f, 1.5f);
				ActiveItemContainers.Add(((Component)stash).gameObject);
				if (!PhotonNetwork.offlineMode)
				{
					((MonoBehaviour)RPCManager.Instance).photonView.RPC("RPCGenerateStash", (PhotonTargets)1, new object[5]
					{
						((Item)stash).ItemID,
						((Item)stash).UID,
						((Component)stash).transform.position.x,
						((Component)stash).transform.position.y,
						((Component)stash).transform.position.z
					});
				}
				At.Invoke<TreasureChest>(stash, "InitDrops", Array.Empty<object>());
				for (int j = 0; j < 5; j++)
				{
					At.SetField<TreasureChest>(stash, "m_hasGeneratedContent", (object)false);
					((SelfFilledItemContainer)stash).GenerateContents();
				}
			}
			yield break;
		}
		RPCManager.SendMessageToAll("Supply Chests are spawning!");
		List<Vector3> locations = Templates.BR_Templates.SupplyDropLocations[SceneManagerHelper.ActiveSceneName].ToList();
		int numOfDrops2 = (int)Math.Ceiling((float)PlayerManager.Instance.GetRemainingPlayers().Count() * 0.5f);
		numOfDrops2 = Mathf.Clamp(numOfDrops2, 2, locations.Count());
		for (int i = 0; i < numOfDrops2; i++)
		{
			if (locations.Count == 0)
			{
				break;
			}
			int random = Random.Range(0, locations.Count());
			GenerateChestSingle(locations[random]);
			locations.RemoveAt(random);
		}
	}

	private void GenerateChestSingle(Vector3 position)
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		int num = ((SupplyDropCounter != 2) ? 1000040 : 1000000);
		TreasureChest component = ((Component)ItemManager.Instance.GenerateItemNetwork(num)).GetComponent<TreasureChest>();
		ActiveItemContainers.Add(((Component)component).gameObject);
		((Component)component).transform.position = position;
		if (!PhotonNetwork.offlineMode)
		{
			((MonoBehaviour)RPCManager.Instance).photonView.RPC("RPCGenerateStash", (PhotonTargets)1, new object[5]
			{
				((Item)component).ItemID,
				((Item)component).UID,
				position.x,
				position.y,
				position.z
			});
		}
		Transform transform = ((Component)((Component)component).GetComponentInChildren<ItemContainer>()).transform;
		if (SupplyDropCounter == 2)
		{
			AddItemsToContainer(Templates.BR_Templates.Weapons_Med, 1, transform);
			AddItemsToContainer(Templates.BR_Templates.Offhands_High, 1, transform);
			AddItemsToContainer(Templates.BR_Templates.Armor_Low, 2, transform);
			AddItemsToContainer(Templates.BR_Templates.Supplies_Low, 6, transform, _removeWhenAdded: false);
		}
		else
		{
			AddItemsToContainer(Templates.BR_Templates.Weapons_High, 1, transform);
			AddItemsToContainer(Templates.BR_Templates.Offhands_High, 1, transform);
			AddItemsToContainer(Templates.BR_Templates.Armor_High, 2, transform);
			AddItemsToContainer(Templates.BR_Templates.Supplies_High, 6, transform);
		}
		if (PhotonNetwork.offlineMode)
		{
			RPCManager.Instance.RPCSendSupplyDrop(((Item)component).UID, position.x, position.y, position.z);
			return;
		}
		((MonoBehaviour)RPCManager.Instance).photonView.RPC("RPCSendSupplyDrop", (PhotonTargets)0, new object[4]
		{
			((Item)component).UID,
			position.x,
			position.y,
			position.z
		});
	}

	public IEnumerator SupplyDropLocalCoroutine(string itemUID, Vector3 location)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		while (!Object.op_Implicit((Object)(object)ItemManager.Instance.GetItem(itemUID)))
		{
			yield return (object)new WaitForSeconds(0.1f);
		}
		if ((Object)(object)beamObject != (Object)null)
		{
			GameObject newbeam = Object.Instantiate<GameObject>(beamObject);
			newbeam.SetActive(true);
			((Component)newbeam.transform.GetChild(0)).gameObject.SetActive(false);
			Object.DestroyImmediate((Object)(object)newbeam.GetComponent<MeshCollider>());
			newbeam.transform.localScale = new Vector3(100f, 10f, 100f);
			newbeam.transform.position = location + Vector3.up * 10f;
			ActiveBeamObjects.Add(newbeam);
		}
	}

	public void CleanupSupplyObjects()
	{
		int num = 0;
		while (num < ActiveItemContainers.Count() && ActiveItemContainers.Count() >= 1)
		{
			GameObject val = ActiveItemContainers[num];
			if (Object.op_Implicit((Object)(object)val))
			{
				TreasureChest component = val.GetComponent<TreasureChest>();
				if (component != null)
				{
					try
					{
						ItemManager.Instance.DestroyItem(((Item)component).UID);
					}
					catch
					{
					}
				}
			}
			ActiveItemContainers.RemoveAt(num);
			num--;
			num++;
		}
		int num2 = 0;
		while (num2 < ActiveBeamObjects.Count() && ActiveBeamObjects.Count() >= 1)
		{
			GameObject val2 = ActiveBeamObjects[num2];
			if (Object.op_Implicit((Object)(object)val2))
			{
				Object.DestroyImmediate((Object)(object)val2);
			}
			ActiveBeamObjects.RemoveAt(num2);
			num2--;
			num2++;
		}
	}

	public GameObject FindInactiveObjectByName(string name)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Invalid comparison between Unknown and I4
		Transform[] array = Resources.FindObjectsOfTypeAll<Transform>();
		for (int i = 0; i < array.Length; i++)
		{
			if ((int)((Object)array[i]).hideFlags == 0 && ((Object)array[i]).name == name)
			{
				return ((Component)array[i]).gameObject;
			}
		}
		return null;
	}
}
public class BattleRoyale_Hooks
{
	[HarmonyPatch(typeof(Character), "Die")]
	public class Character_Die
	{
		[HarmonyPrefix]
		public static void Prefix(Character __instance)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			if (PvP.Instance.CurrentGame != PvP.GameModes.BattleRoyale)
			{
				return;
			}
			if (!__instance.IsAI)
			{
				if (!PhotonNetwork.isNonMasterClientInRoom && At.GetField<Character>(__instance, "m_lastDealers") is List<Pair<UID, float>> list)
				{
					float num = Time.time;
					string text = "";
					foreach (Pair<UID, float> item in list)
					{
						if (item.Value < num)
						{
							num = item.Value;
							text = UID.op_Implicit(item.Key);
						}
					}
					if (text != "")
					{
						Character character = CharacterManager.Instance.GetCharacter(text);
						if (character != null)
						{
							list.Clear();
							At.SetField<Character>(__instance, "m_lastDealers", (object)character);
							RPCManager.SendMessageToAll(character.Name + " has defeated " + __instance.Name);
						}
					}
				}
				foreach (EquipmentSlot item2 in __instance.Inventory.Equipment.EquipmentSlots.Where((EquipmentSlot x) => (Object)(object)x != (Object)null && x.HasItemEquipped))
				{
					__instance.Inventory.DropItem(((Item)item2.EquippedItem).UID);
				}
			}
			else
			{
				if ((Object)(object)__instance.Inventory == (Object)null || (Object)(object)((Component)__instance).GetComponent<LootableOnDeath>() == (Object)null)
				{
					return;
				}
				if (!Object.op_Implicit((Object)(object)__instance.Inventory.Pouch) || !((EffectSynchronizer)__instance.Inventory.Pouch).FullyInitialized)
				{
					__instance.Inventory.ProcessStart();
				}
				if (!PhotonNetwork.isNonMasterClientInRoom)
				{
					if (__instance.Name.ToLower().Contains("butcher"))
					{
						BattleRoyale.Instance.AddItemsToContainer(Templates.BR_Templates.Skills_High, 3, ((Component)__instance.Inventory.Pouch).transform);
						BattleRoyale.Instance.AddItemsToContainer(Templates.BR_Templates.Weapons_High, 1, ((Component)__instance.Inventory.Pouch).transform);
					}
					else if (__instance.Name == "Immaculate" || ((Object)__instance).name == "Shell Horror")
					{
						BattleRoyale.Instance.AddItemsToContainer(Templates.BR_Templates.Skills_High, 1, ((Component)__instance.Inventory.Pouch).transform);
						BattleRoyale.Instance.AddItemsToContainer(Templates.BR_Templates.Skills_Low, 2, ((Component)__instance.Inventory.Pouch).transform);
					}
					else
					{
						BattleRoyale.Instance.AddItemsToContainer(Templates.BR_Templates.Skills_Low, 3, ((Component)__instance.Inventory.Pouch).transform);
					}
				}
			}
			if (__instance.IsLocalPlayer)
			{
				((Component)__instance.OwnerPlayerSys).gameObject.AddComponent<Spectate>();
			}
		}
	}

	[HarmonyPatch(typeof(ItemContainer), "AddItem", new Type[]
	{
		typeof(Item),
		typeof(bool)
	})]
	public class ItemContainer_AddItem
	{
		[HarmonyPrefix]
		public static bool Prefix(ItemContainer __instance, Item _item, ref bool __result)
		{
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected I4, but got Unknown
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected I4, but got Unknown
			if (PhotonNetwork.isNonMasterClientInRoom)
			{
				return true;
			}
			if (BattleRoyale.Instance.IsGameplayStarting || PvP.Instance.CurrentGame == PvP.GameModes.BattleRoyale)
			{
				if (_item is Skill && (Object)(object)((EffectSynchronizer)__instance).OwnerCharacter != (Object)null && !((EffectSynchronizer)__instance).OwnerCharacter.IsAI)
				{
					if (!((CharacterKnowledge)((EffectSynchronizer)__instance).OwnerCharacter.Inventory.SkillKnowledge).IsItemLearned(_item.ItemID))
					{
						_item.ChangeParent(((Component)((EffectSynchronizer)__instance).OwnerCharacter.Inventory.SkillKnowledge).transform);
					}
					__result = true;
					return false;
				}
				if (_item is Weapon && (Object)(object)((EffectSynchronizer)__instance).OwnerCharacter != (Object)null && Templates.Weapon_Skills.ContainsKey((int)((Weapon)((_item is Weapon) ? _item : null)).Type))
				{
					int num = Templates.Weapon_Skills[(int)((Weapon)((_item is Weapon) ? _item : null)).Type];
					CharacterSkillKnowledge skillKnowledge = ((EffectSynchronizer)__instance).OwnerCharacter.Inventory.SkillKnowledge;
					if (skillKnowledge != null && !((CharacterKnowledge)skillKnowledge).IsItemLearned(num))
					{
						Item val = ItemManager.Instance.GenerateItemNetwork(num);
						val.ChangeParent(((Component)skillKnowledge).transform);
						List<Item> list = At.GetField<CharacterKnowledge>((CharacterKnowledge)(object)skillKnowledge, "m_learnedItems") as List<Item>;
						list.Add(val);
					}
				}
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(PlayerCharacterStats), "UpdateWeight")]
	public class PlayerCharacterStats_UpdateWeight
	{
		[HarmonyFinalizer]
		public static Exception Finalizer()
		{
			return null;
		}
	}
}
public class DeathMatch : MonoBehaviour
{
	public static DeathMatch Instance;

	internal void Awake()
	{
		Instance = this;
	}

	public void UpdateDM()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		List<Factions> remainingTeams = PlayerManager.Instance.GetRemainingTeams();
		if (remainingTeams.Count == 1)
		{
			Factions val = remainingTeams[0];
			string text = ((object)(Factions)(ref val)).ToString();
			if (text.EndsWith("s"))
			{
				text = text.Substring(0, text.Length - 1);
			}
			PvP.Instance.StopGameplay(text + "s have won!");
		}
		else if (remainingTeams.Count <= 0)
		{
			PvP.Instance.StopGameplay("Game ended because there are no active teams!");
		}
	}
}
public class FriendlyFire
{
	[HarmonyPatch(typeof(Character), "IsEnemyClose")]
	public class Character_IsEnemyClose
	{
		[HarmonyPrefix]
		public static bool Prefix(ref bool __result, Character __instance, float _range)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			__result = false;
			Collider[] array = Physics.OverlapSphere(__instance.CenterPosition, _range, Global.LockingPointsMask);
			for (int i = 0; i < array.Length; i++)
			{
				LockingPoint component = ((Component)array[i]).GetComponent<LockingPoint>();
				if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.OwnerChar) && component.OwnerChar.Alive && OrigIsTargetable(__instance.TargetingSystem, component.OwnerChar))
				{
					__result = true;
				}
			}
			return false;
		}
	}

	[HarmonyPatch(typeof(TargetingSystem), "IsTargetable", new Type[] { typeof(Character) })]
	public class TargetingSys_IsTargetable
	{
		[HarmonyPrefix]
		public static bool Prefix(ref bool __result, Character ___m_character, Character _char)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (___m_character.IsAI || !PvP.Instance.FriendlyFireEnabled)
			{
				return true;
			}
			if (___m_character.UID != _char.UID)
			{
				__result = true;
			}
			else
			{
				__result = false;
			}
			return false;
		}
	}

	[HarmonyPatch(typeof(TargetingSystem), "IsTargetable", new Type[] { typeof(Factions) })]
	public class TargetingSys_IsTargetable_2
	{
		[HarmonyPrefix]
		public static bool Prefix(ref bool __result, Character ___m_character)
		{
			if (___m_character.IsAI || !PvP.Instance.FriendlyFireEnabled)
			{
				return true;
			}
			__result = true;
			return false;
		}
	}

	[HarmonyPatch(typeof(TargetingSystem), "AcquireTarget")]
	public class TargetingSys_AcquireTarget
	{
		[HarmonyPrefix]
		public static bool Prefix(TargetingSystem __instance, ref bool __result, Character ___m_character, ref LockingPoint ___m_currentLockingPoint, ref int ___m_remainingHelpLockCount)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)___m_character) || ___m_character.IsAI || !PvP.Instance.FriendlyFireEnabled || (PvP.Instance.FriendlyFireEnabled && PvP.Instance.FriendlyTargetingEnabled))
			{
				return true;
			}
			if ((Object)(object)__instance.CameraRef != (Object)null)
			{
				Collider[] array = Physics.OverlapSphere(___m_character.CenterPosition, __instance.TrueRange, Global.LockingPointsMask);
				LockingPoint val = null;
				Vector3 val2 = Vector2.op_Implicit(Vector2.zero);
				Matrix4x4 worldToCameraMatrix = __instance.CameraRef.worldToCameraMatrix;
				Collider[] array2 = array;
				foreach (Collider val3 in array2)
				{
					Vector3 val4 = ((Matrix4x4)(ref worldToCameraMatrix)).MultiplyPoint(((Component)val3).transform.position);
					if (!(val4.z < 0f))
					{
						continue;
					}
					val4.z *= 0.1f;
					if ((Object)(object)val == (Object)null || ((Vector3)(ref val4)).magnitude < ((Vector3)(ref val2)).magnitude)
					{
						LockingPoint component = ((Component)val3).GetComponent<LockingPoint>();
						if ((Object)(object)component.OwnerChar == (Object)null || (OrigIsTargetable(__instance, component.OwnerChar) && component.OwnerChar.Alive && !Physics.Linecast(___m_character.CenterPosition, ((Component)val3).transform.position, Global.SightHideMask)))
						{
							val = component;
							val2 = val4;
						}
					}
				}
				if ((Object)(object)val != (Object)null)
				{
					___m_currentLockingPoint = val;
					if (___m_remainingHelpLockCount > 0)
					{
						___m_remainingHelpLockCount--;
					}
					__result = true;
					return false;
				}
			}
			__result = false;
			return false;
		}
	}

	[HarmonyPatch(typeof(Blast), "Hit")]
	public class Blast_Hit
	{
		[HarmonyPrefix]
		public static bool Prefix(Blast __instance, ref List<Hitbox> ___cachedHitBox)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)((EffectSynchronizer)__instance).OwnerCharacter) || ((EffectSynchronizer)__instance).OwnerCharacter.IsAI || !PvP.Instance.FriendlyFireEnabled)
			{
				return true;
			}
			Collider[] array = Physics.OverlapSphere(((Component)__instance).transform.position, __instance.Radius, Global.WeaponHittingMask);
			List<Character> list = new List<Character>();
			___cachedHitBox.Clear();
			for (int i = 0; i < array.Length; i++)
			{
				Hitbox component = ((Component)array[i]).GetComponent<Hitbox>();
				if ((Object)(object)component != (Object)null && (Object)(object)component.OwnerChar != (Object)null && component.OwnerChar.UID != ((EffectSynchronizer)__instance).OwnerCharacter.UID && !component.BlockBox && !list.Contains(component.OwnerChar))
				{
					___cachedHitBox.Add(component);
					list.Add(component.OwnerChar);
				}
			}
			At.Invoke<Blast>(__instance, "AffectHit", new object[1] { ___cachedHitBox });
			return false;
		}
	}

	[HarmonyPatch(typeof(Projectile), "Explode", new Type[]
	{
		typeof(Collider),
		typeof(Vector3),
		typeof(Vector3),
		typeof(bool)
	})]
	public class Projectile_Explode
	{
		[HarmonyPrefix]
		public static bool Prefix(Projectile __instance, Collider _collider, Vector3 _hitPoint, Vector3 _hitDir, ref float ___m_lastHitTimer, ref float ___m_targetLightIntensity, float ___m_lightStartIntensity, ref float ___m_lightIntensityFadeSpeed, SoundPlayer ___m_shootSound, SoundPlayer ___m_travelSound, ParticleSystem ___m_explosionFX, ref object[] ___m_explodeInfos)
		{
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Invalid comparison between Unknown and I4
			if (!Object.op_Implicit((Object)(object)((EffectSynchronizer)__instance).OwnerCharacter) || ((EffectSynchronizer)__instance).OwnerCharacter.IsAI || !PvP.Instance.FriendlyFireEnabled)
			{
				return true;
			}
			___m_lastHitTimer = 5f;
			___m_targetLightIntensity = ___m_lightStartIntensity * 1.8f;
			___m_lightIntensityFadeSpeed = __instance.LightIntensityFade.x * 0.5f;
			if (Object.op_Implicit((Object)(object)___m_shootSound))
			{
				___m_shootSound.Stop(false);
			}
			if (Object.op_Implicit((Object)(object)___m_travelSound))
			{
				___m_travelSound.Stop(false);
			}
			Character val = null;
			if ((Object)(object)_collider != (Object)null)
			{
				if (Object.op_Implicit((Object)(object)___m_explosionFX))
				{
					___m_explosionFX.Play();
				}
				val = UnityEngineExtensions.GetCharacterOwner(_collider);
			}
			bool flag = false;
			if (Object.op_Implicit((Object)(object)val) && (Object)(object)((EffectSynchronizer)__instance).OwnerCharacter != (Object)(object)val)
			{
				if (!__instance.Unblockable && val.ShieldEquipped)
				{
					Hitbox component = ((Component)_collider).GetComponent<Hitbox>();
					if ((Object)(object)component != (Object)null && component.BlockBox && val.Blocking && !val.Countering)
					{
						flag = true;
					}
				}
			}
			else
			{
				val = null;
			}
			At.Invoke<Projectile>(__instance, "OnProjectileHit", new object[4] { val, _hitPoint, _hitDir, flag });
			___m_explodeInfos[0] = val;
			___m_explodeInfos[1] = _hitPoint;
			___m_explodeInfos[2] = _hitDir;
			___m_explodeInfos[3] = (Object)(object)_collider != (Object)null;
			((Component)__instance).SendMessage("OnExplodeDone", (object)___m_explodeInfos, (SendMessageOptions)1);
			if ((int)__instance.EndMode == 0 || ((int)__instance.EndMode == 3 && ((Object)(object)_collider == (Object)null || Global.FullEnvironmentMask == (Global.FullEnvironmentMask | (1 << ((Component)_collider).gameObject.layer)))))
			{
				At.Invoke<Projectile>(__instance, "EndLife", Array.Empty<object>());
			}
			return false;
		}
	}

	[HarmonyPatch(typeof(RaycastProjectile), "CheckCollision")]
	public class RaycastProjectile_CheckCollision
	{
		[HarmonyPrefix]
		public static bool Prefix(ref bool __result, RaycastProjectile __instance, Vector3 _startRaycast, float _dist, ref RaycastHit _hit, ref Vector3 ___m_shootDir, float ___m_radiusAdd, float ___m_capsuleAdd, LockingPoint ___m_homingTarget, List<Character> ___m_hitCharList)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Expected O, but got Unknown
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Invalid comparison between Unknown and I4
			if (!PvP.Instance.FriendlyFireEnabled || Object.op_Implicit((Object)(object)((EffectSynchronizer)__instance).OwnerCharacter) || ((EffectSynchronizer)__instance).OwnerCharacter.IsAI)
			{
				return true;
			}
			_hit = default(RaycastHit);
			int num = RaycastHitLayerMask(__instance);
			RaycastHit[] array = ((__instance.Radius == 0f) ? Physics.RaycastAll(_startRaycast, ___m_shootDir, _dist, num) : ((__instance.Capsule == 0f) ? Physics.CapsuleCastAll(_startRaycast - ((Component)__instance).transform.right * (__instance.Capsule + ___m_capsuleAdd), _startRaycast + ((Component)__instance).transform.right * (__instance.Capsule + ___m_capsuleAdd), __instance.Radius + ___m_radiusAdd, ___m_shootDir, _dist, num) : Physics.SphereCastAll(_startRaycast, __instance.Radius + ___m_radiusAdd, ___m_shootDir, _dist, num)));
			if (array.Length != 0)
			{
				Character val = (Character)At.GetField<Projectile>((Projectile)(object)__instance, "m_ignoredCharacter");
				int num2 = -1;
				for (int i = 0; i < array.Length; i++)
				{
					Character characterOwner = UnityEngineExtensions.GetCharacterOwner(((RaycastHit)(ref array[i])).collider);
					if (!(((EffectSynchronizer)__instance).OwnerCharacter.UID != characterOwner.UID))
					{
						continue;
					}
					bool flag = (Object)(object)characterOwner == (Object)null && !__instance.HitTargetOnly;
					if (!flag)
					{
						flag = !__instance.HitTargetOnly || (Object.op_Implicit((Object)(object)___m_homingTarget) && (Object)(object)characterOwner == (Object)(object)___m_homingTarget.OwnerChar);
						flag &= (Object)(object)characterOwner != (Object)(object)val;
						flag &= !___m_hitCharList.Contains(characterOwner) || (!__instance.MultiTarget && (int)((Projectile)__instance).EndMode == 0);
					}
					if (!flag)
					{
						continue;
					}
					if (((RaycastHit)(ref array[i])).point == Vector3.zero)
					{
						((RaycastHit)(ref array[i])).point = ((Component)__instance).transform.position;
					}
					if (num2 != -1)
					{
						Vector3 val2 = _startRaycast - ((RaycastHit)(ref array[i])).point;
						float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
						val2 = _startRaycast - ((RaycastHit)(ref array[num2])).point;
						if (!(sqrMagnitude < ((Vector3)(ref val2)).sqrMagnitude))
						{
							continue;
						}
					}
					if (Object.op_Implicit((Object)(object)characterOwner))
					{
						___m_hitCharList.Add(characterOwner);
					}
					num2 = i;
				}
				if (num2 != -1)
				{
					_hit = array[num2];
					__result = true;
					return false;
				}
			}
			__result = false;
			return false;
		}

		private static int RaycastHitLayerMask(RaycastProjectile __instance)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			if (((Projectile)__instance).OnlyExplodeOnLayers)
			{
				return LayerMask.op_Implicit(((Projectile)__instance).ExplodeOnContactWithLayers);
			}
			if ((int)__instance.HitLayer == 2)
			{
				return Global.ProjectileHitAllMask;
			}
			if ((int)__instance.HitLayer == 0)
			{
				return Global.ProjectileHitMeleeMask;
			}
			return Global.ProjectileHitRangedMask;
		}
	}

	public static bool OrigIsTargetable(TargetingSystem instance, Character _character)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		Factions faction = _character.Faction;
		for (int num = instance.TargetableFactions.Length - 1; num >= 0; num--)
		{
			if (((Enum)(Factions)(ref instance.TargetableFactions[num])).CompareTo((object?)faction) == 0)
			{
				return true;
			}
		}
		return false;
	}
}
public class PlayerManager : MonoBehaviour
{
	[HarmonyPatch(typeof(DeployableTrap), "ProcessEffect")]
	public class DeployableTrap_ProcessEffect
	{
		[HarmonyPrefix]
		public static bool Prefix(DeployableTrap __instance, Effect _effect)
		{
			Shooter val = (Shooter)(object)((_effect is Shooter) ? _effect : null);
			if (val != null && PvP.Instance.CurrentGame == PvP.GameModes.BattleRoyale)
			{
				val.Setup(Instance.AllFactions.ToArray(), (!((Object)(object)__instance.FX_HolderTrans != (Object)null)) ? ((Component)__instance).transform : __instance.FX_HolderTrans);
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(TrapTrigger), "OnTriggerEnter")]
	public class TrapTrigger_OnTriggerEnter
	{
		[HarmonyPrefix]
		public static bool Prefix(TrapTrigger __instance, Collider _other)
		{
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected I4, but got Unknown
			if ((Object)(object)_other == (Object)null)
			{
				return true;
			}
			if (PvP.Instance.CurrentGame != 0)
			{
				DeployableTrap componentInParent = ((Component)__instance).GetComponentInParent<DeployableTrap>();
				if (componentInParent != null)
				{
					At.SetField<DeployableTrap>(componentInParent, "m_targetFactions", (object)Instance.AllFactions.ToArray());
				}
				List<Character> list = At.GetField<TrapTrigger>(__instance, "m_charactersInTrigger") as List<Character>;
				Character component = ((Component)_other).GetComponent<Character>();
				if ((Object)(object)component != (Object)null && !list.Contains(component))
				{
					list.Add(component);
					if (!(bool)At.GetField<TrapTrigger>(__instance, "m_alreadyTriggered"))
					{
						((TriggerColliderFlag)__instance).Trigger.ActivateBasicAction(component, __instance.OnEnterState - 1);
					}
					At.SetField<TrapTrigger>(__instance, "m_alreadyTriggered", (object)true);
				}
				return false;
			}
			return true;
		}
	}

	public static PlayerManager Instance;

	public List<Factions> AllFactions;

	internal void Awake()
	{
		Instance = this;
		AllFactions = new List<Factions>();
		for (int i = 0; i < 10; i++)
		{
			AllFactions.Add((Factions)i);
		}
	}

	public void ChangeFactions(Character c, Factions faction)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected I4, but got Unknown
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		PhotonView photonView = ((MonoBehaviour)RPCManager.Instance).photonView;
		object[] obj = new object[3]
		{
			(int)faction,
			null,
			null
		};
		UID uID = c.UID;
		obj[1] = ((object)(UID)(ref uID)).ToString();
		obj[2] = true;
		photonView.RPC("SendChangeFactionsRPC", (PhotonTargets)0, obj);
	}

	public List<Factions> GetRemainingTeams()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		List<Factions> list = new List<Factions>();
		foreach (KeyValuePair<Factions, List<PlayerSystem>> currentPlayer in PvP.Instance.CurrentPlayers)
		{
			if ((int)currentPlayer.Key == 0)
			{
				continue;
			}
			bool flag = false;
			foreach (PlayerSystem item in currentPlayer.Value)
			{
				if ((Object)(object)item.ControlledCharacter != (Object)null && !item.ControlledCharacter.IsDead)
				{
					flag = true;
					break;
				}
			}
			if (flag)
			{
				list.Add(currentPlayer.Key);
			}
		}
		return list;
	}

	public List<Character> GetRemainingPlayers()
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		List<Character> list = new List<Character>();
		foreach (KeyValuePair<Factions, List<PlayerSystem>> currentPlayer in PvP.Instance.CurrentPlayers)
		{
			foreach (PlayerSystem item in PvP.Instance.CurrentPlayers[currentPlayer.Key])
			{
				if ((Object)(object)item.ControlledCharacter != (Object)null && !item.ControlledCharacter.IsDead)
				{
					list.Add(item.ControlledCharacter);
				}
			}
		}
		return list;
	}
}
[BepInPlugin("com.sinai.pvp", "PvP", "2.6.0")]
public class PvP : BaseUnityPlugin
{
	public enum GameModes
	{
		NONE,
		Deathmatch,
		BattleRoyale
	}

	[HarmonyPatch(typeof(InteractionRevive), "OnActivate")]
	public class InteractionRevive_OnActivate
	{
		[HarmonyPrefix]
		public static bool Prefix(InteractionRevive __instance)
		{
			if (Instance.CurrentGame == GameModes.NONE)
			{
				return true;
			}
			object field = At.GetField<InteractionBase>((InteractionBase)(object)__instance, "m_lastCharacter");
			Character val = (Character)((field is Character) ? field : null);
			if (val != null && val.IsLocalPlayer)
			{
				RPCManager.Instance.SendUIMessageLocal(val, "You cannot revive players during a game!");
				((MonoBehaviour)Instance).StartCoroutine(Instance.FixReviveInteraction((InteractionBase)(object)__instance, ((InteractionBase)__instance).OnActivationEvent));
				((InteractionBase)__instance).OnActivationEvent = null;
			}
			return false;
		}
	}

	[HarmonyPatch(typeof(InteractionRevive), "ProcessText")]
	public class InteractionRevive_ProcessText
	{
		[HarmonyPostfix]
		public static void Postfix(ref string __result)
		{
			if (Instance.CurrentGame != 0)
			{
				__result = "";
			}
		}
	}

	public const string GUID = "com.sinai.pvp";

	public const string NAME = "PvP";

	public const string VERSION = "2.6.0";

	public static PvP Instance;

	private const string MenuKey = "PvP Menu";

	public static ConfigEntry<bool> Show_Menu_On_Startup;

	public static ConfigEntry<bool> Enable_Menu_Scaling;

	public GameModes CurrentGame = GameModes.NONE;

	public float GameStartTime = 0f;

	public Dictionary<Factions, List<PlayerSystem>> CurrentPlayers = new Dictionary<Factions, List<PlayerSystem>>();

	public bool FriendlyFireEnabled;

	public bool FriendlyTargetingEnabled;

	public bool EnemiesDisabled;

	internal void Awake()
	{
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Expected O, but got Unknown
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Expected O, but got Unknown
		Instance = this;
		CustomKeybindings.AddAction("PvP Menu", (KeybindingsCategory)0, (ControlType)0, (InputType)1);
		Show_Menu_On_Startup = ((BaseUnityPlugin)this).Config.Bind<bool>("PvP", "Show Menu On startup", true, "Show the PvP menu on game startup.");
		Enable_Menu_Scaling = ((BaseUnityPlugin)this).Config.Bind<bool>("PvP", "Enable Menu Scaling", true, "Attempts to scale the menu to your screen resolution");
		SceneManager.activeSceneChanged += SceneManager_activeSceneChanged;
		Harmony val = new Harmony("com.sinai.pvp");
		val.PatchAll();
		GameObject val2 = new GameObject("PvP");
		Object.DontDestroyOnLoad((Object)(object)val2);
		val2.AddComponent<RPCManager>();
		PhotonView val3 = val2.AddComponent<PhotonView>();
		val3.viewID = 998;
		Debug.Log((object)("Registered PvP with ViewID " + val3.viewID));
		val2.AddComponent<PvPGUI>();
		val2.AddComponent<PlayerManager>();
		val2.AddComponent<BattleRoyale>();
		val2.AddComponent<DeathMatch>();
	}

	private void SceneManager_activeSceneChanged(Scene arg0, Scene arg1)
	{
		string text = SceneManagerHelper.ActiveSceneName.ToLower();
		if (!text.Contains("lowmemory") && !text.Contains("mainmenu"))
		{
			((MonoBehaviour)Instance).StartCoroutine(OnSceneChange());
		}
	}

	private IEnumerator OnSceneChange()
	{
		while (NetworkLevelLoader.Instance.IsGameplayLoading || !NetworkLevelLoader.Instance.AllPlayerDoneLoading)
		{
			yield return (object)new WaitForSeconds(0.3f);
		}
		if (EnemiesDisabled)
		{
			SetEnemiesActive(active: false);
		}
	}

	public static void SetEnemiesActive(bool active)
	{
		Instance.EnemiesDisabled = !active;
		((Component)AISquadManager.Instance).gameObject.SetActive(active);
	}

	internal void Update()
	{
		if ((MenuManager.Instance.IsReturningToMainMenu || Global.IsApplicationClosing) && CurrentGame != 0)
		{
			CurrentGame = GameModes.NONE;
			if (!PhotonNetwork.isNonMasterClientInRoom)
			{
				StopGameplay("The host has left the game!");
			}
		}
		if (CustomKeybindings.GetKeyDown("PvP Menu"))
		{
			PvPGUI.Instance.ShowGUI = !PvPGUI.Instance.ShowGUI;
		}
		if (Global.Lobby.PlayersInLobbyCount >= 1 && !NetworkLevelLoader.Instance.IsGameplayPaused && CurrentGame != 0)
		{
			UpdateGameplay();
		}
	}

	public void StartGameplay(int _mode, string messageToPlayers = "")
	{
		CurrentGame = (GameModes)_mode;
		((MonoBehaviour)RPCManager.Instance).photonView.RPC("StartGameplayRPC", (PhotonTargets)0, new object[2] { _mode, messageToPlayers });
	}

	public void StopGameplay(string messageToPlayers = "")
	{
		((MonoBehaviour)RPCManager.Instance).photonView.RPC("StopGameplayRPC", (PhotonTargets)0, new object[1] { messageToPlayers });
	}

	private void UpdateGameplay()
	{
		if (CurrentGame != GameModes.BattleRoyale && CurrentGame == GameModes.Deathmatch)
		{
			DeathMatch.Instance.UpdateDM();
		}
	}

	private IEnumerator FixReviveInteraction(InteractionBase _base, UnityAction action)
	{
		yield return (object)new WaitForSeconds(0.1f);
		_base.OnActivationEvent = action;
	}
}
public class PvPGUI : MonoBehaviour
{
	public static PvPGUI Instance;

	private static readonly int WINDOW_ID = 6313531;

	public Rect m_windowRect = Rect.zero;

	public Vector2 scroll = Vector2.zero;

	private Vector2 m_virtualSize = new Vector2(1920f, 1080f);

	private Vector2 m_currentSize = Vector2.zero;

	public Matrix4x4 m_scaledMatrix;

	private bool m_showGUI;

	public int guiPage = 0;

	public bool lastMenuToggle;

	public bool ConfirmingBattleRoyale = false;

	public Dictionary<Factions, Color> TeamColors = new Dictionary<Factions, Color>
	{
		{
			(Factions)0,
			Color.white
		},
		{
			(Factions)1,
			Color.green
		},
		{
			(Factions)2,
			Color.red * 2f
		},
		{
			(Factions)3,
			Color.cyan * Color.grey
		},
		{
			(Factions)4,
			Color.magenta
		},
		{
			(Factions)5,
			new Color(0.8f, 0.3f, 0.3f)
		},
		{
			(Factions)6,
			new Color(0.3f, 0.3f, 1f)
		},
		{
			(Factions)7,
			Color.gray
		},
		{
			(Factions)8,
			Color.yellow
		}
	};

	public bool ShowGUI
	{
		get
		{
			return m_showGUI;
		}
		set
		{
			m_showGUI = value;
			if (m_showGUI)
			{
				ForceUnlockCursor.AddUnlockSource();
			}
			else
			{
				ForceUnlockCursor.RemoveUnlockSource();
			}
		}
	}

	internal void Awake()
	{
		Instance = this;
	}

	internal void Start()
	{
		ShowGUI = PvP.Show_Menu_On_Startup.Value;
	}

	internal void Update()
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		if (m_currentSize.x != (float)Screen.width || m_currentSize.y != (float)Screen.height)
		{
			m_scaledMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3((float)Screen.width / m_virtualSize.x, (float)Screen.height / m_virtualSize.y, 1f));
			m_currentSize = new Vector2((float)Screen.width, (float)Screen.height);
		}
		if (!NetworkLevelLoader.Instance.IsGameplayPaused && Global.Lobby.PlayersInLobbyCount > 0)
		{
		}
	}

	internal void OnGUI()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Expected O, but got Unknown
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Expected O, but got Unknown
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Expected O, but got Unknown
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		GUISkin skin = GUI.skin;
		GUI.skin = UIStyles.WindowSkin;
		Matrix4x4 matrix = GUI.matrix;
		if (PvP.Enable_Menu_Scaling.Value)
		{
			GUI.matrix = m_scaledMatrix;
		}
		if (!(m_windowRect == Rect.zero))
		{
			_ = m_windowRect;
			if (0 == 0)
			{
				goto IL_0072;
			}
		}
		m_windowRect = new Rect(50f, 50f, 500f, 300f);
		goto IL_0072;
		IL_0072:
		if (!ConfirmingBattleRoyale && ShowGUI)
		{
			m_windowRect = GUI.Window(WINDOW_ID, m_windowRect, new WindowFunction(DrawWindow), "PvP 2.6.0");
		}
		else if (ConfirmingBattleRoyale || BattleRoyale.Instance.IsGameplayEnding)
		{
			float num = Screen.width / 2 - 200;
			float num2 = ((Global.Lobby.LocalPlayerCount <= 1) ? ((float)(Screen.height / 2 - 150)) : ((float)(Screen.height / 4 - 150)));
			if (ConfirmingBattleRoyale)
			{
				GUI.Window(WINDOW_ID, new Rect(num, num2, 400f, 250f), new WindowFunction(BattleRoyaleConfirmStart), "Are you sure?");
			}
			else if (BattleRoyale.Instance.IsGameplayEnding)
			{
				GUI.Window(WINDOW_ID, new Rect(num, num2, 400f, 150f), new WindowFunction(BattleRoyaleGameEnd), "Play again?");
			}
		}
		if (PvP.Instance.CurrentGame != 0)
		{
			CurrentGameWindow();
		}
		GUI.matrix = matrix;
		GUI.skin = skin;
	}

	private void DrawWindow(int id)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref m_windowRect)).width - 50f, 20f));
		if (GUI.Button(new Rect(((Rect)(ref m_windowRect)).width - 50f, 0f, 45f, 20f), "X"))
		{
			ShowGUI = false;
		}
		GUILayout.BeginArea(new Rect(3f, 25f, ((Rect)(ref m_windowRect)).width - 8f, ((Rect)(ref m_windowRect)).height - 5f));
		GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>());
		GUILayout.Space(150f);
		if (guiPage == 0)
		{
			GUI.color = Color.green;
		}
		else
		{
			GUI.color = Color.white;
		}
		if (GUILayout.Button("Main", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }))
		{
			guiPage = 0;
		}
		if (guiPage == 1)
		{
			GUI.color = Color.green;
		}
		else
		{
			GUI.color = Color.white;
		}
		if (GUILayout.Button("Settings", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }))
		{
			guiPage = 1;
		}
		GUI.color = Color.white;
		GUILayout.EndHorizontal();
		GUI.skin.box.alignment = (TextAnchor)0;
		scroll = GUILayout.BeginScrollView(scroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(((Rect)(ref m_windowRect)).height - 70f) });
		switch (guiPage)
		{
		case 0:
			MainPage();
			break;
		case 1:
			SettingsPage();
			break;
		}
		GUILayout.EndScrollView();
		GUILayout.EndArea();
	}

	private void MainPage()
	{
		//IL_028c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0291: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_035f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_050f: Unknown result type (might be due to invalid IL or missing references)
		//IL_042c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0432: Invalid comparison between Unknown and I4
		//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_03af: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0476: Unknown result type (might be due to invalid IL or missing references)
		//IL_047c: Unknown result type (might be due to invalid IL or missing references)
		//IL_047d: Unknown result type (might be due to invalid IL or missing references)
		//IL_048b: Unknown result type (might be due to invalid IL or missing references)
		if (Global.Lobby.PlayersInLobbyCount > 0 && !NetworkLevelLoader.Instance.IsGameplayPaused)
		{
			if (!PhotonNetwork.isNonMasterClientInRoom)
			{
				if (PvP.Instance.CurrentGame == PvP.GameModes.NONE)
				{
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					if (GUILayout.Button("Begin Deathmatch", Array.Empty<GUILayoutOption>()))
					{
						PvP.Instance.StartGameplay(1, "A Deathmatch has begun!");
					}
					if (GUILayout.Button("Begin Battle Royale", Array.Empty<GUILayoutOption>()))
					{
						ConfirmingBattleRoyale = true;
					}
					GUILayout.EndHorizontal();
				}
				else if (GUILayout.Button("End Gameplay", Array.Empty<GUILayoutOption>()))
				{
					PvP.Instance.StopGameplay("The host has ended the game.");
				}
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				if (!PvP.Instance.FriendlyFireEnabled)
				{
					GUI.color = Color.red;
					if (GUILayout.Button("Enable Friendly Fire", Array.Empty<GUILayoutOption>()))
					{
						RPCManager.SendFriendyFire(enabled: true);
					}
				}
				else
				{
					GUI.color = Color.green;
					if (GUILayout.Button("Disable Friendly Fire", Array.Empty<GUILayoutOption>()))
					{
						RPCManager.SendFriendyFire(enabled: false);
					}
					if (!PvP.Instance.FriendlyTargetingEnabled)
					{
						GUI.color = Color.red;
						if (GUILayout.Button("Enable Friendly Targeting", Array.Empty<GUILayoutOption>()))
						{
							RPCManager.SendFriendyTargeting(enabled: true);
						}
					}
					else if (GUILayout.Button("Disable Friendly Targeting", Array.Empty<GUILayoutOption>()))
					{
						RPCManager.SendFriendyTargeting(enabled: false);
					}
				}
				if (!PvP.Instance.EnemiesDisabled)
				{
					GUI.color = Color.green;
					if (GUILayout.Button("Disable Enemies", Array.Empty<GUILayoutOption>()))
					{
						RPCManager.SendSetEnemiesActive(active: false);
					}
				}
				else
				{
					GUI.color = Color.red;
					if (GUILayout.Button("Enable Enemies", Array.Empty<GUILayoutOption>()))
					{
						RPCManager.SendSetEnemiesActive(active: true);
					}
				}
				GUILayout.EndHorizontal();
				GUI.color = Color.white;
			}
			GUILayout.Label("Characters: ", Array.Empty<GUILayoutOption>());
			{
				foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
				{
					if (!item.ControlledCharacter.Initialized)
					{
						continue;
					}
					GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>());
					GUI.skin.label.wordWrap = false;
					GUI.color = TeamColors[item.ControlledCharacter.Faction];
					string name = item.ControlledCharacter.Name;
					name = (item.ControlledCharacter.IsWorldHost ? (name + " [Host]") : ((!item.ControlledCharacter.IsLocalPlayer) ? (name + " [Online]") : (name + " [Local]")));
					GUILayout.Label(name, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) });
					GUILayout.Label("Team: ", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) });
					if (!PhotonNetwork.isNonMasterClientInRoom || item.ControlledCharacter.IsLocalPlayer)
					{
						if ((int)item.ControlledCharacter.Faction != 0 && PvP.Instance.CurrentGame == PvP.GameModes.NONE)
						{
							if (GUILayout.Button("<", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }))
							{
								Factions faction = (Factions)(item.ControlledCharacter.Faction - 1);
								PlayerManager.Instance.ChangeFactions(item.ControlledCharacter, faction);
							}
						}
						else
						{
							GUILayout.Space(35f);
						}
					}
					GUILayout.Label(((object)(Factions)(ref item.ControlledCharacter.Faction)).ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) });
					if (!PhotonNetwork.isNonMasterClientInRoom || item.ControlledCharacter.IsLocalPlayer)
					{
						if ((int)item.ControlledCharacter.Faction != 8 && PvP.Instance.CurrentGame == PvP.GameModes.NONE)
						{
							if (GUILayout.Button(">", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }))
							{
								Factions faction2 = (Factions)(item.ControlledCharacter.Faction + 1);
								PlayerManager.Instance.ChangeFactions(item.ControlledCharacter, faction2);
							}
						}
						else
						{
							GUILayout.Space(35f);
						}
						if (item.ControlledCharacter.IsDead && PvP.Instance.CurrentGame == PvP.GameModes.NONE && GUILayout.Button("Resurrect", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(75f) }))
						{
							RPCManager.Instance.SendResurrect(item.ControlledCharacter);
						}
					}
					GUI.skin.label.wordWrap = true;
					GUI.color = Color.white;
					GUILayout.EndHorizontal();
				}
				return;
			}
		}
		GUILayout.Label("Load up a character to begin...", Array.Empty<GUILayoutOption>());
	}

	private void SettingsPage()
	{
		GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
		PvP.Show_Menu_On_Startup.Value = GUILayout.Toggle(PvP.Show_Menu_On_Startup.Value, "Show Menu On Startup", Array.Empty<GUILayoutOption>());
		PvP.Enable_Menu_Scaling.Value = GUILayout.Toggle(PvP.Enable_Menu_Scaling.Value, "Enable Menu Scaling", Array.Empty<GUILayoutOption>());
		GUILayout.Space(15f);
		GUILayout.EndVertical();
	}

	private void BattleRoyaleConfirmStart(int windowID)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		GUI.DragWindow(new Rect(0f, 0f, 400f, 20f));
		GUILayout.BeginArea(new Rect(15f, 25f, 370f, 350f));
		GUI.skin.label.alignment = (TextAnchor)4;
		string text = "Are you sure you want to start a Battle Royale?";
		if (SceneManagerHelper.ActiveSceneName != "Monsoon")
		{
			text += "\r\n\r\nThis will teleport all players to Monsoon.";
		}
		GUILayout.Label(text, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(370f) });
		GUILayout.Label("<b><color=red>WARNING:</color> This will WIPE the character save and you will need to manually restore your save from a backup if you wish to restore it for this character.\r\n\r\nIt is highly recommended to use a fresh character for Battle Royale so that you don't care if it gets wiped.</b>", Array.Empty<GUILayoutOption>());
		GUILayout.Space(20f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("No, go back!", Array.Empty<GUILayoutOption>()))
		{
			ConfirmingBattleRoyale = false;
		}
		GUILayout.Space(30f);
		if (GUILayout.Button("Yes, I'm sure!", Array.Empty<GUILayoutOption>()))
		{
			ConfirmingBattleRoyale = false;
			ShowGUI = false;
			if (BattleRoyale.Instance.CheckCanStart())
			{
				BattleRoyale.Instance.StartBattleRoyale();
			}
			else
			{
				RPCManager.Instance.SendUIMessageLocal(CharacterManager.Instance.GetFirstLocalCharacter(), "There are not enough teams to start!");
			}
		}
		GUILayout.EndHorizontal();
		GUILayout.EndArea();
	}

	private void BattleRoyaleGameEnd(int windowID)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		GUI.DragWindow(new Rect(0f, 0f, 400f, 20f));
		GUILayout.BeginArea(new Rect(15f, 65f, 370f, 350f));
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Play Again", Array.Empty<GUILayoutOption>()))
		{
			BattleRoyale.Instance.StartBattleRoyale(skipLoad: true);
			BattleRoyale.Instance.IsGameplayEnding = false;
			ShowGUI = false;
		}
		GUILayout.Space(30f);
		if (GUILayout.Button("End Lobby", Array.Empty<GUILayoutOption>()))
		{
			BattleRoyale.Instance.IsGameplayEnding = false;
			ShowGUI = false;
			((MonoBehaviour)RPCManager.Instance).photonView.RPC("EndBattleRoyaleRPC", (PhotonTargets)0, new object[0]);
		}
		GUILayout.EndHorizontal();
		GUILayout.EndArea();
	}

	private void CurrentGameWindow()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Invalid comparison between Unknown and I4
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.BeginArea(new Rect(15f, 15f, 240f, (float)Screen.height * 0.7f));
		if (PvP.Instance.CurrentGame == PvP.GameModes.BattleRoyale && BattleRoyale.Instance.IsGameplayStarting)
		{
			GUILayout.Label("A Battle Royale is starting...", Array.Empty<GUILayoutOption>());
		}
		else
		{
			GUIStyle label = GUI.skin.label;
			label.fontSize *= 2;
			TimeSpan timeSpan = TimeSpan.FromSeconds(Time.time - PvP.Instance.GameStartTime);
			GUILayout.Label(timeSpan.Minutes.ToString("0") + ":" + timeSpan.Seconds.ToString("00"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) });
			GUIStyle label2 = GUI.skin.label;
			label2.fontSize /= 2;
			GUILayout.Label("Current Teams:", Array.Empty<GUILayoutOption>());
			foreach (KeyValuePair<Factions, List<PlayerSystem>> currentPlayer in PvP.Instance.CurrentPlayers)
			{
				if ((int)currentPlayer.Key == 0)
				{
					continue;
				}
				GUI.color = TeamColors[currentPlayer.Key];
				Factions key = currentPlayer.Key;
				GUILayout.Label(((object)(Factions)(ref key)).ToString() + ":", Array.Empty<GUILayoutOption>());
				GUI.color = Color.white;
				foreach (PlayerSystem item in currentPlayer.Value)
				{
					if (item.ControlledCharacter.IsDead)
					{
						GUI.color = Color.black;
						GUILayout.Label(" - " + item.ControlledCharacter.Name + " (DEAD)", Array.Empty<GUILayoutOption>());
						continue;
					}
					GUILayout.Label(" - " + item.ControlledCharacter.Name + " (" + Math.Round((decimal)item.ControlledCharacter.Stats.CurrentHealth) + " / " + item.ControlledCharacter.Stats.MaxHealth + ")", Array.Empty<GUILayoutOption>());
				}
			}
		}
		GUILayout.EndArea();
	}
}
public class UIStyles
{
	private static GUISkin _customSkin;

	public static Texture2D m_nofocusTex;

	public static Texture2D m_focusTex;

	private static GUIStyle _horizBarStyle;

	public static GUISkin WindowSkin
	{
		get
		{
			if ((Object)(object)_customSkin == (Object)null)
			{
				try
				{
					_customSkin = CreateWindowSkin();
				}
				catch
				{
					_customSkin = GUI.skin;
				}
			}
			return _customSkin;
		}
	}

	private static GUIStyle HorizontalBar
	{
		get
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			if (_horizBarStyle == null)
			{
				_horizBarStyle = new GUIStyle();
				_horizBarStyle.normal.background = Texture2D.whiteTexture;
				_horizBarStyle.margin = new RectOffset(0, 0, 4, 4);
				_horizBarStyle.fixedHeight = 2f;
			}
			return _horizBarStyle;
		}
	}

	public static void HorizontalLine(Color color)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		Color color2 = GUI.color;
		GUI.color = color;
		GUILayout.Box(GUIContent.none, HorizontalBar, Array.Empty<GUILayoutOption>());
		GUI.color = color2;
	}

	private static GUISkin CreateWindowSkin()
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		GUISkin val = Object.Instantiate<GUISkin>(GUI.skin);
		Object.DontDestroyOnLoad((Object)(object)val);
		m_nofocusTex = MakeTex(550, 700, new Color(0.1f, 0.1f, 0.1f, 0.7f));
		m_focusTex = MakeTex(550, 700, new Color(0.3f, 0.3f, 0.3f, 1f));
		val.window.normal.background = m_nofocusTex;
		val.window.onNormal.background = m_focusTex;
		val.box.normal.textColor = Color.white;
		val.window.normal.textColor = Color.white;
		val.button.normal.textColor = Color.white;
		val.textField.normal.textColor = Color.white;
		val.label.normal.textColor = Color.white;
		return val;
	}

	public static Texture2D MakeTex(int width, int height, Color col)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		Color[] array = (Color[])(object)new Color[width * height];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = col;
		}
		Texture2D val = new Texture2D(width, height);
		val.SetPixels(array);
		val.Apply();
		return val;
	}
}
public class RPCManager : MonoBehaviour
{
	public static RPCManager Instance;

	internal void Awake()
	{
		Instance = this;
	}

	public static void SendSetEnemiesActive(bool active)
	{
		if (!PhotonNetwork.isNonMasterClientInRoom)
		{
			((MonoBehaviour)Instance).photonView.RPC("RPCSetEnemiesActive", (PhotonTargets)0, new object[1] { active });
		}
	}

	[PunRPC]
	private void RPCSetEnemiesActive(bool active)
	{
		PvP.SetEnemiesActive(active);
	}

	public static void SendSetPlayerActive(string uid, bool active)
	{
		((MonoBehaviour)Instance).photonView.RPC("RPCSetPlayerActive", (PhotonTargets)0, new object[2] { uid, active });
	}

	[PunRPC]
	private void RPCSetPlayerActive(string uid, bool active)
	{
		Character character = CharacterManager.Instance.GetCharacter(uid);
		if (character != null)
		{
			((Component)character).gameObject.SetActive(active);
		}
	}

	public static void SendFriendyFire(bool enabled)
	{
		SendMessageToAll((enabled ? "Enabling" : "Disabling") + " Friendly Fire!");
		((MonoBehaviour)Instance).photonView.RPC("SendFriendlyFireRPC", (PhotonTargets)0, new object[1] { enabled });
	}

	[PunRPC]
	private void SendFriendlyFireRPC(bool enabled)
	{
		PvP.Instance.FriendlyFireEnabled = enabled;
	}

	public static void SendFriendyTargeting(bool enabled)
	{
		SendMessageToAll((enabled ? "Enabling" : "Disabling") + " Friendly Targeting!");
		((MonoBehaviour)Instance).photonView.RPC("SendFriendlyTargetingRPC", (PhotonTargets)0, new object[1] { enabled });
	}

	[PunRPC]
	private void SendFriendlyTargetingRPC(bool enabled)
	{
		PvP.Instance.FriendlyTargetingEnabled = enabled;
	}

	[PunRPC]
	public void StartGameplayRPC(int _mode, string messageToPlayers = "")
	{
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Invalid comparison between Unknown and I4
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		if (PvPGUI.Instance.ShowGUI)
		{
			PvPGUI.Instance.ShowGUI = false;
		}
		if (_mode == 2)
		{
			BattleRoyale.Instance.IsGameplayStarting = false;
			BattleRoyale.Instance.LastSupplyDropTime = -1f;
			BattleRoyale.Instance.LastEnemySpawnTime = Time.time;
			BattleRoyale.Instance.SupplyDropCounter = 0;
			BattleRoyale.Instance.ActiveItemContainers.Clear();
			BattleRoyale.Instance.ActiveBeamObjects.Clear();
		}
		PvP.Instance.CurrentPlayers.Clear();
		foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
		{
			if ((int)item.ControlledCharacter.Faction == 0)
			{
				if (item.IsLocalPlayer)
				{
					((Component)item).gameObject.AddComponent<Spectate>();
				}
				continue;
			}
			if (PvP.Instance.CurrentPlayers.ContainsKey(item.ControlledCharacter.Faction))
			{
				PvP.Instance.CurrentPlayers[item.ControlledCharacter.Faction].Add(item);
			}
			else
			{
				PvP.Instance.CurrentPlayers.Add(item.ControlledCharacter.Faction, new List<PlayerSystem> { item });
			}
			if (item.ControlledCharacter.IsLocalPlayer)
			{
				Instance.SendUIMessageLocal(item.ControlledCharacter, messageToPlayers);
			}
		}
		PvP.Instance.CurrentGame = (PvP.GameModes)_mode;
		PvP.Instance.GameStartTime = Time.time;
	}

	[PunRPC]
	public void StopGameplayRPC(string messageToPlayers = "")
	{
		if (PvP.Instance.CurrentGame == PvP.GameModes.BattleRoyale)
		{
			BattleRoyale.Instance.EndBattleRoyale();
		}
		PvP.Instance.CurrentGame = PvP.GameModes.NONE;
		List<PlayerSystem> list = Global.Lobby.PlayersInLobby;
		if (PhotonNetwork.isNonMasterClientInRoom)
		{
			list = list.Where((PlayerSystem x) => (Object)(object)x.ControlledCharacter != (Object)null && x.ControlledCharacter.IsLocalPlayer).ToList();
		}
		foreach (PlayerSystem item in list)
		{
			((Component)item).GetComponent<Spectate>()?.EndSpectate();
			if (messageToPlayers != "" && (Object)(object)item.ControlledCharacter != (Object)null && item.ControlledCharacter.IsLocalPlayer)
			{
				Instance.SendUIMessageLocal(item.ControlledCharacter, messageToPlayers);
			}
			if (!PhotonNetwork.isNonMasterClientInRoom && (Object)(object)item.ControlledCharacter != (Object)null && item.ControlledCharacter.IsDead)
			{
				Instance.SendResurrect(item.ControlledCharacter);
			}
		}
	}

	public static void SendMessageToAll(string message)
	{
		((MonoBehaviour)Instance).photonView.RPC("SendMessageToAllRPC", (PhotonTargets)0, new object[1] { message });
	}

	[PunRPC]
	private void SendMessageToAllRPC(string message)
	{
		foreach (PlayerSystem item in Global.Lobby.PlayersInLobby.Where((PlayerSystem x) => x.ControlledCharacter.IsLocalPlayer))
		{
			SendUIMessageLocal(item.ControlledCharacter, message);
		}
	}

	public void SendUIMessageLocal(Character c, string message)
	{
		c.CharacterUI.NotificationPanel.ShowNotification(message, 5f);
	}

	[PunRPC]
	public void SendChangeFactionsRPC(int factionInt, string UID, bool alliedToSame = true)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		Character character = CharacterManager.Instance.GetCharacter(UID);
		if (character != null)
		{
			Factions faction = (Factions)factionInt;
			character.Faction = faction;
			character.DetectabilityEmitter.Faction = faction;
			List<Factions> list = PlayerManager.Instance.AllFactions.Where((Factions x) => x != faction).ToList();
			character.TargetingSystem.TargetableFactions = list.ToArray();
			if (!alliedToSame)
			{
				character.TargetingSystem.AlliedToSameFaction = false;
			}
			else
			{
				character.TargetingSystem.AlliedToSameFaction = true;
			}
		}
	}

	public void SendResurrect(Character _character)
	{
		if (!PhotonNetwork.offlineMode)
		{
			((MonoBehaviour)_character).photonView.RPC("SendResurrect", (PhotonTargets)0, new object[3]
			{
				true,
				string.Empty,
				true
			});
		}
		else
		{
			_character.Resurrect();
		}
	}

	[PunRPC]
	public void RPCStartBattleRoyale(bool skipLoad = false)
	{
		if (SceneManagerHelper.ActiveSceneName == "Monsoon")
		{
			skipLoad = true;
		}
		BattleRoyale.Instance.IsGameplayStarting = true;
		PvP.Instance.CurrentGame = PvP.GameModes.BattleRoyale;
		if (!skipLoad)
		{
			foreach (PlayerSystem item in Global.Lobby.PlayersInLobby.Where((PlayerSystem x) => x.ControlledCharacter.IsLocalPlayer))
			{
				Character controlledCharacter = item.ControlledCharacter;
				CharacterManager.Instance.RequestAreaSwitch(controlledCharacter, AreaManager.Instance.GetAreaFromSceneName("Monsoon"), 0, 0, 1.5f, "Battle Royale!");
			}
		}
		if (Global.CheatsEnabled)
		{
			Global.CheatsEnabled = false;
			foreach (PlayerSystem item2 in Global.Lobby.PlayersInLobby.Where((PlayerSystem x) => x.ControlledCharacter.IsLocalPlayer))
			{
				Character controlledCharacter2 = item2.ControlledCharacter;
				CharacterControl characterControl = controlledCharacter2.CharacterControl;
				((LocalCharacterControl)((characterControl is LocalCharacterControl) ? characterControl : null)).MovementMultiplier = 1f;
			}
		}
		((MonoBehaviour)this).StartCoroutine(BattleRoyale.Instance.SetupAfterSceneLoad(skipLoad));
	}

	[PunRPC]
	public void SendSpawnEnemyRPC(string uid, float x, float y, float z)
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Expected O, but got Unknown
		Character val = BattleRoyale.Instance.EnemyCharacters.Find((Character w) => w.UID == UID.op_Implicit(uid));
		if (val != null)
		{
			((Component)val).gameObject.SetActive(true);
			val.Teleport(new Vector3(x, y, z), ((Component)val).transform.rotation);
			int num = 50;
			if (val.Name.ToLower().Contains("butcher"))
			{
				num = 200;
			}
			else if (((Object)val).name.ToLower().Contains("illuminator"))
			{
				num = 20;
			}
			At.SetField<CharacterStats>(val.Stats, "m_maxHealthStat", (object)new Stat((float)num));
		}
	}

	[PunRPC]
	public void EndBattleRoyaleRPC()
	{
		MenuManager.Instance.BackToMainMenu();
	}

	[PunRPC]
	public void RPCSendSupplyDrop(string itemUID, float x, float y, float z)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		((MonoBehaviour)this).StartCoroutine(BattleRoyale.Instance.SupplyDropLocalCoroutine(itemUID, new Vector3(x, y, z)));
	}

	[PunRPC]
	public void RPCSendCleanup()
	{
		BattleRoyale.Instance.CleanupSupplyObjects();
	}

	[PunRPC]
	public void RPCGenerateStash(int itemID, string UID, float x, float y, float z)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		TreasureChest component = ((Component)ItemManager.Instance.GenerateItemNetwork(itemID)).GetComponent<TreasureChest>();
		((Item)component).UID = UID;
		((Item)component).SaveType = (SaveTypes)0;
		((Component)component).transform.position = new Vector3(x, y, z);
		BattleRoyale.Instance.ActiveItemContainers.Add(((Component)component).gameObject);
	}
}
public class Spectate : MonoBehaviour
{
	private static Camera m_camera;

	private Character m_ownerCharacter;

	private Vector3 m_startPosition;

	private Character m_target;

	private int m_spectateTargetIndex;

	private bool hasTarget;

	public static Transform CameraTransform => VideoCamera.Instance.VideoCameraTrans;

	public static Camera FreeCamera
	{
		get
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)m_camera))
			{
				m_camera = (Camera)At.GetField<VideoCamera>(VideoCamera.Instance, "m_camera");
			}
			return m_camera;
		}
	}

	public Character[] AvailableTargets => PlayerManager.Instance.GetRemainingPlayers().ToArray();

	internal void Awake()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		m_ownerCharacter = ((Component)this).gameObject.GetComponent<PlayerSystem>().ControlledCharacter;
		m_startPosition = ((Component)m_ownerCharacter).transform.position;
		List<Character> list = new List<Character>();
		CharacterManager.Instance.FindCharactersInRange(((Component)m_ownerCharacter).transform.position, 10f, ref list);
		if (list.Contains(m_ownerCharacter))
		{
			list.Remove(m_ownerCharacter);
		}
		RPCManager.SendSetPlayerActive(UID.op_Implicit(m_ownerCharacter.UID), active: false);
		SetFreeCam(active: true);
		if (list.Count > 0)
		{
			SetTarget(list[0]);
		}
	}

	private void SetFreeCam(bool active)
	{
		At.Invoke<VideoCamera>(VideoCamera.Instance, "SetCameraActive", new object[1] { active });
		if (active)
		{
			At.SetField<VideoCamera>(VideoCamera.Instance, "m_flyMode", (object)true);
			Global.LockCursor(true);
		}
	}

	internal void Update()
	{
		if (Input.GetKeyDown((KeyCode)276))
		{
			CycleTarget(-1);
		}
		else if (Input.GetKeyDown((KeyCode)275))
		{
			CycleTarget(1);
		}
		else if (Input.GetKeyDown((KeyCode)273) || Input.GetKeyDown((KeyCode)274))
		{
			m_spectateTargetIndex = 0;
			ReleaseTarget();
		}
		else if (Input.GetKeyDown((KeyCode)27) && !PvPGUI.Instance.ShowGUI)
		{
			ReleaseTarget();
			PvPGUI.Instance.ShowGUI = true;
			Global.LockCursor(false);
		}
		if (hasTarget)
		{
			UpdateTarget();
		}
	}

	private void UpdateTarget()
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)m_target) || m_target.IsDead)
		{
			ReleaseTarget();
			return;
		}
		Vector3 position = ((Component)m_target).transform.position + Vector3.up * 4f + ((Component)m_target).transform.forward * -6f;
		((Component)FreeCamera).transform.position = position;
		CameraTransform.position = position;
		((Component)FreeCamera).transform.LookAt(((Component)m_target).transform);
		CameraTransform.LookAt(((Component)m_target).transform);
	}

	private void CycleTarget(int change)
	{
		if (change == -1)
		{
			if (m_spectateTargetIndex > 0)
			{
				m_spectateTargetIndex--;
			}
			else
			{
				m_spectateTargetIndex = AvailableTargets.Length - 1;
			}
		}
		else if (m_spectateTargetIndex < AvailableTargets.Length - 1)
		{
			m_spectateTargetIndex++;
		}
		else
		{
			m_spectateTargetIndex = 0;
		}
		SetTarget(AvailableTargets[m_spectateTargetIndex]);
	}

	private void SetTarget(Character target)
	{
		hasTarget = true;
		m_target = target;
		Global.LockCursor(true);
		RPCManager.Instance.SendUIMessageLocal(m_ownerCharacter, "Spectating " + target.Name);
		At.SetField<VideoCamera>(VideoCamera.Instance, "m_targetTrans", (object)((Component)target).transform);
		At.SetField<VideoCamera>(VideoCamera.Instance, "m_state", (object)(VideoCamState)2);
	}

	private void ReleaseTarget()
	{
		hasTarget = false;
		m_target = null;
		At.SetField<VideoCamera>(VideoCamera.Instance, "m_targetTrans", (object)null);
		At.SetField<VideoCamera>(VideoCamera.Instance, "m_state", (object)(VideoCamState)0);
	}

	public void EndSpectate()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		ReleaseTarget();
		SetFreeCam(active: false);
		RPCManager.SendSetPlayerActive(UID.op_Implicit(m_ownerCharacter.UID), active: true);
		m_ownerCharacter.Teleport(m_startPosition, Quaternion.identity);
		Object.Destroy((Object)(object)this);
	}
}
public static class Templates
{
	public static class BR_Templates
	{
		public static readonly Dictionary<string, float> TimeOfDayStarts = new Dictionary<string, float> { { "Monsoon", 23f } };

		public static readonly Dictionary<string, List<Vector3>> SpawnLocations = new Dictionary<string, List<Vector3>> { 
		{
			"Monsoon",
			new List<Vector3>
			{
				new Vector3(50.4f, -2.7f, 102.6f),
				new Vector3(93.9f, -6.97f, 109.1f),
				new Vector3(137.5f, 22.13f, 172.5f),
				new Vector3(91.7f, -4.37f, 195.2f),
				new Vector3(81.82f, -3.38f, 258.07f),
				new Vector3(146.4f, 9.03f, 255.2f),
				new Vector3(-11.6f, 4.78f, 276.93f),
				new Vector3(61.3f, 4.46f, 192.4f),
				new Vector3(3.04f, -0.744f, 200.03f),
				new Vector3(-15.39f, -0.37f, 146.63f),
				new Vector3(40.2f, -4.43f, 208.093f),
				new Vector3(77.34f, 4.465f, 136.96f)
			}
		} };

		public static readonly Dictionary<string, List<Vector3>> SupplyDropLocations = new Dictionary<string, List<Vector3>> { 
		{
			"Monsoon",
			new List<Vector3>
			{
				new Vector3(92.48f, -5.45f, 138.99f),
				new Vector3(-18.96f, -0.29f, 208.71f),
				new Vector3(90.05f, 4.465f, 162.2f),
				new Vector3(97.65f, 10.52f, 290.009f),
				new Vector3(121.197f, 0.182f, 232.48f),
				new Vector3(-6.46f, 11.67f, 287.92f)
			}
		} };

		public static readonly Dictionary<string, List<string>> ObjectsToDeactivate = new Dictionary<string, List<string>> { 
		{
			"Monsoon",
			new List<string> { "JesusBeam", "Tree Behavior UNPC", "Tree_Behavior_CityCheck", "Tree Behavior Teleport", "Tree_Behavior_Council", "CharactersToDesactivate", "Allies", "DialogueAutomaticGuards", "AutomaticDialogueInn", "AreaSwitchToMarsh" }
		} };

		public static readonly Dictionary<string, List<string>> ObjectsToActivate = new Dictionary<string, List<string>> { 
		{
			"Monsoon",
			new List<string> { "WarzoneMonsoon", "Ennemies" }
		} };

		public static readonly List<int> Skills_Low = new List<int>
		{
			8100090, 8100140, 8100130, 8100071, 8100101, 8100121, 8100260, 8100360, 8205350, 8205000,
			8205120, 8205050, 8205080, 8205150, 8205210
		};

		public static readonly List<int> Skills_High = new List<int>
		{
			8100020, 8100370, 8100350, 8100280, 8100200, 8200310, 8200030, 8200031, 8200032, 8200100,
			8200101, 8200102, 8200103, 8205320, 8205330
		};

		public static readonly List<int> Weapons_Low = new List<int> { 2000061, 2000110, 2000151, 2000120, 2010020, 2010040, 2010041, 2010080, 2020030 };

		public static readonly List<int> Weapons_Med = new List<int>
		{
			2000021, 2000031, 2020060, 2020110, 2020020, 2100000, 2100110, 2130000, 2130022, 2120000,
			2120030, 2140070, 2200010, 2200040
		};

		public static readonly List<int> Weapons_High = new List<int>
		{
			2000150, 2000170, 2010070, 2010130, 2010140, 2020140, 2020160, 2100100, 2100160, 2110100,
			2110110, 2120070, 2130021, 2130160, 2140120, 2140130, 2200030, 2200040, 2200020
		};

		public static readonly List<int> Offhands_Low = new List<int> { 2300120, 2300070, 2300210, 2300050 };

		public static readonly List<int> Offhands_High = new List<int> { 5110100, 5110110, 5110002, 5110004, 2300171, 2300160, 2300091, 2300220, 5100090 };

		public static readonly List<int> Armor_Low = new List<int>
		{
			3000010, 3000011, 3000012, 3000020, 3000021, 3000022, 3000030, 3000031, 3000034, 3000180,
			3000181, 3000182, 3000183, 3000184, 3000103, 3000250
		};

		public static readonly List<int> Armor_High = new List<int>
		{
			3000061, 3100120, 3100201, 3100202, 3100200, 3000103, 3000252, 3000302, 3000303, 3100010,
			3100012, 3100013, 3100040, 3100041, 3100042, 3100080, 3100081, 3100082, 3100090, 3100091,
			3100092, 3100150, 3100151, 3100152, 3100170, 3100171, 3100172
		};

		public static readonly List<int> Supplies_Low = new List<int>
		{
			4300010, 4300010, 4300010, 4300010, 4300010, 4300010, 4300010, 4300060, 4300060, 4300060,
			4300020, 4300020, 4300030, 4300030, 4300050, 4300070, 4300080, 4300100, 4300120
		};

		public static readonly List<int> Supplies_High = new List<int>
		{
			4300240, 4300240, 4300240, 4300260, 4300260, 4300260, 4300250, 4300250, 4300250, 4400070,
			4400060, 4400051, 4400041, 4400031
		};
	}

	public static readonly List<int> StarterSkills = new List<int> { 8100010, 8200040, 8100072, 8200600, 8100120, 8100190 };

	public static readonly Dictionary<int, int> Weapon_Skills = new Dictionary<int, int>
	{
		{ 0, 8100290 },
		{ 1, 8100380 },
		{ 2, 8100270 },
		{ 50, 8100320 },
		{ 51, 8100362 },
		{ 52, 8100300 },
		{ 53, 8100310 },
		{ 54, 8100340 }
	};
}

HardcoreRebalance.dll

Decompiled 2 months 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 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(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;

	public static readonly Dictionary<string, int> CraftExceptions;

	static ExceptionIDs()
	{
		StartingRecipees = new Dictionary<string, string>
		{
			["Crystal Powder"] = "-SEtMHRqWUmvrmyvryV8Ng",
			["Trinket of Elatt"] = "com.iggy.trinketrecipe",
			["Flint and Steel"] = "com.dub.flintandsteelrecipe",
			["Makeshift Hatchet"] = "com.dub.makeshifthatchetrecipe",
			["Makeshift Mining Pick"] = "com.dub.makeshiftminingpickrecipe",
			["Makeshift Fishing Harpoon"] = "com.dub.fishingharpoonrecipe",
			["Elixir of Memory Echoes"] = "4300192",
			["Sugar"] = "OE10NFgta0ulLYZCrcChnw",
			["Salt Water"] = "saltwater-recipe",
			["Racid Water clear"] = "c9nZOQ_BmUaFBmB7xEadnQ",
			["River Water clear"] = "SK6LKVhmx0CFs1-uwKJvaA",
			["charcoal"] = "com.dub.charcoal",
			["Healing Poultice"] = "com.dub.healingpoultice",
			["First Aid Tools"] = "com.dub.Firstaidtools",
			["Camping Gear"] = "com.dub.campinggear",
			["Crafting Influence"] = "com.dub.influencerecipe",
			["Crafting Fletching Feathers"] = "com.dub.fletchingfeathers"
		};
		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,
	BlessingDetermination = -59000,
	BlessingInfluence = -59001,
	BlessingTolerance = -59002
}
public enum HardcoreEffects
{
	EnemyHealing,
	Mortality,
	CombatEquiping,
	TrapAware
}
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;
		}
	}
}