Decompiled source of ColecaoDoViajante v0.39.29

ColecaoDoViajante.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ColecaoDoViajante;
using ColecaoDoViajante.Config;
using ColecaoDoViajante.Modules.AreaRespawn;
using ColecaoDoViajante.Modules.DestroyItem;
using ColecaoDoViajante.Modules.EnchantingVisualizer;
using ColecaoDoViajante.Modules.EnchantmentScrolls;
using ColecaoDoViajante.Modules.ExtraQuickSlots;
using ColecaoDoViajante.Modules.HostStash;
using ColecaoDoViajante.Modules.QuestItemGuide;
using ColecaoDoViajante.Modules.QuestRecovery;
using ColecaoDoViajante.Modules.RaidMode;
using ColecaoDoViajante.Modules.SharedPing;
using ColecaoDoViajante.Modules.SoroboreanTravel;
using ColecaoDoViajante.Modules.WindAltarGhosts;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using NodeCanvas.Framework;
using NodeCanvas.Tasks.Actions;
using Photon;
using RaidMode;
using SideLoader;
using SideLoader.Model;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("ColecaoDoViajante")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ColecaoDoViajante")]
[assembly: AssemblyTitle("ColecaoDoViajante")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RaidMode
{
	[HarmonyPatch(typeof(AreaManager), "IsCoopRestricted")]
	public class AreaManager_IsCoopRestricted
	{
		public static void Postfix(ref bool __result)
		{
			__result = false;
		}
	}
	[HarmonyPatch(typeof(WeaponLoadout), "CanBeLoaded")]
	internal static class WeaponLoadout_CanBeLoaded_AutoEquipAmmunition
	{
		private static void Prefix(WeaponLoadout __instance)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			//IL_0069: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null || (int)__instance.AmunitionType > 0)
			{
				return;
			}
			ProjectileWeapon component = ((Component)__instance).GetComponent<ProjectileWeapon>();
			Character val = (((Object)(object)component == (Object)null) ? null : ((EffectSynchronizer)component).OwnerCharacter);
			if ((Object)(object)val == (Object)null || !val.IsLocalPlayer)
			{
				return;
			}
			Ammunition equippedAmmunition = val.Inventory.GetEquippedAmmunition();
			if (!IsCompatible(equippedAmmunition, __instance.CompatibleEquipment))
			{
				Ammunition val2 = FindCompatible(val.Inventory.Pouch, __instance.CompatibleEquipment);
				if ((Object)(object)val2 == (Object)null && val.Inventory.HasABag && (Object)(object)val.Inventory.EquippedBag != (Object)null)
				{
					val2 = FindCompatible((ItemContainer)(object)val.Inventory.EquippedBag.Container, __instance.CompatibleEquipment);
				}
				if (!((Object)(object)val2 == (Object)null))
				{
					val.Inventory.EquipItem((Equipment)(object)val2, false);
					Plugin.Log.LogInfo((object)("[Atalho] Municao equipada automaticamente: " + ((Item)val2).Name));
				}
			}
		}

		private static bool IsCompatible(Ammunition ammunition, WeaponType expectedType)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			return (Object)(object)ammunition != (Object)null && ((Weapon)ammunition).Type == expectedType && ((Item)ammunition).RemainingAmount > 0;
		}

		private static Ammunition FindCompatible(ItemContainer container, WeaponType expectedType)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)container == (Object)null)
			{
				return null;
			}
			List<Ammunition> itemOfType = container.GetItemOfType<Ammunition>();
			if (itemOfType == null)
			{
				return null;
			}
			for (int i = 0; i < itemOfType.Count; i++)
			{
				if (IsCompatible(itemOfType[i], expectedType))
				{
					return itemOfType[i];
				}
			}
			return null;
		}
	}
	[HarmonyPatch(typeof(Skill), "HasAllRequirements", new Type[] { typeof(bool) })]
	internal static class Skill_HasAllRequirements_AutoEquipFlamethrower
	{
		[HarmonyPatch(typeof(Skill), "QuickSlotUse")]
		internal static class Skill_QuickSlotUse_AutoEquipFlamethrower
		{
			private static bool Prefix(Skill __instance)
			{
				if ((Object)(object)__instance == (Object)null || ((Item)__instance).ItemID != 8100090)
				{
					return true;
				}
				string text = ((Item)__instance).UID.ToString();
				if (RetryingNativeUse.Contains(text))
				{
					return true;
				}
				if (!TryEquipBestFlameSource(__instance))
				{
					return true;
				}
				if (PendingRetries.Add(text) && (Object)(object)Plugin.Instance != (Object)null)
				{
					((MonoBehaviour)Plugin.Instance).StartCoroutine(RetryAfterEquip(__instance, text));
				}
				return false;
			}
		}

		private const int FlamethrowerSkillId = 8100090;

		private const int LanternTagId = 37;

		private const int IceFlameTorchId = 5100070;

		private const int FrostburnStaffId = 2150150;

		private static readonly HashSet<string> PendingRetries = new HashSet<string>();

		private static readonly HashSet<string> RetryingNativeUse = new HashSet<string>();

		private const BindingFlags Members = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private static void Prefix(Skill __instance, bool _tryingToActivate)
		{
			if (_tryingToActivate && (Object)(object)__instance != (Object)null && ((Item)__instance).ItemID == 8100090)
			{
				TryEquipBestFlameSource(__instance);
			}
		}

		private static bool TryEquipBestFlameSource(Skill skill)
		{
			Character val = (((Object)(object)skill == (Object)null) ? null : ((EffectSynchronizer)skill).OwnerCharacter);
			if ((Object)(object)val == (Object)null || !val.IsLocalPlayer || HasFlameSourceEquipped(val))
			{
				return false;
			}
			Equipment val2 = FindBestFlameSource(val.Inventory.Pouch);
			if (val.Inventory.HasABag && (Object)(object)val.Inventory.EquippedBag != (Object)null)
			{
				Equipment val3 = FindBestFlameSource((ItemContainer)(object)val.Inventory.EquippedBag.Container);
				if ((Object)(object)val3 != (Object)null && ((Object)(object)val2 == (Object)null || GetFlamethrowerDamage((Item)(object)val3) > GetFlamethrowerDamage((Item)(object)val2)))
				{
					val2 = val3;
				}
			}
			if ((Object)(object)val2 == (Object)null)
			{
				return false;
			}
			val.Inventory.EquipItem(val2, false);
			Plugin.Log.LogInfo((object)("[Lanca-chamas] Fonte de fogo equipada automaticamente: " + ((Item)val2).Name));
			return true;
		}

		private static IEnumerator RetryAfterEquip(Skill skill, string key)
		{
			yield return null;
			yield return (object)new WaitForSeconds(0.2f);
			PendingRetries.Remove(key);
			if ((Object)(object)skill != (Object)null && (Object)(object)((EffectSynchronizer)skill).OwnerCharacter != (Object)null)
			{
				RetryingNativeUse.Add(key);
				try
				{
					((Item)skill).TryQuickSlotUse();
					yield return (object)new WaitForSeconds(0.15f);
					((Item)skill).TryQuickSlotUse();
				}
				finally
				{
					RetryingNativeUse.Remove(key);
				}
			}
		}

		private static bool HasFlameSourceEquipped(Character owner)
		{
			return IsFlameSource((Item)(object)owner.CurrentWeapon) || IsFlameSource((Item)(object)owner.LeftHandWeapon);
		}

		private static Equipment FindBestFlameSource(ItemContainer container)
		{
			if ((Object)(object)container == (Object)null)
			{
				return null;
			}
			List<Equipment> itemOfType = container.GetItemOfType<Equipment>();
			Equipment val = null;
			float num = float.MinValue;
			int num2 = 0;
			while (itemOfType != null && num2 < itemOfType.Count)
			{
				Equipment val2 = itemOfType[num2];
				if (IsFlameSource((Item)(object)val2))
				{
					float flamethrowerDamage = GetFlamethrowerDamage((Item)(object)val2);
					if ((Object)(object)val == (Object)null || flamethrowerDamage > num)
					{
						val = val2;
						num = flamethrowerDamage;
					}
				}
				num2++;
			}
			return val;
		}

		private static bool IsFlameSource(Item item)
		{
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			if (item.ItemID == 5100070 || item.ItemID == 2150150)
			{
				return true;
			}
			Equipment val = (Equipment)(object)((item is Equipment) ? item : null);
			if ((Object)(object)val != (Object)null && val.ActiveEnchantmentIDs != null)
			{
				for (int i = 0; i < val.ActiveEnchantmentIDs.Count; i++)
				{
					int num = val.ActiveEnchantmentIDs[i];
					if (num >= 18 && num <= 21)
					{
						return true;
					}
				}
			}
			try
			{
				if ((Object)(object)TagSourceManager.Instance != (Object)null && item.HasTag(TagSourceManager.Instance.GetTag(UID.op_Implicit(37.ToString()))))
				{
					return true;
				}
			}
			catch
			{
			}
			string text = item.Name ?? string.Empty;
			if (text.IndexOf("lantern", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("lanterna", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("torch", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("tocha", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return true;
			}
			Component[] components = ((Component)item).GetComponents<Component>();
			int num2 = 0;
			while (components != null && num2 < components.Length)
			{
				string text2 = (((Object)(object)components[num2] == (Object)null) ? string.Empty : ((object)components[num2]).GetType().Name);
				if (text2.IndexOf("lantern", StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf("light", StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf("torch", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return true;
				}
				num2++;
			}
			return false;
		}

		private static float GetFlamethrowerDamage(Item item)
		{
			float val = 0f;
			val = Math.Max(val, ReadDamageMembers(item));
			Component[] components = ((Component)item).GetComponents<Component>();
			int num = 0;
			while (components != null && num < components.Length)
			{
				val = Math.Max(val, ReadDamageMembers(components[num]));
				num++;
			}
			return val;
		}

		private static float ReadDamageMembers(object source)
		{
			if (source == null)
			{
				return 0f;
			}
			float num = 0f;
			Type type = source.GetType();
			FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				if (fieldInfo.Name.IndexOf("damage", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					num = Math.Max(num, ToDamageValue(fieldInfo.GetValue(source)));
				}
			}
			PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (PropertyInfo propertyInfo in properties)
			{
				if (propertyInfo.CanRead && propertyInfo.GetIndexParameters().Length == 0 && propertyInfo.Name.IndexOf("damage", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					try
					{
						num = Math.Max(num, ToDamageValue(propertyInfo.GetValue(source, null)));
					}
					catch
					{
					}
				}
			}
			return num;
		}

		private static float ToDamageValue(object value)
		{
			if (value == null)
			{
				return 0f;
			}
			if (value is float result)
			{
				return result;
			}
			if (value is double num)
			{
				return (float)num;
			}
			if (value is int num2)
			{
				return num2;
			}
			if (value is IEnumerable enumerable)
			{
				float num3 = 0f;
				foreach (object item in enumerable)
				{
					num3 += ToDamageValue(item);
				}
				return num3;
			}
			return 0f;
		}
	}
	[HarmonyPatch(typeof(Skill), "HasAllRequirements", new Type[] { typeof(bool) })]
	internal static class Skill_HasAllRequirements_AutoEquipPistol
	{
		[HarmonyPatch(typeof(Skill), "QuickSlotUse")]
		internal static class Skill_QuickSlotUse_AutoEquipPistol
		{
			private static bool Prefix(Skill __instance)
			{
				if ((Object)(object)__instance == (Object)null || ((Item)__instance).ItemID != 8200600 || !TryEquipPistol(__instance))
				{
					return true;
				}
				string text = ((Item)__instance).UID.ToString();
				if (PendingRetries.Add(text) && (Object)(object)Plugin.Instance != (Object)null)
				{
					((MonoBehaviour)Plugin.Instance).StartCoroutine(RetryAfterEquip(__instance, text));
				}
				return false;
			}
		}

		private const int FireReloadSkillId = 8200600;

		private static readonly HashSet<string> PendingRetries = new HashSet<string>();

		private static void Prefix(Skill __instance, bool _tryingToActivate)
		{
			if (_tryingToActivate && !((Object)(object)__instance == (Object)null) && ((Item)__instance).ItemID == 8200600)
			{
				TryEquipPistol(__instance);
			}
		}

		private static bool TryEquipPistol(Skill skill)
		{
			Character val = (((Object)(object)skill == (Object)null) ? null : ((EffectSynchronizer)skill).OwnerCharacter);
			if ((Object)(object)val == (Object)null || !val.IsLocalPlayer || HasPistolEquipped(val))
			{
				return false;
			}
			Weapon val2 = FindPistol(val.Inventory.Pouch);
			if ((Object)(object)val2 == (Object)null && val.Inventory.HasABag && (Object)(object)val.Inventory.EquippedBag != (Object)null)
			{
				val2 = FindPistol((ItemContainer)(object)val.Inventory.EquippedBag.Container);
			}
			if ((Object)(object)val2 == (Object)null)
			{
				return false;
			}
			val.Inventory.EquipItem((Equipment)(object)val2, false);
			Plugin.Log.LogInfo((object)("[Atirar/Recarregar] Pistola equipada automaticamente: " + ((Item)val2).Name));
			return true;
		}

		private static IEnumerator RetryAfterEquip(Skill skill, string key)
		{
			yield return (object)new WaitForSeconds(0.1f);
			PendingRetries.Remove(key);
			if ((Object)(object)skill != (Object)null && (Object)(object)((EffectSynchronizer)skill).OwnerCharacter != (Object)null && HasPistolEquipped(((EffectSynchronizer)skill).OwnerCharacter))
			{
				((Item)skill).TryQuickSlotUse();
			}
		}

		private static bool HasPistolEquipped(Character owner)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Invalid comparison between Unknown and I4
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Invalid comparison between Unknown and I4
			return ((Object)(object)owner.CurrentWeapon != (Object)null && (int)owner.CurrentWeapon.Type == 45) || ((Object)(object)owner.LeftHandWeapon != (Object)null && (int)owner.LeftHandWeapon.Type == 45);
		}

		private static Weapon FindPistol(ItemContainer container)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Invalid comparison between Unknown and I4
			if ((Object)(object)container == (Object)null)
			{
				return null;
			}
			List<Weapon> itemOfType = container.GetItemOfType<Weapon>();
			if (itemOfType == null)
			{
				return null;
			}
			for (int i = 0; i < itemOfType.Count; i++)
			{
				if ((Object)(object)itemOfType[i] != (Object)null && (int)itemOfType[i].Type == 45)
				{
					return itemOfType[i];
				}
			}
			return null;
		}
	}
	[HarmonyPatch(typeof(Character), "SlowDown")]
	public class Character_SlowDown
	{
		public static bool Prefix(Character __instance, ref float _slowVal, ref float _timeTo, ref float _timeStay, ref float _timeFrom)
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Invalid comparison between Unknown and I4
			if (RaidModeConfig.LiveSettings.DifficultyMode == RaidModeConfig.DifficultyModeSetting.NoScaling || RaidModeConfig.LiveSettings.DifficultyMode == RaidModeConfig.DifficultyModeSetting.JustVanilla)
			{
				return true;
			}
			if (RaidModeConfig.LiveSettings.DifficultyMode == RaidModeConfig.DifficultyModeSetting.Custom && RaidModeConfig.LiveSettings.SlowdownScaling)
			{
				return true;
			}
			int manualDifficultyScaling = RaidModeConfig.LiveSettings.ManualDifficultyScaling;
			int num = ((manualDifficultyScaling > 0) ? manualDifficultyScaling : Global.Lobby.PlayersInLobbyCount);
			if (num == 0)
			{
				return true;
			}
			if ((int)__instance.Faction != 1)
			{
				float num2 = ((RaidModeConfig.LiveSettings.DifficultyMode == RaidModeConfig.DifficultyModeSetting.VanillaPlus) ? 1f : 0f);
				float num3 = (1f + num2) / (float)num / (RaidModeConfig.LiveSettings.HardMode ? 2f : 1f);
				_slowVal *= num3;
				_timeTo *= num3;
				_timeStay *= num3;
				_timeFrom *= num3;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Character), "Resurrect", new Type[]
	{
		typeof(PlayerSaveData),
		typeof(bool)
	})]
	public class Character_Resurrect
	{
		public static bool Prefix(Character __instance, PlayerSaveData _resurrectState, bool _playAnim)
		{
			if (_resurrectState != null && _playAnim)
			{
				_resurrectState.BurntHealth -= __instance.ActiveMaxHealth * 0.5f;
				float num = __instance.ActiveMaxHealth * ((float)RaidModeConfig.LiveSettings.RevivalHealthBurn / 100f);
				_resurrectState.BurntHealth += num;
				float num2 = _resurrectState.Stamina * ((float)RaidModeConfig.LiveSettings.RevivalStaminaBurn / 100f);
				_resurrectState.BurntStamina += num2;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Character), "Knock")]
	public class Character_Knock
	{
		public static void Postfix(Character __instance, bool _down)
		{
			if (RaidModeConfig.LiveSettings.StabilityRework && _down && !__instance.Dodging)
			{
				__instance.StatusEffectMngr.CleanseStatusEffect("Confusion");
			}
		}
	}
	[HarmonyPatch(typeof(Character), "StabilityHit")]
	public class Character_StabilityHit
	{
		public static bool Prefix(Character __instance, float _knockValue, float _angle, bool _block, Character _dealerChar)
		{
			//IL_0503: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
			if (!RaidModeConfig.LiveSettings.StabilityRework)
			{
				return true;
			}
			float stability = __instance.m_stability;
			float num = _knockValue;
			if (__instance.IsPetrified)
			{
				num = 0f;
			}
			if (num < 0f)
			{
				num = 0f;
			}
			if (!__instance.m_impactImmune && num > 0f && !__instance.m_pendingDeath)
			{
				if (__instance.Stats.CurrentStamina < 1f)
				{
					float num2 = __instance.m_shieldStability + __instance.m_stability - 49f;
					if (num < num2)
					{
						num = num2;
					}
				}
				__instance.m_timeOfLastStabilityHit = Time.time;
				if ((Object)(object)__instance.CharacterCamera != (Object)null && num > 0f)
				{
					__instance.CharacterCamera.Hit(num * 6f);
				}
				if (_block && __instance.m_shieldStability > 0f)
				{
					if (num > __instance.m_shieldStability)
					{
						__instance.m_stability -= num - __instance.m_shieldStability;
					}
					__instance.m_shieldStability = Mathf.Clamp(__instance.m_shieldStability - num, 0f, 50f);
				}
				else
				{
					__instance.m_stability = Mathf.Clamp(__instance.m_stability - num, 0f, 100f);
				}
				if (__instance.m_stability <= 0f)
				{
					if ((!__instance.IsAI && ((MonoBehaviour)__instance).photonView.isMine) || (__instance.IsAI && ((Object)(object)_dealerChar == (Object)null || ((MonoBehaviour)_dealerChar).photonView.isMine)))
					{
						((MonoBehaviour)__instance).photonView.RPC("SendKnock", (PhotonTargets)0, new object[2] { true, __instance.m_stability });
					}
					else
					{
						__instance.Knock(true);
					}
					__instance.m_stability = 0f;
					if (__instance.IsPhotonPlayerLocal)
					{
						__instance.BlockInput(false);
					}
					((MonoBehaviour)__instance).Invoke("DelayedCheckFootStep", 0.1f);
				}
				else if (__instance.m_stability <= 50f)
				{
					if (stability > 50f && __instance.m_knockbackCount == 0f)
					{
						if ((!__instance.IsAI && ((MonoBehaviour)__instance).photonView.isMine) || (__instance.IsAI && ((Object)(object)_dealerChar == (Object)null || ((MonoBehaviour)_dealerChar).photonView.isMine)))
						{
							((MonoBehaviour)__instance).photonView.RPC("SendKnock", (PhotonTargets)0, new object[2] { false, __instance.m_stability });
						}
						else
						{
							__instance.Knock(false);
						}
					}
					else if (__instance.m_stability <= 33f && stability > 33f && __instance.m_knockbackCount <= 1f)
					{
						if ((!__instance.IsAI && ((MonoBehaviour)__instance).photonView.isMine) || (__instance.IsAI && ((Object)(object)_dealerChar == (Object)null || ((MonoBehaviour)_dealerChar).photonView.isMine)))
						{
							((MonoBehaviour)__instance).photonView.RPC("SendKnock", (PhotonTargets)0, new object[2] { false, __instance.m_stability });
						}
						else
						{
							__instance.Knock(false);
						}
					}
					else if (__instance.m_stability <= 16f && stability > 16f && __instance.m_knockbackCount <= 2f)
					{
						if ((!__instance.IsAI && ((MonoBehaviour)__instance).photonView.isMine) || (__instance.IsAI && ((Object)(object)_dealerChar == (Object)null || ((MonoBehaviour)_dealerChar).photonView.isMine)))
						{
							((MonoBehaviour)__instance).photonView.RPC("SendKnock", (PhotonTargets)0, new object[2] { false, __instance.m_stability });
						}
						else
						{
							__instance.Knock(false);
						}
					}
					if (__instance.IsPhotonPlayerLocal && _block)
					{
						__instance.BlockInput(false);
					}
				}
				else if (!_block)
				{
					if (__instance.m_knockHurtAllowed)
					{
						__instance.m_hurtType = (HurtType)0;
						if (__instance.m_currentlyChargingAttack)
						{
							__instance.CancelCharging();
						}
						__instance.m_animator.SetTrigger("Knockhurt");
						if (__instance.knockhurt != null)
						{
							((MonoBehaviour)__instance).StopCoroutine(__instance.knockhurt);
						}
						__instance.knockhurt = ((MonoBehaviour)__instance).StartCoroutine(__instance.KnockhurtRoutine(num));
					}
				}
				else
				{
					__instance.m_hurtType = (HurtType)3;
					if (__instance.InLocomotion)
					{
						__instance.m_animator.SetTrigger("BlockHit");
					}
				}
				__instance.m_animator.SetInteger("KnockAngle", (int)_angle);
				UnityAction stabilityHitCall = __instance.StabilityHitCall;
				if (stabilityHitCall != null)
				{
					stabilityHitCall.Invoke();
				}
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(CharacterBarListener), "UpdateDisplay")]
	public class CharacterBarListener_UpdateDisplay
	{
		public static void Postfix(CharacterBarListener __instance)
		{
			if (Object.op_Implicit((Object)(object)__instance.TargetCharacter) && Object.op_Implicit((Object)(object)__instance.TargetCharacter.OwnerPlayerSys) && (Object)(object)__instance.TargetCharacter != (Object)(object)((UIElement)__instance).CharacterUI.TargetCharacter && Object.op_Implicit((Object)(object)__instance.m_healthBar) && Object.op_Implicit((Object)(object)__instance.m_healthBar.m_lblValue))
			{
				__instance.m_healthBar.HideIfFull = !RaidModeConfig.LiveSettings.ShowNameplates;
				((Component)__instance.m_healthBar.m_lblValue).gameObject.SetActive(RaidModeConfig.LiveSettings.ShowNameplates || (Object.op_Implicit((Object)(object)MenuManager.Instance) && MenuManager.Instance.DisplayDebugInfo));
				if (RaidModeConfig.LiveSettings.ShowNameplates)
				{
					__instance.m_healthBar.m_lblValue.text = __instance.TargetCharacter.Name;
				}
			}
		}
	}
	[HarmonyPatch(typeof(CharacterBarListener), "UpdateVisibility")]
	public class CharacterBarListener_UpdateVisibility
	{
		public static void Postfix(CharacterBarListener __instance)
		{
			if (Object.op_Implicit((Object)(object)__instance.TargetCharacter) && Object.op_Implicit((Object)(object)__instance.TargetCharacter.OwnerPlayerSys) && (Object)(object)__instance.TargetCharacter != (Object)(object)((UIElement)__instance).CharacterUI.TargetCharacter && Object.op_Implicit((Object)(object)((UIElement)__instance).LocalCharacter) && ((UIElement)__instance).LocalCharacter.IsStartInitDone && Object.op_Implicit((Object)(object)__instance.m_targetCharacterBarManager) && Object.op_Implicit((Object)(object)((UIElement)__instance).LocalCharacter.CharacterCamera) && Object.op_Implicit((Object)(object)((UIElement)__instance).LocalCharacter.CharacterCamera.CameraScript))
			{
				__instance.m_targetCharacterBarManager.DisplayDistance = 100000f;
				if (RaidModeConfig.LiveSettings.ShowNameplates && RaidModeConfig.LiveSettings.ShowNameplatesGlobally)
				{
					__instance.m_inRange = true;
					__instance.UpdateSeenByCamera();
					__instance.m_inSight = true;
				}
				else
				{
					__instance.m_inRange = __instance.m_sqrDistanceWithLocalPlayer <= 400f;
				}
			}
		}
	}
	[HarmonyPatch(typeof(CharacterManager), "SendStartFastTravel")]
	public class CharacterManager_SendStartFastTravel
	{
		public static bool Prefix()
		{
			if (RaidModeConfig.LiveSettings.ReviveNoManLeftBehind)
			{
				foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
				{
					if (Object.op_Implicit((Object)(object)item.ControlledCharacter) && item.ControlledCharacter.IsDead)
					{
						return false;
					}
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(CharacterStats), "ApplyCoopStats")]
	public class CharacterStats_ApplyCoopStats
	{
		public static bool Prefix(CharacterStats __instance)
		{
			if (NetworkLevelLoader.Instance.IsGameplayLoading)
			{
				__instance.m_delayedApplyCoopStats = true;
				return false;
			}
			if (Object.op_Implicit((Object)(object)__instance.CoopStats))
			{
				if (!Object.op_Implicit((Object)(object)__instance.m_character))
				{
					__instance.m_character = ((Component)__instance).GetComponent<Character>();
				}
				float healthRatio = __instance.m_character.HealthRatio;
				__instance.CoopStats.ApplyToCharacter(__instance.m_character, Global.Lobby.PlayersInLobbyCount);
				__instance.m_character.Stats.UpdateStats();
				__instance.m_character.Stats.SetHealth(healthRatio * __instance.m_character.Stats.ActiveMaxHealth);
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(ConnectPhotonMaster), "CreateOrJoin")]
	public class ConnectPhotonMaster_CreateOrJoin
	{
		public static bool Prefix(string _roomName)
		{
			//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_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			PhotonNetwork.JoinOrCreateRoom(_roomName, new RoomOptions
			{
				IsVisible = true,
				MaxPlayers = (byte)RaidModeConfig.GetRoomPlayerLimit()
			}, TypedLobby.Default);
			return false;
		}
	}
	[HarmonyPatch(typeof(ConnectPhotonMaster), "CreateRoom", new Type[]
	{
		typeof(string),
		typeof(int),
		typeof(string),
		typeof(bool),
		typeof(int)
	})]
	public class ConnectPhotonMaster_CreateRoom
	{
		public static bool Prefix(string _roomName, int _storeID, string _lobbyID, bool _hardcore, int _dlcid)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			RoomOptions val = new RoomOptions();
			Hashtable val2 = new Hashtable();
			if (_storeID != -1 && !string.IsNullOrEmpty(_lobbyID))
			{
				((Dictionary<object, object>)(object)val2).Add((object)"Store", (object)_storeID);
				((Dictionary<object, object>)(object)val2).Add((object)"LobbyID", (object)_lobbyID);
			}
			((Dictionary<object, object>)(object)val2).Add((object)"Hardcore", (object)_hardcore);
			((Dictionary<object, object>)(object)val2).Add((object)"AreaDLC", (object)_dlcid);
			val.CustomRoomProperties = val2;
			val.IsVisible = true;
			val.MaxPlayers = (byte)RaidModeConfig.GetRoomPlayerLimit();
			PhotonNetwork.CreateRoom(_roomName, val, TypedLobby.Default);
			return false;
		}
	}
	[HarmonyPatch(typeof(CoopStats), "ApplyToCharacter")]
	public class CoopStats_ApplyToCharacter
	{
		public static bool Prefix(Character _char)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_0076: 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_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Expected O, but got Unknown
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Expected O, but got Unknown
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Expected O, but got Unknown
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Expected O, but got Unknown
			//IL_03a9: 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)
			CharacterStats stats = _char.Stats;
			stats.RemoveStatStack(TagSourceManager.Instance.GetTag(UID.op_Implicit("77")), "Coop_Stat", true);
			stats.RemoveStatStack(TagSourceManager.Instance.GetTag(UID.op_Implicit("95")), "Coop_Stat", true);
			stats.RemoveStatStack(TagSourceManager.Instance.GetTag(UID.op_Implicit("96")), "Coop_Stat", true);
			stats.RemoveStatStack(TagSourceManager.Instance.GetTag(UID.op_Implicit("84")), "Coop_Stat", false);
			if (RaidModeConfig.LiveSettings.DifficultyMode == RaidModeConfig.DifficultyModeSetting.NoScaling)
			{
				return false;
			}
			if (RaidModeConfig.LiveSettings.DifficultyMode == RaidModeConfig.DifficultyModeSetting.JustVanilla)
			{
				if (Global.Lobby.PlayersInLobbyCount > 1)
				{
					return true;
				}
				return false;
			}
			int manualDifficultyScaling = RaidModeConfig.LiveSettings.ManualDifficultyScaling;
			int num = ((manualDifficultyScaling > 0) ? (manualDifficultyScaling + 1) : Global.Lobby.PlayersInLobbyCount);
			if (RaidModeConfig.LiveSettings.DifficultyMode == RaidModeConfig.DifficultyModeSetting.VanillaPlus)
			{
				VanillaPlus(_char, num, stats.CoopStats.StatData);
				return false;
			}
			float num2 = 0.5f;
			float num3 = 0.1f;
			float num4 = 0.1f;
			float num5 = 0.5f;
			if (RaidModeConfig.LiveSettings.DifficultyMode == RaidModeConfig.DifficultyModeSetting.Custom)
			{
				num2 = (float)RaidModeConfig.LiveSettings.HealthScaling / 100f;
				num3 = (float)RaidModeConfig.LiveSettings.ImpactDamageScaling / 100f;
				num4 = (float)RaidModeConfig.LiveSettings.DamageScaling / 100f;
				num5 = (float)RaidModeConfig.LiveSettings.EffectiveStabilityScaling / 100f;
			}
			float num6 = ((!RaidModeConfig.LiveSettings.HardMode) ? 1 : 2);
			float num7 = num2 * ((float)num - 1f) * num6;
			StatStack val = new StatStack("Coop_Stat", -1f, num7, (Tag[])null);
			stats.AddStatStack(TagSourceManager.Instance.GetTag(UID.op_Implicit("77")), val, true);
			float num8 = num3 * ((float)num - 1f) * num6;
			StatStack val2 = new StatStack("Coop_Stat", -1f, num8, (Tag[])null);
			stats.AddStatStack(TagSourceManager.Instance.GetTag(UID.op_Implicit("95")), val2, true);
			float num9 = num4 * ((float)num - 1f) * num6;
			StatStack val3 = new StatStack("Coop_Stat", -1f, num9, (Tag[])null);
			stats.AddStatStack(TagSourceManager.Instance.GetTag(UID.op_Implicit("96")), val3, true);
			float num10 = stats.ImpactResistanceStat.BaseValue + _char.Inventory.Equipment.GetEquipmentImpactResistance();
			float num11 = 0f;
			if (num10 < 100f)
			{
				float num12 = 1f - num10 / 100f;
				float num13 = 1f / num12;
				float num14 = num13 / (1f / (float)num);
				float num15 = num14 - num13;
				float num16 = num15 * num5 * num6 + num13;
				float num17 = 1f / num16;
				num11 = (1f - num17) * 100f - num10;
			}
			else if (num10 - 25f < 100f)
			{
				float num18 = 1f - (num10 - 25f) / 100f;
				float num19 = 1f / num18;
				float num20 = num19 / (1f / (float)num);
				float num21 = num20 - num19;
				float num22 = num21 * num5 * num6 + num19;
				float num23 = 1f / num22;
				num11 = (1f - num23) * 100f - num10 + 0.25f;
			}
			StatStack val4 = new StatStack("Coop_Stat", -1f, num11, (Tag[])null);
			stats.AddStatStack(TagSourceManager.Instance.GetTag(UID.op_Implicit("84")), val4, false);
			return false;
		}

		public static bool VanillaPlus(Character _char, float _playerCount, CoopStatData[] statData)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Expected O, but got Unknown
			//IL_0144: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Expected O, but got Unknown
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Expected O, but got Unknown
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Expected O, but got Unknown
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			CharacterStats stats = _char.Stats;
			List<string> list = new List<string>();
			float num = 0f;
			float num2 = ((!RaidModeConfig.LiveSettings.HardMode) ? 1 : 2);
			for (int i = 0; i < statData.Length; i++)
			{
				if (statData[i].Stat.Tag.TagName == "ImpactResistance" && _playerCount > 2f)
				{
					num = statData[i].Value[0];
					continue;
				}
				float num3 = statData[i].Value[0] * (_playerCount - 1f) * num2;
				StatStack val = new StatStack("Coop_Stat", -1f, num3, (Tag[])null);
				stats.AddStatStack(statData[i].Stat.Tag, val, statData[i].Modifier);
				list.Add(statData[i].Stat.Tag.TagName);
			}
			if (_playerCount > 2f)
			{
				if (!list.Contains("MaxHealth"))
				{
					float num4 = 0.5f * (_playerCount - 2f) * num2;
					StatStack val2 = new StatStack("Coop_Stat", -1f, num4, (Tag[])null);
					stats.AddStatStack(TagSourceManager.Instance.GetTag(UID.op_Implicit("77")), val2, true);
				}
				if (!list.Contains("Impact"))
				{
					float num5 = 0.75f * (_playerCount - 2f) * num2;
					StatStack val3 = new StatStack("Coop_Stat", -1f, num5, (Tag[])null);
					stats.AddStatStack(TagSourceManager.Instance.GetTag(UID.op_Implicit("95")), val3, true);
				}
				if (!list.Contains("AllDamages"))
				{
					float num6 = 0.15f * (_playerCount - 2f) * num2;
					StatStack val4 = new StatStack("Coop_Stat", -1f, num6, (Tag[])null);
					stats.AddStatStack(TagSourceManager.Instance.GetTag(UID.op_Implicit("96")), val4, true);
				}
				float num7 = stats.ImpactResistanceStat.BaseValue + _char.Inventory.Equipment.GetEquipmentImpactResistance();
				float num15;
				if (num7 < 100f)
				{
					float num8 = 1f - num7 / 100f;
					float num9 = 1f / num8;
					float num10 = 1f - (num7 + num) / 100f;
					float num11 = 1f / num10;
					float num12 = num11 - num9;
					float num13 = num12 * (_playerCount - 1f) * num2 + num9;
					float num14 = 1f / num13;
					num15 = (1f - num14) * 100f - num7;
				}
				else if (num7 - 25f < 100f)
				{
					float num16 = 1f - (num7 - 25f) / 100f;
					float num17 = 1f / num16;
					float num18 = 1f - (num7 - 25f + num) / 100f;
					float num19 = 1f / num18;
					float num20 = num19 - num17;
					float num21 = num20 * (_playerCount - 1f) * num2 + num17;
					float num22 = 1f / num21;
					num15 = (1f - num22) * 100f - num7 + 25f;
				}
				else
				{
					num15 = num;
				}
				StatStack val5 = new StatStack("Coop_Stat", -1f, num15, (Tag[])null);
				stats.AddStatStack(TagSourceManager.Instance.GetTag(UID.op_Implicit("84")), val5, false);
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(CurrentRoomNameDisplay), "OnEnable")]
	public class CurrentRoomNameDisplay_OnEnable
	{
		public static void Postfix(CurrentRoomNameDisplay __instance)
		{
			if (RaidModeConfig.LiveSettings.HideRoomName)
			{
				__instance.m_lblRoomName.text = "-";
			}
			else
			{
				__instance.m_lblRoomName.text = PhotonNetwork.room.Name;
			}
		}
	}
	[HarmonyPatch(typeof(DefeatPlayerSpawn), "GetScatterPoint")]
	public class DefeatPlayerSpawn_GetScatterPoint
	{
		public static void Postfix(DefeatPlayerSpawn __instance, ref Transform __result, Transform[] positions)
		{
			if (positions != null && __instance.ID >= positions.Length)
			{
				__result = positions[^1];
			}
		}
	}
	[HarmonyPatch(typeof(Deployable), "DeployableCast")]
	public class Deployable_DeployableCast
	{
		public static bool Prefix(Deployable __instance)
		{
			if (!__instance.IsDeployed)
			{
				__instance.m_character = ((EffectSynchronizer)((ItemExtension)__instance).Item).OwnerCharacter;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(GiveReward), "OnExecute")]
	public class GiveReward_OnExecute
	{
		private enum RewardType
		{
			SideQuestArtifact,
			SideQuestSkill,
			StoryArtifact,
			StorySkill,
			WorldArtifact
		}

		private static Dictionary<int, RewardType> rewardDatabase = new Dictionary<int, RewardType>
		{
			[2140120] = RewardType.SideQuestArtifact,
			[3000210] = RewardType.SideQuestArtifact,
			[3000212] = RewardType.SideQuestArtifact,
			[3000211] = RewardType.SideQuestArtifact,
			[3000043] = RewardType.SideQuestArtifact,
			[3000041] = RewardType.SideQuestArtifact,
			[3000040] = RewardType.SideQuestArtifact,
			[5300170] = RewardType.SideQuestArtifact,
			[5300160] = RewardType.SideQuestArtifact,
			[2300180] = RewardType.SideQuestArtifact,
			[3000360] = RewardType.SideQuestArtifact,
			[3000362] = RewardType.SideQuestArtifact,
			[3000361] = RewardType.SideQuestArtifact,
			[5110070] = RewardType.SideQuestArtifact,
			[8200031] = RewardType.SideQuestSkill,
			[8100090] = RewardType.SideQuestSkill,
			[8200010] = RewardType.SideQuestSkill,
			[8100300] = RewardType.SideQuestSkill,
			[8100310] = RewardType.SideQuestSkill,
			[8100070] = RewardType.SideQuestSkill,
			[8100100] = RewardType.SideQuestSkill,
			[8100290] = RewardType.SideQuestSkill,
			[8100362] = RewardType.SideQuestSkill,
			[8100320] = RewardType.SideQuestSkill,
			[8100270] = RewardType.SideQuestSkill,
			[8100380] = RewardType.SideQuestSkill,
			[8100340] = RewardType.SideQuestSkill,
			[8200190] = RewardType.SideQuestSkill,
			[8200130] = RewardType.SideQuestSkill,
			[8200170] = RewardType.SideQuestSkill,
			[8200140] = RewardType.SideQuestSkill,
			[8200110] = RewardType.SideQuestSkill,
			[8200180] = RewardType.SideQuestSkill,
			[8201020] = RewardType.SideQuestSkill,
			[8201021] = RewardType.SideQuestSkill,
			[8201022] = RewardType.SideQuestSkill,
			[8201023] = RewardType.SideQuestSkill,
			[8201024] = RewardType.SideQuestSkill,
			[8400018] = RewardType.SideQuestSkill,
			[8400014] = RewardType.SideQuestSkill,
			[8400019] = RewardType.SideQuestSkill,
			[8400013] = RewardType.SideQuestSkill,
			[8400021] = RewardType.SideQuestSkill,
			[8400011] = RewardType.SideQuestSkill,
			[3100040] = RewardType.StoryArtifact,
			[3100042] = RewardType.StoryArtifact,
			[3100041] = RewardType.StoryArtifact,
			[3100090] = RewardType.StoryArtifact,
			[3100092] = RewardType.StoryArtifact,
			[3100091] = RewardType.StoryArtifact,
			[2200100] = RewardType.StoryArtifact,
			[5110097] = RewardType.StoryArtifact,
			[3100031] = RewardType.StoryArtifact,
			[3100030] = RewardType.StoryArtifact,
			[2000031] = RewardType.StoryArtifact,
			[5100080] = RewardType.StoryArtifact,
			[4300270] = RewardType.StoryArtifact,
			[5100110] = RewardType.StoryArtifact,
			[8200100] = RewardType.StorySkill,
			[8200105] = RewardType.StorySkill,
			[8200104] = RewardType.StorySkill,
			[8202004] = RewardType.StorySkill,
			[8202005] = RewardType.StorySkill,
			[8205280] = RewardType.StorySkill,
			[8205350] = RewardType.StorySkill,
			[8205340] = RewardType.StorySkill,
			[8205330] = RewardType.StorySkill,
			[8205310] = RewardType.StorySkill,
			[8205999] = RewardType.StorySkill,
			[8205998] = RewardType.StorySkill,
			[8205261] = RewardType.StorySkill,
			[8205997] = RewardType.StorySkill,
			[8205270] = RewardType.StorySkill,
			[8205260] = RewardType.StorySkill,
			[8205311] = RewardType.StorySkill,
			[8205300] = RewardType.StorySkill,
			[8205240] = RewardType.StorySkill,
			[2000151] = RewardType.WorldArtifact,
			[2150170] = RewardType.WorldArtifact,
			[2000320] = RewardType.WorldArtifact,
			[2120270] = RewardType.WorldArtifact,
			[2110260] = RewardType.WorldArtifact,
			[2020070] = RewardType.WorldArtifact,
			[2200190] = RewardType.WorldArtifact,
			[2120070] = RewardType.WorldArtifact,
			[2010280] = RewardType.WorldArtifact,
			[2020330] = RewardType.WorldArtifact,
			[2130310] = RewardType.WorldArtifact,
			[2010070] = RewardType.WorldArtifact,
			[2140060] = RewardType.WorldArtifact,
			[2160230] = RewardType.WorldArtifact,
			[2160100] = RewardType.WorldArtifact,
			[2130021] = RewardType.WorldArtifact,
			[2300360] = RewardType.WorldArtifact,
			[5110112] = RewardType.WorldArtifact,
			[5110340] = RewardType.WorldArtifact,
			[5110002] = RewardType.WorldArtifact,
			[2300030] = RewardType.WorldArtifact,
			[5110005] = RewardType.WorldArtifact,
			[3200030] = RewardType.WorldArtifact,
			[3200032] = RewardType.WorldArtifact,
			[3200031] = RewardType.WorldArtifact,
			[5300070] = RewardType.WorldArtifact,
			[5300030] = RewardType.WorldArtifact,
			[5300180] = RewardType.WorldArtifact,
			[5300050] = RewardType.WorldArtifact,
			[5100510] = RewardType.WorldArtifact
		};

		public static void Postfix(GiveReward __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			if ((int)__instance.RewardReceiver == 2)
			{
				return;
			}
			Character val = CharacterManager.Instance.GetWorldHostCharacter();
			if ((int)__instance.RewardReceiver == 1 && ((Task)__instance).blackboard != null)
			{
				Variable<Character> variable = ((Task)__instance).blackboard.GetVariable<Character>("gInstigator");
				if (variable != null)
				{
					val = variable.value;
				}
			}
			List<Character> list = new List<Character>();
			for (int i = 0; i < CharacterManager.Instance.PlayerCharacters.Count; i++)
			{
				Character character = CharacterManager.Instance.GetCharacter(CharacterManager.Instance.PlayerCharacters.Values[i]);
				if (Object.op_Implicit((Object)(object)character) && (Object)(object)character != (Object)(object)val)
				{
					list.Add(character);
				}
			}
			foreach (ItemQuantity item in __instance.ItemReward)
			{
				if (!rewardDatabase.TryGetValue(item.Item.value.ItemID, out var value))
				{
					continue;
				}
				switch (value)
				{
				case RewardType.SideQuestArtifact:
					if (!RaidModeConfig.LiveSettings.ShareSideQuestArtifacts)
					{
						continue;
					}
					break;
				case RewardType.SideQuestSkill:
					if (!RaidModeConfig.LiveSettings.ShareSideQuestSkills)
					{
						continue;
					}
					break;
				case RewardType.StoryArtifact:
					if (!RaidModeConfig.LiveSettings.ShareStoryArtifacts)
					{
						continue;
					}
					break;
				case RewardType.StorySkill:
					if (!RaidModeConfig.LiveSettings.ShareStorySkills)
					{
						continue;
					}
					break;
				case RewardType.WorldArtifact:
					if (!RaidModeConfig.LiveSettings.ShareWorldArtifacts)
					{
						continue;
					}
					break;
				}
				foreach (Character item2 in list)
				{
					int num = ((item.Quantity == null) ? 1 : item.Quantity.value);
					bool flag = item.TryToEquip != null && item.TryToEquip.value;
					if (item.Item.value.RefItem is Skill)
					{
						item2.Inventory.ReceiveSkillReward(item.Item.value.ItemID);
					}
					else
					{
						item2.Inventory.ReceiveItemReward(item.Item.value.ItemID, num, flag);
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(InteractionRevive), "OnActivate")]
	public class InteractionRevive_OnActivate
	{
		public static bool Prefix(InteractionBase __instance)
		{
			if (RaidModeConfig.LiveSettings.ReviveCombatRestrictions == RaidModeConfig.ReviveCombatSetting.OnlyReviver && Global.CombatManager.PlayersInCombat.Contains(__instance.LastCharacter))
			{
				if (__instance.LastCharacter.IsLocalPlayer)
				{
					__instance.LastCharacter.CharacterUI.ShowInfoNotification("Must be out of combat to revive a teammate!");
				}
				__instance.InterruptActivation();
				return false;
			}
			if (RaidModeConfig.LiveSettings.ReviveCombatRestrictions == RaidModeConfig.ReviveCombatSetting.Party && Global.CombatManager.PlayersInCombat.Count > 0)
			{
				if (__instance.LastCharacter.IsLocalPlayer)
				{
					__instance.LastCharacter.CharacterUI.ShowInfoNotification("The party must be out of combat to revive a teammate!");
				}
				__instance.InterruptActivation();
				return false;
			}
			if (RaidModeConfig.LiveSettings.ReviveItemNeeded)
			{
				if (!__instance.LastCharacter.Inventory.OwnsItem(4400010) && !__instance.LastCharacter.Inventory.OwnsItem(4300010) && !__instance.LastCharacter.Inventory.OwnsItem(4300240))
				{
					if (__instance.LastCharacter.IsLocalPlayer)
					{
						__instance.LastCharacter.CharacterUI.ShowInfoNotification("A healing item is required to revive a teammate.");
					}
					__instance.InterruptActivation();
					return false;
				}
				if (__instance.LastCharacter.Inventory.OwnsItem(4400010))
				{
					if (PhotonNetwork.isMasterClient)
					{
						__instance.LastCharacter.Inventory.RemoveItem(4400010, 1);
					}
					if (__instance.LastCharacter.IsLocalPlayer)
					{
						__instance.LastCharacter.CharacterUI.ShowInfoNotification("Used a Bandage to revive teammate.");
					}
				}
				else if (__instance.LastCharacter.Inventory.OwnsItem(4300010))
				{
					if (PhotonNetwork.isMasterClient)
					{
						__instance.LastCharacter.Inventory.RemoveItem(4300010, 1);
					}
					if (__instance.LastCharacter.IsLocalPlayer)
					{
						__instance.LastCharacter.CharacterUI.ShowInfoNotification("Used a Life Potion to revive teammate.");
					}
				}
				else
				{
					if (PhotonNetwork.isMasterClient)
					{
						__instance.LastCharacter.Inventory.RemoveItem(4300240, 1);
					}
					if (__instance.LastCharacter.IsLocalPlayer)
					{
						__instance.LastCharacter.CharacterUI.ShowInfoNotification("Used a Great Life Potion to revive teammate.");
					}
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(InteractionSleep), "ProcessText")]
	public class InteractionSleep_ProcessText
	{
		public static bool Prefix(InteractionSleep __instance)
		{
			if (RaidModeConfig.LiveSettings.CozyBeds && __instance.m_sleepableScript.IsInnsBed)
			{
				__instance.m_sleepableScript.Capacity = 2;
			}
			else
			{
				__instance.m_sleepableScript.Capacity = 1;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(InteractionSwitchArea), "OnActivate")]
	public class InteractionSwitchArea_OnActivate
	{
		public static bool Prefix(InteractionSwitchArea __instance)
		{
			if (RaidModeConfig.LiveSettings.ReviveNoManLeftBehind)
			{
				foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
				{
					if (Object.op_Implicit((Object)(object)item.ControlledCharacter) && item.ControlledCharacter.IsDead)
					{
						if (((InteractionBase)__instance).LastCharacter.IsLocalPlayer)
						{
							((InteractionBase)__instance).LastCharacter.CharacterUI.ShowInfoNotification("Nao e possivel sair enquanto houver aliados caidos!");
						}
						((InteractionBase)__instance).InterruptActivation();
						return false;
					}
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Item), "UpdateProcessing")]
	public class Item_UpdateProcessing
	{
		public static bool Prefix(Item __instance)
		{
			__instance.m_updateSpeed = 0f;
			return true;
		}
	}
	[HarmonyPatch(typeof(ItemManager), "UpdateSyncItem")]
	public class ItemManager_UpdateSyncItem
	{
		public static void Prefix(ItemManager __instance)
		{
			__instance.m_itemSyncTimer = 0f;
		}
	}
	[HarmonyPatch(typeof(ItemManager), "LoadItemsForCharacter")]
	public class ItemManager_LoadItemsForCharacter
	{
		public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return ItemSyncAudience.Expand(instructions, "SendLoadItemsForCharacter");
		}
	}
	[HarmonyPatch(typeof(ItemManager), "LoadStashForCharacter")]
	public class ItemManager_LoadStashForCharacter
	{
		public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return ItemSyncAudience.Expand(instructions, "SendLoadStashItemsForCharacter");
		}
	}
	internal static class ItemSyncAudience
	{
		internal static IEnumerable<CodeInstruction> Expand(IEnumerable<CodeInstruction> source, string rpc)
		{
			List<CodeInstruction> list = source.ToList();
			int num = 0;
			for (int i = 0; i < list.Count - 1; i++)
			{
				if (list[i].opcode == OpCodes.Ldstr && object.Equals(list[i].operand, rpc) && CodeInstructionExtensions.LoadsConstant(list[i + 1], 2L))
				{
					list[i + 1].opcode = OpCodes.Ldc_I4;
					list[i + 1].operand = 1;
					num++;
				}
			}
			if (num != 1)
			{
				throw new InvalidOperationException("RaidMode: RPC de sincronizacao inesperado: " + rpc);
			}
			return list;
		}
	}
	[HarmonyPatch(typeof(NetworkCharacterControl), "Update")]
	public class NetworkCharacterControl_Update
	{
		public static bool Prefix(NetworkCharacterControl __instance)
		{
			if (!((CharacterControl)__instance).m_character.IsAI && !((CharacterControl)__instance).m_character.SendInitDone && ((CharacterControl)__instance).m_character.Initialized && NetworkLevelLoader.Instance.IsOverallLoadingDone)
			{
				((MonoBehaviour)__instance).photonView.RPC("RequestInitInfo", ((MonoBehaviour)__instance).photonView.owner, new object[1] { PhotonNetwork.player });
				((CharacterControl)__instance).m_character.SendInitDone = true;
			}
			return true;
		}
	}
	public class NetworkLevelLoader_Patch : MonoBehaviour
	{
		[HarmonyPatch(typeof(NetworkLevelLoader), "UpdateCheckAllPlayerDoneLoading")]
		public class NetworkLevelLoader_UpdateCheckAllPlayerDoneLoading
		{
			public static void Postfix(NetworkLevelLoader __instance)
			{
				if (!PhotonNetwork.isNonMasterClientInRoom || s_isSendingGameplayResumedRequest)
				{
					return;
				}
				if (s_lastGameplayResumedResult)
				{
					PhotonPlayer player = PhotonNetwork.player;
					PhotonPlayer[] playerList = PhotonNetwork.playerList;
					foreach (PhotonPlayer val in playerList)
					{
						if (val.ID != player.ID)
						{
							if (!__instance.m_doneLoadingPlayers.Contains(val.ID))
							{
								__instance.m_doneLoadingPlayers.Add(val.ID);
							}
							if (!__instance.m_readyToContinuePlayers.Contains(val.ID))
							{
								__instance.m_readyToContinuePlayers.Add(val.ID);
							}
						}
					}
				}
				else
				{
					SendRequestIsGameplayResumed();
				}
			}
		}

		internal static NetworkLevelLoader_Patch Instance;

		internal const int VIEW_ID = 980;

		internal static bool s_isSendingGameplayResumedRequest;

		internal static bool s_lastGameplayResumedResult;

		public static void Init()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("RaidModeNetLevelLoaderRPC");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x3D);
			Instance = val.AddComponent<NetworkLevelLoader_Patch>();
			PhotonView val2 = val.AddComponent<PhotonView>();
			val2.viewID = 980;
		}

		public static void SendRequestIsGameplayResumed()
		{
			if (!s_isSendingGameplayResumedRequest)
			{
				s_lastGameplayResumedResult = false;
				s_isSendingGameplayResumedRequest = true;
				((MonoBehaviour)Instance).photonView.RPC("ReceiveRequestIsGameplayResumed", (PhotonTargets)2, Array.Empty<object>());
			}
		}

		[PunRPC]
		public void ReceiveRequestIsGameplayResumed(PhotonMessageInfo info)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			PhotonView photonView = ((MonoBehaviour)Instance).photonView;
			PhotonPlayer sender = info.sender;
			object[] array = new object[1];
			int num;
			if (!NetworkLevelLoader.Instance.IsGameplayPaused)
			{
				CharacterManager instance = CharacterManager.Instance;
				num = (Object.op_Implicit((Object)(object)((instance != null) ? instance.GetFirstLocalCharacter() : null)) ? 1 : 0);
			}
			else
			{
				num = 0;
			}
			array[0] = (byte)num != 0;
			photonView.RPC("ReceiveIsGameplayResumed", sender, array);
		}

		[PunRPC]
		public void ReceiveIsGameplayResumed(bool resumed)
		{
			s_lastGameplayResumedResult = resumed;
			s_isSendingGameplayResumedRequest = false;
		}
	}
	[HarmonyPatch(typeof(OtherPlayersCompass), "Update")]
	public class OtherPlayersCompass_Update
	{
		public static bool Prefix(OtherPlayersCompass __instance)
		{
			for (int i = 0; i < ((CompassElement<Character>)(object)__instance).m_watchedElements.Length; i++)
			{
				((CompassElement<Character>)(object)__instance).m_watchedElements[i] = null;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(PauseMenu), "Update")]
	public class PauseMenu_Update
	{
		public static bool Prefix(PauseMenu __instance)
		{
			if (((UIElement)__instance).m_hideWanted && ((UIElement)__instance).IsDisplayed && Time.time - ((UIElement)__instance).m_lastToggleTime >= ((UIElement)__instance).MinActiveTime)
			{
				((UIElement)__instance).OnHide();
			}
			if (((Panel)__instance).m_displayTarget != 0)
			{
				((Panel)__instance).UpdateShowHide();
			}
			if (Object.op_Implicit((Object)(object)((UIElement)__instance).LocalCharacter))
			{
				if ((((UIElement)__instance).LocalCharacter.Alive && ((Selectable)__instance.m_btnSplit).interactable != PhotonNetwork.offlineMode) || PhotonNetwork.isMasterClient)
				{
					((Selectable)__instance.m_btnSplit).interactable = PhotonNetwork.offlineMode || PhotonNetwork.isMasterClient;
				}
				else if (!((UIElement)__instance).LocalCharacter.Alive && ((Selectable)__instance.m_btnSplit).interactable)
				{
					((Selectable)__instance.m_btnSplit).interactable = false;
				}
				if (!__instance.m_suicide && ((Input.GetKey((KeyCode)304) && Input.GetKey((KeyCode)308) && Input.GetKeyDown((KeyCode)117)) || ControlsInput.GamepadUnstuckCheat(((UIElement)__instance).PlayerID)))
				{
					__instance.m_suicide = true;
					if (Object.op_Implicit((Object)(object)__instance.m_btnDie) && !((Component)__instance.m_btnDie).gameObject.activeSelf)
					{
						((Component)__instance.m_btnDie).gameObject.SetActive(true);
					}
				}
			}
			while (__instance.m_actionQueue.Count > 0)
			{
				__instance.m_actionQueue.Dequeue()?.Invoke();
			}
			PersonalPvpPauseButton.Refresh(__instance);
			return false;
		}
	}
	[HarmonyPatch(typeof(PauseMenu), "Show")]
	public class PauseMenu_Show
	{
		public static void Postfix(PauseMenu __instance)
		{
			((Selectable)__instance.m_btnSplit).interactable = PhotonNetwork.offlineMode || PhotonNetwork.isMasterClient;
			((Selectable)__instance.m_btnToggleNetwork).interactable = StoreManager.Instance.AllowOnlineFeatures && !ConnectPhotonMaster.Instance.RequestingRooms;
			PersonalPvpPauseButton.Ensure(__instance);
		}
	}
	internal static class PersonalPvpPauseButton
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__Toggle;
		}

		private const string ButtonName = "ColecaoDoViajante_PvP";

		internal static void Ensure(PauseMenu pauseMenu)
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Expected O, but got Unknown
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Expected O, but got Unknown
			if (!((Object)(object)pauseMenu == (Object)null) && !((Object)(object)pauseMenu.m_btnChat == (Object)null))
			{
				Transform parent = ((Component)pauseMenu.m_btnChat).transform.parent;
				Transform val = parent.Find("ColecaoDoViajante_PvP");
				Button component;
				if ((Object)(object)val == (Object)null)
				{
					GameObject val2 = Object.Instantiate<GameObject>(((Component)pauseMenu.m_btnChat).gameObject, parent);
					((Object)val2).name = "ColecaoDoViajante_PvP";
					component = val2.GetComponent<Button>();
				}
				else
				{
					component = ((Component)val).GetComponent<Button>();
				}
				RectTransform component2 = ((Component)pauseMenu.m_btnChat).GetComponent<RectTransform>();
				RectTransform component3 = ((Component)component).GetComponent<RectTransform>();
				if ((Object)(object)component2 != (Object)null && (Object)(object)component3 != (Object)null)
				{
					component3.anchorMin = component2.anchorMin;
					component3.anchorMax = component2.anchorMax;
					component3.pivot = component2.pivot;
					component3.sizeDelta = component2.sizeDelta;
					Rect rect = component2.rect;
					float num = Mathf.Max(5f, ((Rect)(ref rect)).height * 0.18f);
					Vector2 anchoredPosition = component2.anchoredPosition;
					Vector2 up = Vector2.up;
					rect = component2.rect;
					component3.anchoredPosition = anchoredPosition + up * (((Rect)(ref rect)).height + num);
				}
				int num2 = ((Component)pauseMenu.m_btnChat).transform.GetSiblingIndex();
				if (((Component)component).transform.GetSiblingIndex() < num2)
				{
					num2--;
				}
				((Component)component).transform.SetSiblingIndex(num2);
				component.onClick = new ButtonClickedEvent();
				ButtonClickedEvent onClick = component.onClick;
				object obj = <>O.<0>__Toggle;
				if (obj == null)
				{
					UnityAction val3 = Toggle;
					<>O.<0>__Toggle = val3;
					obj = (object)val3;
				}
				((UnityEvent)onClick).AddListener((UnityAction)obj);
				((Selectable)component).interactable = true;
				UpdateLabel(component);
			}
		}

		internal static void Refresh(PauseMenu pauseMenu)
		{
			if (!((Object)(object)pauseMenu == (Object)null) && !((Object)(object)pauseMenu.m_btnChat == (Object)null))
			{
				Transform val = ((Component)pauseMenu.m_btnChat).transform.parent.Find("ColecaoDoViajante_PvP");
				if ((Object)(object)val != (Object)null)
				{
					UpdateLabel(((Component)val).GetComponent<Button>());
				}
			}
		}

		private static void Toggle()
		{
			RaidModeConfig.TogglePersonalPvp();
			Button[] array = Object.FindObjectsOfType<Button>();
			foreach (Button val in array)
			{
				if (((Object)val).name == "ColecaoDoViajante_PvP")
				{
					UpdateLabel(val);
				}
			}
		}

		private static void UpdateLabel(Button button)
		{
			if (!((Object)(object)button == (Object)null))
			{
				Text componentInChildren = ((Component)button).GetComponentInChildren<Text>(true);
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.text = (RaidModeConfig.LocalPersonalPvpEnabled ? "PVP: ON" : "PVP: OFF");
				}
			}
		}
	}
	[HarmonyPatch(typeof(PauseMenu), "OnToggleNetwork")]
	public class PauseMenu_OnToggleNetwork
	{
		public static bool Prefix(PauseMenu __instance)
		{
			if (PhotonNetwork.offlineMode)
			{
				__instance.m_gameNamingWindow.Show(LocalizationManager.Instance.GetLoc("MessageBox_Online_RoomNameCreate"), (UnityAction<string>)__instance.OnConfirmRoomCreation);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	public class PeerBase_CreatePeerBase
	{
		public static bool Prefix(PeerBase __instance, ref int __result)
		{
			__result = 60000;
			return false;
		}
	}
	internal static class PvPMode
	{
		private sealed class ProjectileHitState
		{
			internal bool NativePvpHit;
		}

		private static readonly FieldInfo TargetingOwner = AccessTools.Field(typeof(TargetingSystem), "m_character");

		private static readonly FieldInfo TargetableFactions = AccessTools.Field(typeof(SubEffect), "m_targetableFactions");

		private static readonly FieldInfo ShootProjectileFactions = AccessTools.Field(typeof(ShootProjectile), "m_targetableFactions");

		private static readonly MethodInfo ReceiveDamageMethod = AccessTools.Method(typeof(Character), "ReceiveDamage", new Type[3]
		{
			typeof(float),
			typeof(Vector3),
			typeof(bool)
		}, (Type[])null);

		private static readonly ConditionalWeakTable<SubEffect, object> PvpTargetEffects = new ConditionalWeakTable<SubEffect, object>();

		private static readonly ConditionalWeakTable<Projectile, ProjectileHitState> ProjectileHits = new ConditionalWeakTable<Projectile, ProjectileHitState>();

		private static readonly object PvpTargetMarker = new object();

		private static readonly Dictionary<string, float> TraceTimes = new Dictionary<string, float>();

		private static readonly Factions[] PvpFactions;

		[ThreadStatic]
		private static bool m_checkingPvpCondition;

		internal static void Trace(string route, Character source, Character target, string detail)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			source = ResolveCombatOwner(source);
			if (!((Object)(object)source == (Object)null) && (int)source.PlayerType != 0 && Plugin.Log != null)
			{
				string key = route + "|" + detail;
				if (!TraceTimes.TryGetValue(key, out var value) || !(Time.time - value < 0.75f))
				{
					TraceTimes[key] = Time.time;
					string text = (((Object)(object)target == (Object)null) ? "nenhum" : target.Name);
					Plugin.Log.LogInfo((object)("[PvP] " + route + " | " + detail + " | origem=" + source.Name + " | alvo=" + text));
				}
			}
		}

		internal static bool CanAttack(Character attacker, Character target)
		{
			//IL_0025: 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)
			attacker = ResolveCombatOwner(attacker);
			return (Object)(object)attacker != (Object)null && (Object)(object)target != (Object)null && (Object)(object)attacker != (Object)(object)target && (int)attacker.PlayerType != 0 && (int)target.PlayerType != 0 && RaidModeConfig.HasPersonalPvpEnabled(attacker) && RaidModeConfig.HasPersonalPvpEnabled(target);
		}

		internal static bool ApplySummonPvpDamage(Character target, Character dealer, float damage, Vector3 hitVector)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)target == (Object)null || (Object)(object)dealer == (Object)null || (int)target.PlayerType == 0 || (int)dealer.PlayerType != 0 || string.IsNullOrEmpty(dealer.SummonerUID))
			{
				return false;
			}
			if (!CanAttack(dealer, target))
			{
				return true;
			}
			if ((PhotonNetwork.isMasterClient || target.IsLocalPlayer) && ReceiveDamageMethod != null)
			{
				ReceiveDamageMethod.Invoke(target, new object[3] { damage, hitVector, true });
			}
			return true;
		}

		internal static void IncludePlayersForPvp(SubEffect effect)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			Character effectOwner = GetEffectOwner((EffectSynchronizer)(object)effect);
			if (!((Object)(object)effect == (Object)null) && !((Object)(object)effectOwner == (Object)null) && (int)effectOwner.PlayerType != 0 && !(TargetableFactions == null) && RaidModeConfig.HasPersonalPvpEnabled(effectOwner))
			{
				Factions[] array = TargetableFactions.GetValue(effect) as Factions[];
				Factions[] array2 = IncludePlayerFactionForPvp(effectOwner, array);
				if (array2 != array)
				{
					TargetableFactions.SetValue(effect, array2);
				}
				if (array2 != null && Array.IndexOf(array2, (Factions)1) >= 0 && !PvpTargetEffects.TryGetValue(effect, out var _))
				{
					PvpTargetEffects.Add(effect, PvpTargetMarker);
					Trace("SubEffect preparado", effectOwner, null, ((object)effect).GetType().Name);
				}
			}
		}

		internal static Factions[] IncludePlayerFactionForPvp(Character owner, Factions[] factions)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			owner = ResolveCombatOwner(owner);
			if ((Object)(object)owner == (Object)null || (int)owner.PlayerType == 0 || !RaidModeConfig.HasPersonalPvpEnabled(owner) || factions == null || Array.IndexOf(factions, (Factions)1) >= 0)
			{
				return factions;
			}
			Factions[] array = (Factions[])(object)new Factions[factions.Length + 1];
			Array.Copy(factions, array, factions.Length);
			array[^1] = (Factions)1;
			return array;
		}

		internal static void IncludePlayersForPvp(ShootProjectile shooter)
		{
			if (!((Object)(object)shooter == (Object)null) && !(ShootProjectileFactions == null))
			{
				Character effectOwner = GetEffectOwner((Effect)(object)shooter);
				Factions[] array = ShootProjectileFactions.GetValue(shooter) as Factions[];
				Factions[] array2 = IncludePlayerFactionForPvp(effectOwner, array);
				if (array2 != array)
				{
					ShootProjectileFactions.SetValue(shooter, array2);
				}
				if (array2 != null && Array.IndexOf(array2, (Factions)1) >= 0)
				{
					shooter.DontFindTargetSelf = true;
					Trace("Projetil preparado", effectOwner, null, ((object)shooter).GetType().Name);
				}
			}
		}

		internal static bool TryPvpConditionsWithoutPriority(Effect effect, Character target, ref bool result)
		{
			if (m_checkingPvpCondition || (Object)(object)effect == (Object)null || !IsPvpPair(effect.SourceCharacter, target) || !CanAttack(effect.SourceCharacter, target))
			{
				return false;
			}
			m_checkingPvpCondition = true;
			try
			{
				if (!effect.TryTriggerConditions(target, true))
				{
					return false;
				}
				result = true;
				Trace("Prioridade PvP ignorada", effect.SourceCharacter, target, ((object)effect).GetType().Name);
				return true;
			}
			finally
			{
				m_checkingPvpCondition = false;
			}
		}

		internal static bool UsesPvpTargeting(SubEffect effect)
		{
			object value;
			return (Object)(object)effect != (Object)null && PvpTargetEffects.TryGetValue(effect, out value);
		}

		internal static void FilterPvpBlastTargets(Blast blast, List<Hitbox> targets)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (!UsesPvpTargeting((SubEffect)(object)blast) || targets == null)
			{
				return;
			}
			Character source = GetEffectOwner((EffectSynchronizer)(object)blast);
			Collider[] array = Physics.OverlapSphere(((Component)blast).transform.position, blast.Radius, Global.WeaponHittingMask);
			for (int i = 0; i < array.Length; i++)
			{
				Hitbox val = (((Object)(object)array[i] == (Object)null) ? null : ((Component)array[i]).GetComponent<Hitbox>());
				Character val2 = (((Object)(object)val == (Object)null) ? null : val.OwnerChar);
				if ((Object)(object)val == (Object)null || val.BlockBox || !CanAttack(source, val2))
				{
					continue;
				}
				bool flag = false;
				for (int j = 0; j < targets.Count; j++)
				{
					if ((Object)(object)targets[j] != (Object)null && (Object)(object)targets[j].OwnerChar == (Object)(object)val2)
					{
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					targets.Add(val);
					Trace("Alvo de explosao", source, val2, ((object)blast).GetType().Name + "=incluido");
				}
			}
			targets.RemoveAll(delegate(Hitbox box)
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				Character val3 = (((Object)(object)box == (Object)null) ? null : box.OwnerChar);
				return (Object)(object)val3 != (Object)null && (int)val3.PlayerType != 0 && !CanAttack(source, val3);
			});
		}

		internal static void BeginProjectileHit(Projectile projectile)
		{
			if ((Object)(object)projectile != (Object)null)
			{
				ProjectileHits.GetValue(projectile, (Projectile _) => new ProjectileHitState()).NativePvpHit = false;
			}
		}

		internal static void NoteNativeProjectileHit(Projectile projectile, Character target)
		{
			if ((Object)(object)projectile != (Object)null && CanAttack(GetEffectOwner((EffectSynchronizer)(object)projectile), target))
			{
				ProjectileHits.GetValue(projectile, (Projectile _) => new ProjectileHitState()).NativePvpHit = true;
			}
		}

		internal static void ApplyProjectileHitIfNeeded(Projectile projectile, Collider collider, Vector3 hitPoint, Vector3 hitDirection)
		{
			//IL_0072: 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)
			if (!((Object)(object)projectile == (Object)null) && !((Object)(object)collider == (Object)null))
			{
				Character characterOwner = UnityEngineExtensions.GetCharacterOwner(collider);
				Character effectOwner = GetEffectOwner((EffectSynchronizer)(object)projectile);
				ProjectileHitState value = ProjectileHits.GetValue(projectile, (Projectile _) => new ProjectileHitState());
				if (!value.NativePvpHit && CanAttack(effectOwner, characterOwner))
				{
					((EffectSynchronizer)projectile).SynchronizeEffects((EffectCategories)4, characterOwner, hitPoint, hitDirection);
					Trace("Alvo de projetil", effectOwner, characterOwner, ((object)projectile).GetType().Name + "=sincronizado");
				}
			}
		}

		internal static Character GetTrapSource(TrapTrigger trigger)
		{
			DeployableTrap val = (((Object)(object)trigger == (Object)null) ? null : ((Component)trigger).GetComponentInParent<DeployableTrap>());
			return ((Object)(object)val == (Object)null) ? null : ((EffectSynchronizer)val).SourceCharacter;
		}

		internal static Factions[] IncludePlayerFaction(Factions[] factions)
		{
			if (factions == null || Array.IndexOf(factions, (Factions)1) >= 0)
			{
				return factions;
			}
			Factions[] array = (Factions[])(object)new Factions[factions.Length + 1];
			Array.Copy(factions, array, factions.Length);
			array[^1] = (Factions)1;
			return array;
		}

		internal static Character GetTargetingOwner(TargetingSystem targeting)
		{
			return (Character)(((Object)(object)targeting == (Object)null || TargetingOwner == null) ? null : /*isinst with value type is only supported in some contexts*/);
		}

		internal static Character GetEffectOwner(EffectSynchronizer synchronizer)
		{
			if ((Object)(object)synchronizer == (Object)null)
			{
				return null;
			}
			return ResolveCombatOwner(synchronizer.OwnerCharacter ?? synchronizer.SourceCharacter);
		}

		internal static Character GetEffectOwner(Effect effect)
		{
			if ((Object)(object)effect == (Object)null)
			{
				return null;
			}
			return ResolveCombatOwner(effect.OwnerCharacter ?? effect.SourceCharacter);
		}

		internal static Character ResolveCombatOwner(Character character)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			if ((Object)(object)character == (Object)null || (int)character.PlayerType > 0)
			{
				return character;
			}
			if (!string.IsNullOrEmpty(character.SummonerUID) && (Object)(object)CharacterManager.Instance != (Object)null)
			{
				Character character2 = CharacterManager.Instance.GetCharacter(character.SummonerUID);
				if ((Object)(object)character2 != (Object)null && (Object)(object)character2 != (Object)(object)character)
				{
					return ResolveCombatOwner(character2);
				}
			}
			return character;
		}

		internal static void EnsurePlayerFaction(TargetingSystem targeting)
		{
			if (!((Object)(object)targeting == (Object)null))
			{
				Character owner = ResolveCombatOwner(GetTargetingOwner(targeting));
				targeting.TargetableFactions = IncludePlayerFactionForPvp(owner, targeting.TargetableFactions);
			}
		}

		internal static void RefreshAllTargetingFactions()
		{
			if ((Object)(object)CharacterManager.Instance == (Object)null || CharacterManager.Instance.Characters == null)
			{
				return;
			}
			RefreshCombatFactions();
			foreach (Character value in CharacterManager.Instance.Characters.Values)
			{
				if ((Object)(object)value != (Object)null)
				{
					EnsurePlayerFaction(value.TargetingSystem);
				}
			}
		}

		internal unsafe static void RefreshCombatFactions()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Invalid comparison between Unknown and I4
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: 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)
			if ((Object)(object)CharacterManager.Instance == (Object)null || CharacterManager.Instance.Characters == null)
			{
				return;
			}
			List<Character> list = new List<Character>();
			foreach (Character value2 in CharacterManager.Instance.Characters.Values)
			{
				if ((Object)(object)value2 != (Object)null && (int)value2.PlayerType != 0 && RaidModeConfig.HasPersonalPvpEnabled(value2))
				{
					list.Add(value2);
				}
			}
			list.Sort((Character left, Character right) => string.CompareOrdinal(((object)left.UID/*cast due to .constrained prefix*/).ToString(), ((object)right.UID/*cast due to .constrained prefix*/).ToString()));
			Dictionary<Character, Factions> dictionary = new Dictionary<Character, Factions>();
			for (int num = 0; num < list.Count; num++)
			{
				dictionary[list[num]] = PvpFactions[num % PvpFactions.Length];
			}
			foreach (Character value3 in CharacterManager.Instance.Characters.Values)
			{
				if (!((Object)(object)value3 == (Object)null) && (int)value3.PlayerType != 0)
				{
					Factions value;
					Factions val = (Factions)((!dictionary.TryGetValue(value3, out value)) ? 1 : ((int)value));
					if (value3.Faction != val)
					{
						value3.ChangeFaction(val, false);
						Trace("Faccao PvP", value3, null, ((object)(*(Factions*)(&val))/*cast due to .constrained prefix*/).ToString());
					}
				}
			}
		}

		internal static Factions[] IncludePlayersForOwner(Character owner, Factions[] factions)
		{
			return IncludePlayerFactionForPvp(owner, factions);
		}

		internal static bool CanApplyHostileEffect(Character source, Character target)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			source = ResolveCombatOwner(source);
			if ((Object)(object)target == (Object)null || (int)target.PlayerType == 0)
			{
				return true;
			}
			if ((Object)(object)source == (Object)(object)target)
			{
				return false;
			}
			return !IsPvpPair(source, target) || CanAttack(source, target);
		}

		internal static bool IsPvpPair(Character source, Character target)
		{
			//IL_0025: 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_0033: Invalid comparison between Unknown and I4
			source = ResolveCombatOwner(source);
			return (Object)(object)source != (Object)null && (Object)(object)target != (Object)null && (Object)(object)source != (Object)(object)target && (int)source.PlayerType != 0 && (int)target.PlayerType > 0;
		}

		static PvPMode()
		{
			Factions[] array = new Factions[8];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			PvpFactions = (Factions[])(object)array;
		}
	}
	[HarmonyPatch(typeof(Weapon), "ElligibleFaction", new Type[] { typeof(Hitbox) })]
	internal static class WeaponHitbox_ElligibleFaction_PvP
	{
		private static void Postfix(Weapon __instance, Hitbox _box, ref bool __result)
		{
			if (!__result && (Object)(object)_box != (Object)null && PvPMode.CanAttack(((EffectSynchronizer)__instance).OwnerCharacter, _box.OwnerChar))
			{
				__result = true;
			}
		}
	}
	[HarmonyPatch(typeof(Weapon), "ElligibleFaction", new Type[] { typeof(Character) })]
	internal static class Weapon_ElligibleFaction_PvP
	{
		private static void Postfix(Weapon __instance, Character _character, ref bool __result)
		{
			if (!__result && PvPMode.CanAttack(((EffectSynchronizer)__instance).OwnerCharacter, _character))
			{
				__result = true;
			}
		}
	}
	[HarmonyPatch(typeof(MeleeHitDetector), "ElligibleFaction", new Type[] { typeof(Character) })]
	internal static class MeleeHitDetector_ElligibleFaction_PvP
	{
		private static void Postfix(MeleeHitDetector __instance, Character _character, ref bool __result)
		{
			if (!__result && PvPMode.CanAttack(__instance.m_ownerCharacter, _character))
			{
				__result = true;
			}
		}
	}
	[HarmonyPatch(typeof(TargetingSystem), "IsTargetable", new Type[] { typeof(Character) })]
	internal static class TargetingSystem_IsTargetable_PvP
	{
		private static void Postfix(TargetingSystem __instance, Character _char, ref bool __result)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Invalid comparison between Unknown and I4
			Character targetingOwner = PvPMode.GetTargetingOwner(__instance);
			Character val = PvPMode.ResolveCombatOwner(targetingOwner);
			if (!((Object)(object)val == (Object)null) && !((Object)(object)_char == (Object)null))
			{
				if ((Object)(object)targetingOwner != (Object)null && SummonedGhostRegistry.Contains(targetingOwner) && ((Object)(object)val == (Object)(object)_char || (SummonedGhostRegistry.Contains(_char) && targetingOwner.Faction == _char.Faction)))
				{
					__result = false;
				}
				else if ((Object)(object)val == (Object)(object)_char)
				{
					__result = false;
				}
				else if ((Object)(object)targetingOwner != (Object)null && (int)targetingOwner.PlayerType == 0 && !SummonedGhostRegistry.Contains(targetingOwner) && (int)targetingOwner.SummonType == 0 && string.IsNullOrEmpty(targetingOwner.SummonerUID) && SummonedGhostRegistry.Contains(_char))
				{
					__result = true;
				}
				else if ((Object)(object)targetingOwner != (Object)null && (int)targetingOwner.PlayerType == 0 && !string.IsNullOrEmpty(targetingOwner.SummonerUID) && (int)_char.PlayerType > 0)
				{
					__result = PvPMode.CanAttack(val, _char);
					PvPMode.Trace("Mira da invocacao", val, _char, __result ? "PvP bilateral permitido" : "PvP desligado em um dos jogadores");
				}
				else if (PvPMode.IsPvpPair(val, _char))
				{
					__result = PvPMode.CanAttack(val, _char);
					PvPMode.Trace("Mira", val, _char, "alvo de jogador=" + (__result ? "permitido" : "bloqueado"));
				}
			}
		}
	}
	[HarmonyPatch(typeof(TargetingSystem), "IsTargetable", new Type[] { typeof(Factions) })]
	internal static class TargetingSystem_IsTargetableFaction_PvP
	{
		private static void Postfix(TargetingSystem __instance, Factions _faction, ref bool __result)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if (!__result && (int)_faction == 1 && RaidModeConfig.HasPersonalPvpEnabled(PvPMode.ResolveCombatOwner(PvPMode.GetTargetingOwner(__instance))))
			{
				__result = true;
			}
		}
	}
	[HarmonyPatch(typeof(TargetingSystem), "InitTargetableFaction")]
	internal static class TargetingSystem_InitTargetableFaction_PvP
	{
		private static void Postfix(TargetingSystem __instance)
		{
			PvPMode.EnsurePlayerFaction(__instance);
		}
	}
	[HarmonyPatch(typeof(TargetingSystem), "ProcessUpdate")]
	internal static class TargetingSystem_ProcessUpdate_PvP
	{
		private static void Prefix(TargetingSystem __instance)
		{
			PvPMode.EnsurePlayerFaction(__instance);
		}
	}
	[HarmonyPatch(typeof(Character), "VitalityHit", new Type[]
	{
		typeof(Character),
		typeof(float),
		typeof(Vector3)
	})]
	internal static class Character_VitalityHit_SummonPvP
	{
		private static bool Prefix(Character __instance, Character _dealerChar, float _damage, Vector3 _hitVector)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			return !PvPMode.ApplySummonPvpDamage(__instance, _dealerChar, _damage, _hitVector);
		}
	}
	[HarmonyPatch(typeof(PunctualDamage), "ActivateLocally", new Type[]
	{
		typeof(Character),
		typeof(object[])
	})]
	internal static class PunctualDamage_ActivateLocally_PvP
	{
		private static bool Prefix(PunctualDamage __instance, Character _targetCharacter)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Invalid comparison between Unknown and I4
			Character source = (((Object)(object)__instance == (Object)null) ? null : PvPMode.ResolveCombatOwner(((Effect)__instance).OwnerCharacter ?? ((Effect)__instance).SourceCharacter));
			bool flag = PvPMode.CanApplyHostileEffect(source, _targetCharacter);
			if ((Object)(object)_targetCharacter != (Object)null && (int)_targetCharacter.PlayerType > 0)
			{
				PvPMode.Trace("Dano direto", source, _targetCharacter, (((Object)(object)__instance == (Object)null) ? "desconhecido" : ((object)__instance).GetType().Name) + "=" + (flag ? "permitido" : "bloqueado"));
			}
			return flag;
		}
	}
	[HarmonyPatch(typeof(PunctualDamageAoE), "ActivateLocally", new Type[]
	{
		typeof(Character),
		typeof(object[])
	})]
	internal static class PunctualDamageAoE_ActivateLocally_PvP
	{
		private static void Prefix(PunctualDamageAoE __instance)
		{
			Character val = (((Object)(object)__instance == (Object)null) ? null : ((Effect)__instance).SourceCharacter);
			if ((Object)(object)val != (Object)null)
			{
				PvPMode.EnsurePlayerFaction(val.TargetingSystem);
			}
		}
	}
	[HarmonyPatch(typeof(Item), "OnUse", new Type[] { typeof(Character) })]
	internal static class Item_OnUse_PvPTrace
	{
		private static void Postfix(Item __instance, Character _targetChar)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			if (!(__instance is Skill) || (Object)(object)((EffectSynchronizer)__instance).OwnerCharacter == (Object)null || (int)((EffectSynchronizer)__instance).OwnerCharacter.PlayerType == 0)
			{
				return;
			}
			Effect[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Effect>(true);
			List<string> list = new List<string>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				if ((Object)(object)componentsInChildren[i] != (Object)null && !list.Contains(((object)componentsInChildren[i]).GetType().Name))
				{
					list.Add(((object)componentsInChildren[i]).GetType().Name);
				}
			}
			PvPMode.Trace("Habilidade usada", ((EffectSynchronizer)__instance).OwnerCharacter, _targetChar, "ID=" + __instance.ItemID + " " + __instance.Name + " | efeitos=" + string.Join(",", list.ToArray()));
		}
	}
	[HarmonyPatch(typeof(Effect), "TryTriggerConditions", new Type[]
	{
		typeof(Character),
		typeof(bool)
	})]
	internal static class Effect_TryTriggerConditions_PvPTrace
	{
		private static bool Prefix(Effect __instance, Character _affectedCharacter, ref bool __result)
		{
			return !PvPMode.TryPvpConditionsWithoutPriority(__instance, _affectedCharacter, ref __result);
		}

		private static void Postfix(Effect __instance, Character _affectedCharacter, bool __result)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			Character source = (((Object)(object)__instance == (Object)null) ? null : __instance.SourceCharacter);
			if ((Object)(object)_affectedCharacter != (Object)null && (int)_affectedCharacter.PlayerType != 0 && PvPMode.IsPvpPair(source, _affectedCharacter))
			{
				PvPMode.Trace("Efeito pronto", source, _affectedCharacter, (((Object)(object)__instance == (Object)null) ? "desconhecido" : ((object)__instance).GetType().Name) + "=" + (__result ? "ativo" : "recusado"));
			}
		}
	}
	[HarmonyPatch(typeof(SubEffect), "IsTargetable", new Type[] { typeof(Character) })]
	internal static class SubEffect_IsTargetable_PvP
	{
		private static void Postfix(SubEffect __instance, Character _character, ref bool __result)
		{
			if (PvPMode.UsesPvpTargeting(__instance) && !((Object)(object)_character == (Object)null))
			{
				Character ownerCharacter = ((EffectSynchronizer)__instance).OwnerCharacter;
				if (PvPMode.IsPvpPair(ownerCharacter, _character) || (Object)(object)ownerCharacter == (Object)(object)_character)
				{
					__result = PvPMode.CanAttack(ownerCharacter, _character);
				}
			}
		}
	}
	[HarmonyPatch(typeof(SubEffect), "Setup", new Type[]
	{
		typeof(Effect),
		typeof(int),
		typeof(Factions[]),
		typeof(Transform)
	})]
	internal static class SubEffect_Setup_PvP
	{
		private static void Prefix(Effect _parentEffect, ref Factions[] _targetFactions)
		{
			Character owner = (((Object)(object)_parentEffect == (Object)null) ? null : (_parentEffect.OwnerCharacter ?? _parentEffect.SourceCharacter));
			_targetFactions = PvPMode.IncludePlayersForOwner(owner, _targetFactions);
		}

		private static void Postfix(SubEffect __instance)
		{
			PvPMode.IncludePlayersForPvp(__instance);
		}
	}
	[HarmonyPatch(typeof(ShootProjectile), "Setup", new Type[]
	{
		typeof(Factions[]),
		typeof(Transform)
	})]
	internal static class ShootProjectile_Setup_PvP
	{
		private static void Prefix(ShootProjectile __instance, ref Factions[] _targetFactions)
		{
			_targetFactions = PvPMode.IncludePlayersForOwner(PvPMode.GetEffectOwner((Effect)(object)__instance), _targetFactions);
		}

		private static void Postfix(ShootProjectile __instance)
		{
			PvPMode.IncludePlayersForPvp(__instance);
		}
	}
	[HarmonyPatch(typeof(Shooter), "Setup", new Type[]
	{
		typeof(TargetingSystem),
		typeof(Transform)
	})]
	internal static class Shooter_Setup_PvP
	{
		private static void Prefix(Shooter __instance, TargetingSystem _targetSystem)
		{
			Character targetingOwner = PvPMode.GetTargetingOwner(_targetSystem);
			if ((Object)(object)_targetSystem != (Object)null)
			{
				_targetSystem.TargetableFactions = PvPMode.IncludePlayersForOwner(targetingOwner, _targetSystem.TargetableFactions);
				PvPMode.Trace("Atirador preparado", targetingOwner, null, ((Object)(object)__instance == (Object)null) ? "desconhecido" : ((object)__instance).GetType().Name);
			}
		}
	}
	[HarmonyPatch(typeof(Blast), "Hit")]
	internal static class Blast_Hit_PvP
	{
		private static void Prefix(Blast __instance)
		{
			PvPMode.IncludePlayersForPvp((SubEffect)(object)__instance);
		}
	}
	[HarmonyPatch(typeof(ConeBlast), "Hit")]
	internal static class ConeBlast_Hit_PvP
	{
		private static void Prefix(ConeBlast __instance)
		{
			PvPMode.IncludePlayersForPvp((SubEffect)(object)__instance);
		}
	}
	[HarmonyPatch(typeof(Blast), "AffectHit", new Type[] { typeof(List<Hitbox>) })]
	internal static class Blast_AffectHit_PvP
	{
		private static void Prefix(Blast __instance, List<Hitbox> _hitTargets)
		{
			PvPMode.FilterPvpBlastTargets(__instance, _hitTargets);
		}
	}
	[HarmonyPatch(typeof(Projectile), "Explode", new Type[]
	{
		typeof(Collider),
		typeof(Vector3),
		typeof(Vector3),
		typeof(bool)
	})]
	internal static class Projectile_Explode_PvP
	{
		private static void Prefix(Projectile __instance)
		{
			PvPMode.BeginProjectileHit(__instance);
		}

		private static void Postfix(Projectile __instance, Collider _collider, Vector3 _hitPoint, Vector3 _hitDir)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			PvPMode.ApplyProjectileHitIfNeeded(__instance, _collider, _hitPoint, _hitDir);
		}
	}
	[HarmonyPatch(typeof(Projectile), "OnProjectileHit", new Type[]
	{
		typeof(Character),
		typeof(Vector3),
		typeof(Vector3),
		typeof(bool)
	})]
	internal static class Projectile_OnProjectileHit_PvP
	{
		private static void Postfix(Projectile __instance, Character _affectedCharacter)
		{
			PvPMode.NoteNativeProjectileHit(__instance, _affectedCharacter);
		}
	}
	[HarmonyPatch(typeof(DeployableTrap), "get_TargetFactions")]
	internal static class DeployableTrap_TargetFactions_PvP
	{
		private static void Postfix(DeployableTrap __instance, ref Factions[] __result)
		{
			if (RaidModeConfig.HasPersonalPvpEnabled(((Object)(object)__instance == (Object)null) ? null : ((EffectSynchronizer)__instance).SourceCharacter))
			{
				__result = PvPMode.IncludePlayerFaction(__result);
			}
		}
	}
	[HarmonyPatch(typeof(DeployableTrap), "OnReceiveArmTrap", new Type[]
	{
		typeof(string),
		typeof(int),
		typeof(bool)
	})]
	internal static class DeployableTrap_OnReceiveArmTrap_PvP
	{
		private static void Postfix(DeployableTrap __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && RaidModeConfig.HasPersonalPvpEnabled(((EffectSynchronizer)__instance).SourceCharacter))
			{
				TrapTrigger componentInChildren = ((Component)__instance).GetComponentInChildren<TrapTrigger>(true);
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.SetTargetableFactions(PvPMode.IncludePlayerFaction(__instance.TargetFactions));
				}
				((EffectSynchronizer)__instance).ReprocessEffects();
			}
		}
	}
	[HarmonyPatch(typeof(TrapTrigger), "OnTriggerEnter", new Type[] { typeof(Collider) })]
	internal static class TrapTrigger_OnTriggerEnter_PvP
	{
		private static bool Prefix(TrapTrigger __instance, Collider _other)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			Character val = (((Object)(object)_other == (Object)null) ? null : ((Component)_other).GetComponent<Character>());
			if ((Object)(object)val == (Object)null || (int)val.PlayerType == 0)
			{
				return true;
			}
			Character trapSource = PvPMode.GetTrapSource(__instance);
			bool flag = (Object)(object)trapSource == (Object)null || (int)trapSource.PlayerType == 0 || PvPMode.CanAttack(trapSource, val);
			PvPMode.Trace("Gatilho de armadilha", trapSource, val, flag ? "permitido" : "bloqueado");
			return flag;
		}
	}
	[HarmonyPatch(typeof(EffectSynchronizer), "SynchronizeEffects", new Type[]
	{
		typeof(EffectCategories),
		typeof(Character),
		typeof(Vector3),
		typeof(Vector3)
	})]
	internal static class EffectSynchronizer_SynchronizeEffects_PvP
	{
		private static bool Prefix(EffectSynchronizer __instance, Character _affectedCharacter)
		{
			Character effectOwner = PvPMode.GetEffectOwner(__instance);
			if (PvPMode.UsesPvpTargeting((SubEffect)(object)((__instance is SubEffect) ? __instance : null)) && ((Object)(object)effectOwner == (Object)(object)_affectedCharacter || PvPMode.IsPvpPair(effectOwner, _affectedCharacter)))
			{
				bool flag = PvPMode.CanAttack(effectOwner, _affectedCharacter);
				PvPMode.Trace("Efeito sincronizado", effectOwner, _affectedCharacter, (((Object)(object)__instance == (Object)null) ? "desconhecido" : ((object)__instance).GetType().Name) + "=" + (flag ? "permitido" : "bloqueado"));
				return flag;
			}
			bool flag2 = !PvPMode.IsPvpPair(effectOwner, _affectedCharacter) || PvPMode.CanAttack(effectOwner, _affectedCharacter);
			if (PvPMode.IsPvpPair(effectOwner, _affectedCharacter))
			{
				PvPMode.Trace("Efeito sincronizado", effectOwner, _affectedCharacter, (((Object)(object)__instance == (Object)null) ? "desconhecido" : ((object)__instance).GetType().Name) + "=" + (flag2 ? "permitido" : "bloqueado"));
			}
			return flag2;
		}
	}
	[HarmonyPatch(typeof(QuestEventManager), "SetQuestEventStack")]
	public class QuestEventManager_SetQuestEventStack
	{
		public static bool Prefix(QuestEventManager __instance, string _eventUID, int _stackAmount, bool _sendEvent, ref bool __result)
		{
			QuestEventData val = default(QuestEventData);
			if (!QuestEventManager.m_questEvents.TryGetValue(_eventUID, ref val))
			{
				__result = __instance.AddEvent(_eventUID, _stackAmount, _sendEvent);
				return false;
			}
			val.ResetTime();
			val.SetStack(_stackAmount);
			__instance.NotifyOnQEAddedListeners(val);
			if (_sendEvent)
			{
				if (!PhotonNetwork.isNonMasterClientInRoom)
				{
					((MonoBehaviour)__instance).photonView.RPC("SendSyncQuestEventAdd", (PhotonTargets)1, new object[2]
					{
						_eventUID,
						val.ToNetworkData()
					});
				}
				else
				{
					((MonoBehaviour)__instance).photonView.RPC("SendSetQuestEventStack", (PhotonTargets)1, new object[2] { _eventUID, _stackAmount });
				}
			}
			__result = true;
			return false;
		}
	}
	[HarmonyPatch(typeof(QuestEventManager), "AddEvent", new Type[]
	{
		typeof(string),
		typeof(int),
		typeof(bool)
	})]
	public class QuestEventManager_AddEvent
	{
		public static bool Prefix(QuestEventManager __instance, ref bool __result, string _eventUID, int _stackAmount, bool _sendEvent)
		{
			if (string.IsNullOrEmpty(_eventUID))
			{
				Debug.LogError((object)"Tryied to add event but received empty UID");
				__result = false;
				return false;
			}
			QuestEventData val = null;
			if (!QuestEventManager.m_questEvents.TryGetValue(_eventUID, ref val))
			{
				val = QuestEventData.CreateEventData(_eventUID);
				if (val == null)
				{
					__result = false;
					return false;
				}
				val.SetStack(_stackAmount);
				QuestEventManager.m_questEvents.Add(_eventUID, val);
			}
			else if (val.IsStackable)
			{
				val.IncreaseStack(_stackAmount);
			}
			if (val.IsEphemeral)
			{
				QuestEventManager.m_ephemeralEvents.Add(val.EventUID);
			}
			val.UpdateTime();
			__instance.NotifyOnQEAddedListeners(val);
			if (_sendEvent)
			{
				if (!PhotonNetwork.isNonMasterClientInRoom)
				{
					((MonoBehaviour)__instance).photonView.RPC("SendSyncQuestEventAdd", (PhotonTargets)1, new object[2]
					{
						_eventUID,
						val.ToNetworkData()
					});
				}
				else
				{
					((MonoBehaviour)__instance).photonView.RPC("SendAddQuestEvent", (PhotonTargets)1, new object[2] { _eventUID, _stackAmount });
				}
			}
			__result = true;
			return false;
		}
	}
	[HarmonyPatch(typeof(RepairEquipmentNodeAction), "OnExecute")]
	public class RepairEquipmentNodeAction_OnExecute
	{
		public static bool Prefix()
		{
			if (RaidModeConfig.LiveSettings.ShareBlacksmithRepairs)
			{
				for (int i = 0; i < CharacterManager.Instance.PlayerCharacters.Count; i++)
				{
					Character character = CharacterManager.Instance.GetCharacter(CharacterManager.Instance.PlayerCharacters.Values[i]);
					if (Object.op_Implicit((Object)(object)character) && Object.op_Implicit((Object)(object)character.Inventory))
					{
						character.Inventory.RepairEverything(false);
					}
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(RestingMenu), "StartInit")]
	public class RestingMenu_StartInit
	{
		public static void Postfix(RestingMenu __instance)
		{
			if (Object.op_Implicit((Object)(object)__instance.m_sldOtherPlayerCursorTemplate))
			{
				for (int i = 0; i < __instance.m_sldOtherPlayerCursors.Length; i++)
				{
					Object.Destroy((Object)(object)((Component)__instance.m_sldOtherPlayerCursors[i]).gameObject);
					__instance.m_sldOtherPlayerCursors[i] = null;
				}
				__instance.m_sldOtherPlayerCursors = (Slider[])(object)new Slider[19];
				((Component)__instance.m_sldOtherPlayerCursorTemplate).gameObject.SetActive(true);
				for (int j = 0; j < __instance.m_sldOtherPlayerCursors.Length; j++)
				{
					__instance.m_sldOtherPlayerCursors[j] = Object.Instantiate<Slider>(__instance.m_sldOtherPlayerCursorTemplate);
					((Component)__instance.m_sldOtherPlayerCursors[j]).transform.SetParent(((Component)__instance.m_sldOtherPlayerCursorTemplate).transform.parent);
					UnityEngineExtensions.ResetRectTrans(((Component)__instance.m_sldOtherPlayerCursors[j]).transform);
					((Component)__instance.m_sldOtherPlayerCursors[j]).transform.Translate(0f, (float)(j + 1), 0f);
				}
				((Component)__instance.m_sldOtherPlayerCursorTemplate).gameObject.SetActive(false);
				__instance.ResetMenu();
			}
		}
	}
	[HarmonyPatch(typeof(RoomCreationPanel), "Show", new Type[]
	{
		typeof(string),
		typeof(UnityAction<string>),
		typeof(UnityAction)
	})]
	public class RoomCreationPanel_Show
	{
		public static bool Prefix(RoomCreationPanel __instance)
		{
			if (RaidModeConfig.LiveSettings.HideRoomName)
			{
				__instance.m_txtRoomName.inputType = (InputType)2;
			}
			else
			{
				__instance.m_txtRoomName.inputType = (InputType)0;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(RPCManager), "SendItemSplitSyncToMaster")]
	public class RPCManager_SendItemSplitSyncToMaster
	{
		public static bool Prefix(RPCManager __instance, string _itemInfos)
		{
			((MonoBehaviour)__instance).photonView.RPC("SendItemSyncRPC", (PhotonTargets)1, new object[2] { _itemInfos, true });
			return false;
		}
	}
	[HarmonyPatch(typeof(Sleepable), "CheckProximity")]
	public class Sleepable_CheckProximity
	{
		public static bool Prefix(Sleepable __instance, ref int __result, Character _character)
		{
			//IL_0051: 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)
			if (RaidModeConfig.LiveSettings.CozyBeds && __instance.IsInnsBed)
			{
				__instance.Capacity = 2;
			}
			else
			{
				__instance.Capacity = 1;
			}
			int num = 0;
			if ((Object)(object)Cha