Decompiled source of AttributeInheritance v1.0.5

AttributeInheritance.dll

Decompiled 17 hours ago
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace FundeAtributo;

[BepInPlugin("yuri.AttributeInheritance", "Attribute Inheritance", "1.0.5")]
public class Plugin : BaseUnityPlugin
{
	public class Bonus
	{
		public float fogo;

		public float gelo;

		public float raio;

		public float veneno;

		public float espirito;

		public string resistencias;

		public string equipar;

		public string ataque;

		public float bloqueio;

		public float defesa;

		public float aparar;

		public float adrenalina;

		public string parada;

		public bool Tem()
		{
			if (fogo > 0.1f || gelo > 0.1f || raio > 0.1f || veneno > 0.1f || espirito > 0.1f)
			{
				return true;
			}
			if (bloqueio > 0.1f || defesa > 0.1f || aparar > 0.01f || adrenalina > 0.1f)
			{
				return true;
			}
			if (resistencias != null && resistencias != "")
			{
				return true;
			}
			if (equipar != null && equipar != "")
			{
				return true;
			}
			if (ataque != null && ataque != "")
			{
				return true;
			}
			if (parada != null && parada != "")
			{
				return true;
			}
			return false;
		}

		public string Texto()
		{
			string text = "";
			if (espirito > 0.1f)
			{
				text = Somar(text, "spirit " + (int)espirito);
			}
			if (fogo > 0.1f)
			{
				text = Somar(text, "fire " + (int)fogo);
			}
			if (gelo > 0.1f)
			{
				text = Somar(text, "frost " + (int)gelo);
			}
			if (raio > 0.1f)
			{
				text = Somar(text, "lightning " + (int)raio);
			}
			if (veneno > 0.1f)
			{
				text = Somar(text, "poison " + (int)veneno);
			}
			if (bloqueio > 0.1f)
			{
				text = Somar(text, "block " + (int)bloqueio);
			}
			if (aparar > 1.05f)
			{
				text = Somar(text, "parry");
			}
			if (adrenalina > 0.1f)
			{
				text = Somar(text, "parry adrenaline " + (int)adrenalina);
			}
			if (resistencias != null && resistencias != "")
			{
				text = Somar(text, NomeRes(resistencias));
			}
			if (equipar != null && equipar != "")
			{
				text = Somar(text, DescreverEfeitos(equipar));
			}
			if (ataque != null && ataque != "")
			{
				text = Somar(text, "attack effect");
			}
			return text;
		}

		private static string Somar(string texto, string pedaco)
		{
			if (texto == "")
			{
				return pedaco;
			}
			return texto + ", " + pedaco;
		}
	}

	[HarmonyPatch(typeof(ItemData), "GetDamage", new Type[]
	{
		typeof(int),
		typeof(float)
	})]
	private static class AoDano
	{
		private static void Postfix(ItemData __instance, ref DamageTypes __result)
		{
			if (!((Object)(object)Inst == (Object)null) && Inst.Ligado.Value)
			{
				Bonus bonus = LerGravado(__instance);
				AplicarDano(ref __result, bonus);
			}
		}
	}

	[HarmonyPatch(typeof(ItemData), "GetBaseBlockPower", new Type[] { typeof(int) })]
	private static class AoBloqueio
	{
		private static void Postfix(ItemData __instance, ref float __result)
		{
			if (!((Object)(object)Inst == (Object)null) && Inst.Ligado.Value)
			{
				Bonus bonus = LerGravado(__instance);
				if (bonus.bloqueio > __result)
				{
					__result = bonus.bloqueio;
				}
			}
		}
	}

	[HarmonyPatch(typeof(ItemData), "GetDeflectionForce", new Type[] { typeof(int) })]
	private static class AoDefesa
	{
		private static void Postfix(ItemData __instance, ref float __result)
		{
			if (!((Object)(object)Inst == (Object)null) && Inst.Ligado.Value)
			{
				Bonus bonus = LerGravado(__instance);
				if (bonus.defesa > __result)
				{
					__result = bonus.defesa;
				}
			}
		}
	}

	[HarmonyPatch(typeof(Humanoid), "BlockAttack")]
	private static class AoAparar
	{
		private static void Prefix(Humanoid __instance, ItemData ___m_leftItem, ItemData ___m_rightItem)
		{
			TrocaParada.Entrar(__instance, ___m_leftItem, ___m_rightItem);
		}

		private static void Postfix()
		{
			TrocaParada.Sair();
		}
	}

	private static class TrocaParada
	{
		private static int profundidade;

		private static ItemData itemA;

		private static ItemData itemB;

		private static float paradaA;

		private static float paradaB;

		private static float adrenalinaA;

		private static float adrenalinaB;

		private static StatusEffect efeitoA;

		private static StatusEffect efeitoB;

		private static bool mexeuA;

		private static bool mexeuB;

		private static int extrasA;

		private static int extrasB;

		public static void Entrar(Humanoid quem, ItemData esquerda, ItemData direita)
		{
			if (profundidade == 0)
			{
				Preparar(quem, esquerda, direita);
			}
			profundidade++;
		}

		public static void Sair()
		{
			profundidade--;
			if (profundidade <= 0)
			{
				profundidade = 0;
				Restaurar(itemA, paradaA, adrenalinaA, efeitoA, mexeuA, extrasA);
				Restaurar(itemB, paradaB, adrenalinaB, efeitoB, mexeuB, extrasB);
				itemA = null;
				itemB = null;
				mexeuA = false;
				mexeuB = false;
				extrasA = 0;
				extrasB = 0;
			}
		}

		private static void Restaurar(ItemData item, float parada, float adrenalina, StatusEffect efeito, bool mexeu, int extras)
		{
			if (item != null && item.m_shared != null && item.m_shared.m_damageModifiers != null)
			{
				while (extras > 0 && item.m_shared.m_damageModifiers.Count > 0)
				{
					item.m_shared.m_damageModifiers.RemoveAt(item.m_shared.m_damageModifiers.Count - 1);
					extras--;
				}
			}
			if (mexeu && item != null && item.m_shared != null)
			{
				item.m_shared.m_timedBlockBonus = parada;
				item.m_shared.m_perfectBlockAdrenaline = adrenalina;
				item.m_shared.m_perfectBlockStatusEffect = efeito;
			}
		}

		private static void Preparar(Humanoid quem, ItemData esquerda, ItemData direita)
		{
			mexeuA = false;
			mexeuB = false;
			itemA = null;
			itemB = null;
			if (!((Object)(object)Inst == (Object)null) && Inst.Ligado.Value && !((Object)(object)quem != (Object)(object)Player.m_localPlayer))
			{
				mexeuA = PrepararItem(esquerda, out itemA, out paradaA, out adrenalinaA, out efeitoA, out extrasA);
				mexeuB = PrepararItem(direita, out itemB, out paradaB, out adrenalinaB, out efeitoB, out extrasB);
			}
		}

		private static bool PrepararItem(ItemData item, out ItemData guardado, out float parada, out float adrenalina, out StatusEffect efeito, out int extras)
		{
			guardado = null;
			parada = 0f;
			adrenalina = 0f;
			efeito = null;
			extras = 0;
			if (item == null || item.m_shared == null)
			{
				return false;
			}
			Bonus bonus = LerGravado(item);
			float timedBlockBonus = item.m_shared.m_timedBlockBonus;
			float perfectBlockAdrenaline = item.m_shared.m_perfectBlockAdrenaline;
			StatusEffect perfectBlockStatusEffect = item.m_shared.m_perfectBlockStatusEffect;
			bool flag = false;
			if (bonus.aparar > timedBlockBonus)
			{
				item.m_shared.m_timedBlockBonus = bonus.aparar;
				flag = true;
			}
			if (bonus.adrenalina > perfectBlockAdrenaline)
			{
				item.m_shared.m_perfectBlockAdrenaline = bonus.adrenalina;
				flag = true;
			}
			if ((Object)(object)perfectBlockStatusEffect == (Object)null && bonus.parada != null && bonus.parada != "")
			{
				string nome = bonus.parada.Split(new char[1] { ',' })[0];
				StatusEffect val = AcharEfeito(nome);
				if ((Object)(object)val != (Object)null)
				{
					item.m_shared.m_perfectBlockStatusEffect = val;
					flag = true;
				}
			}
			extras = InjetarRes(item, bonus.resistencias);
			if (extras > 0)
			{
				flag = true;
			}
			if (!flag)
			{
				return false;
			}
			guardado = item;
			parada = timedBlockBonus;
			adrenalina = perfectBlockAdrenaline;
			efeito = perfectBlockStatusEffect;
			return true;
		}

		private static int InjetarRes(ItemData item, string res)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			if (item == null || item.m_shared == null || res == null || res == "")
			{
				return 0;
			}
			if (item.m_shared.m_damageModifiers == null)
			{
				item.m_shared.m_damageModifiers = new List<DamageModPair>();
			}
			int num = 0;
			string[] array = res.Split(new char[1] { ',' });
			for (int i = 0; i < array.Length; i++)
			{
				string[] array2 = array[i].Split(new char[1] { '=' });
				if (array2.Length != 2)
				{
					continue;
				}
				try
				{
					DamageType val = (DamageType)Enum.Parse(typeof(DamageType), array2[0]);
					DamageModifier val2 = (DamageModifier)Enum.Parse(typeof(DamageModifier), array2[1]);
					if (Forca(val2) >= 3 && Forca(val2) > Forca(ModNaLista(item, val)))
					{
						DamageModPair item2 = new DamageModPair
						{
							m_type = val,
							m_modifier = val2
						};
						item.m_shared.m_damageModifiers.Add(item2);
						num++;
					}
				}
				catch
				{
				}
			}
			return num;
		}

		private static DamageModifier ModNaLista(ItemData item, DamageType tipo)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			List<DamageModPair> damageModifiers = item.m_shared.m_damageModifiers;
			DamageModifier val = (DamageModifier)0;
			for (int i = 0; i < damageModifiers.Count; i++)
			{
				if (damageModifiers[i].m_type == tipo && Forca(damageModifiers[i].m_modifier) > Forca(val))
				{
					val = damageModifiers[i].m_modifier;
				}
			}
			return val;
		}
	}

	[HarmonyPatch(typeof(ItemData), "AddBlockTooltip")]
	private static class MostraAparo
	{
		private static ItemData item;

		private static bool mexeuAparo;

		private static bool mexeuAdrenalina;

		private static float aparoAntes;

		private static float adrenalinaAntes;

		private static void Prefix(ItemData __instance)
		{
			item = null;
			mexeuAparo = false;
			mexeuAdrenalina = false;
			if (!((Object)(object)Inst == (Object)null) && Inst.Ligado.Value && __instance != null && __instance.m_shared != null)
			{
				Bonus bonus = LerGravado(__instance);
				if (bonus.aparar > __instance.m_shared.m_timedBlockBonus)
				{
					aparoAntes = __instance.m_shared.m_timedBlockBonus;
					__instance.m_shared.m_timedBlockBonus = bonus.aparar;
					mexeuAparo = true;
					item = __instance;
				}
				if (bonus.adrenalina > __instance.m_shared.m_perfectBlockAdrenaline)
				{
					adrenalinaAntes = __instance.m_shared.m_perfectBlockAdrenaline;
					__instance.m_shared.m_perfectBlockAdrenaline = bonus.adrenalina;
					mexeuAdrenalina = true;
					item = __instance;
				}
			}
		}

		private static void Postfix()
		{
			if (item != null && item.m_shared != null)
			{
				if (mexeuAparo)
				{
					item.m_shared.m_timedBlockBonus = aparoAntes;
				}
				if (mexeuAdrenalina)
				{
					item.m_shared.m_perfectBlockAdrenaline = adrenalinaAntes;
				}
			}
			item = null;
			mexeuAparo = false;
			mexeuAdrenalina = false;
		}
	}

	[HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[] { typeof(int) })]
	private static class AoDica
	{
		private static void Postfix(ItemData __instance, ref string __result)
		{
			if (!((Object)(object)Inst == (Object)null) && Inst.Ligado.Value)
			{
				Bonus bonus = LerGravado(__instance);
				if (bonus.Tem())
				{
					__result = __result + "\nFused attribute: " + bonus.Texto();
				}
			}
		}
	}

	[HarmonyPatch(typeof(Character), "GetDamageModifiers")]
	private static class AoResistencia
	{
		private static void Postfix(Character __instance, ref DamageModifiers __result)
		{
			if ((Object)(object)Inst == (Object)null || !Inst.Ligado.Value || (Object)(object)__instance != (Object)(object)Player.m_localPlayer)
			{
				return;
			}
			List<ItemData> equippedItems = ((Humanoid)Player.m_localPlayer).GetInventory().GetEquippedItems();
			for (int i = 0; i < equippedItems.Count; i++)
			{
				if (Familia(equippedItems[i]) != 2)
				{
					Bonus bonus = LerGravado(equippedItems[i]);
					AplicarRes(ref __result, bonus.resistencias);
				}
			}
		}
	}

	[HarmonyPatch(typeof(Humanoid), "UpdateEquipmentStatusEffects")]
	private static class AoEquipar
	{
		private static void Postfix(Humanoid __instance)
		{
			if (!((Object)(object)Inst == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
			{
				ManterEfeitos(Player.m_localPlayer);
			}
		}
	}

	[HarmonyPatch(typeof(Attack), "DoMeleeAttack")]
	private static class GolpePerto
	{
		private static void Prefix(Humanoid ___m_character)
		{
			TrocaEfeito.Entrar(___m_character);
		}

		private static void Postfix()
		{
			TrocaEfeito.Sair();
		}
	}

	[HarmonyPatch(typeof(Attack), "FireProjectileBurst")]
	private static class GolpeLonge
	{
		private static void Prefix(Humanoid ___m_character)
		{
			TrocaEfeito.Entrar(___m_character);
		}

		private static void Postfix()
		{
			TrocaEfeito.Sair();
		}
	}

	private static class TrocaEfeito
	{
		private static int profundidade;

		private static ItemData item;

		private static StatusEffect anterior;

		public static void Entrar(Humanoid quem)
		{
			if (profundidade == 0)
			{
				Preparar(quem);
			}
			profundidade++;
		}

		public static void Sair()
		{
			profundidade--;
			if (profundidade <= 0)
			{
				profundidade = 0;
				if (item != null && item.m_shared != null)
				{
					item.m_shared.m_attackStatusEffect = anterior;
				}
				item = null;
				anterior = null;
			}
		}

		private static void Preparar(Humanoid quem)
		{
			item = null;
			anterior = null;
			if ((Object)(object)Inst == (Object)null || !Inst.Ligado.Value || (Object)(object)quem != (Object)(object)Player.m_localPlayer)
			{
				return;
			}
			ItemData currentWeapon = quem.GetCurrentWeapon();
			if (currentWeapon != null && currentWeapon.m_shared != null && !((Object)(object)currentWeapon.m_shared.m_attackStatusEffect != (Object)null))
			{
				Bonus bonus = LerGravado(currentWeapon);
				StatusEffect val = AcharEfeito(bonus.ataque);
				if (!((Object)(object)val == (Object)null))
				{
					item = currentWeapon;
					anterior = currentWeapon.m_shared.m_attackStatusEffect;
					currentWeapon.m_shared.m_attackStatusEffect = val;
				}
			}
		}
	}

	[HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")]
	private static class SoltaCursor
	{
		private static void Postfix()
		{
			if (Aberto)
			{
				ZCursor.LockState = (CursorLockMode)0;
				ZCursor.Show();
			}
		}
	}

	[HarmonyPatch(typeof(Player), "TakeInput")]
	private static class SemJogo
	{
		private static void Postfix(ref bool __result)
		{
			if (Aberto)
			{
				__result = false;
			}
		}
	}

	[HarmonyPatch(typeof(PlayerController), "TakeInput")]
	private static class SemComando
	{
		private static void Postfix(ref bool __result)
		{
			if (Aberto)
			{
				__result = false;
			}
		}
	}

	[HarmonyPatch(typeof(Menu), "Update")]
	private static class SemPausa
	{
		private static bool Prefix()
		{
			if (quadroSemPausa == Time.frameCount)
			{
				return false;
			}
			if (!Aberto || !ZInput.GetKeyDown((KeyCode)27, true))
			{
				return true;
			}
			Aberto = false;
			quadroSemPausa = Time.frameCount;
			return false;
		}
	}

	[HarmonyPatch(typeof(ZInput), "GetMouseDelta")]
	private static class SemOlhar
	{
		private static bool Prefix(ref Vector2 __result)
		{
			//IL_000a: 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)
			if (!Aberto)
			{
				return true;
			}
			__result = Vector2.zero;
			return false;
		}
	}

	[HarmonyPatch(typeof(ZInput), "GetMouseButton")]
	private static class SemClique
	{
		private static bool Prefix(ref bool __result)
		{
			if (!Aberto)
			{
				return true;
			}
			__result = false;
			return false;
		}
	}

	[HarmonyPatch(typeof(ZInput), "GetMouseButtonUp")]
	private static class SemSolta
	{
		private static bool Prefix(ref bool __result)
		{
			if (!Aberto)
			{
				return true;
			}
			__result = false;
			return false;
		}
	}

	[HarmonyPatch(typeof(InventoryGui), "DoCrafting")]
	private static class GuardaMelhoria
	{
		private static void Prefix(InventoryGui __instance)
		{
			DentroMelhoria++;
			LimparPeca();
			if (!(CampoMelhoria == null))
			{
				object? value = CampoMelhoria.GetValue(__instance);
				GuardarPeca((ItemData)((value is ItemData) ? value : null));
			}
		}

		private static void Postfix()
		{
			DentroMelhoria--;
			if (DentroMelhoria < 0)
			{
				DentroMelhoria = 0;
			}
			LimparPeca();
		}
	}

	[HarmonyPatch(typeof(Inventory), "RemoveItem", new Type[] { typeof(ItemData) })]
	private static class GuardaAoTirar
	{
		private static void Prefix(ItemData item)
		{
			if (DentroMelhoria > 0)
			{
				GuardarPeca(item);
			}
		}
	}

	[HarmonyPatch(typeof(Inventory), "AddItem", new Type[]
	{
		typeof(string),
		typeof(int),
		typeof(int),
		typeof(int),
		typeof(long),
		typeof(string),
		typeof(Vector2i),
		typeof(bool),
		typeof(bool),
		typeof(bool)
	})]
	private static class CopiaNaMelhoria
	{
		private static void Postfix(ItemData __result)
		{
			if (DentroMelhoria > 0)
			{
				ColarPeca(__result);
			}
		}
	}

	[HarmonyPatch(typeof(Inventory), "AddItem", new Type[]
	{
		typeof(string),
		typeof(int),
		typeof(int),
		typeof(int),
		typeof(long),
		typeof(string),
		typeof(bool),
		typeof(bool)
	})]
	private static class CopiaNaMelhoriaCurta
	{
		private static void Postfix(ItemData __result)
		{
			if (DentroMelhoria > 0)
			{
				ColarPeca(__result);
			}
		}
	}

	private const string Chave = "yuri.funde";

	public static Plugin Inst;

	public static bool Aberto;

	private static int quadroSemPausa;

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

	private ConfigEntry<bool> Ligado;

	private ConfigEntry<string> Tecla;

	private ConfigEntry<int> Largura;

	private ConfigEntry<int> Altura;

	public static FieldInfo CampoMelhoria;

	public static Dictionary<string, string> DadosMelhoria;

	public static string NomeMelhoria;

	public static string PrefabMelhoria;

	public static int DentroMelhoria;

	private ItemData origem;

	private ItemData destino;

	private Vector2 rolagem;

	private static Texture2D fundo;

	private static GUIStyle titulo;

	private static GUIStyle texto;

	private void Awake()
	{
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Expected O, but got Unknown
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Expected O, but got Unknown
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Expected O, but got Unknown
		Inst = this;
		Ligado = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Shield with shield: the one that stays keeps the parry, the parry adrenaline and the higher defense. Armor passes the effect. Only your own game needs this mod.");
		Tecla = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Key", "F7", "Key that opens the window.");
		Largura = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Width", 552, new ConfigDescription("Window width on the X axis.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(360, 1600), new object[0]));
		Altura = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Height", 700, new ConfigDescription("Window height on the Y axis.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(360, 1400), new object[0]));
		CampoMelhoria = typeof(InventoryGui).GetField("m_craftUpgradeItem", BindingFlags.Instance | BindingFlags.NonPublic);
		Harmony val = new Harmony("yuri.AttributeInheritance");
		val.PatchAll(typeof(Plugin).Assembly);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Attribute Inheritance 1.0.5");
	}

	private void Update()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		if (!Ligado.Value || (Object)(object)Player.m_localPlayer == (Object)null)
		{
			if (Aberto)
			{
				Aberto = false;
			}
			return;
		}
		if (Input.GetKeyDown(LerTecla()))
		{
			Aberto = !Aberto;
		}
		if (Aberto && Input.GetKeyDown((KeyCode)27))
		{
			Aberto = false;
			quadroSemPausa = Time.frameCount;
		}
		ManterEfeitos(Player.m_localPlayer);
	}

	private KeyCode LerTecla()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			return (KeyCode)Enum.Parse(typeof(KeyCode), Tecla.Value);
		}
		catch
		{
			return (KeyCode)288;
		}
	}

	private static Texture2D Fundo()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)fundo != (Object)null)
		{
			return fundo;
		}
		fundo = new Texture2D(1, 1);
		fundo.SetPixel(0, 0, new Color(0.06f, 0.06f, 0.06f, 0.96f));
		fundo.Apply();
		return fundo;
	}

	private static void GarantirEstilo()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Expected O, but got Unknown
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Expected O, but got Unknown
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Expected O, but got Unknown
		if (texto == null)
		{
			texto = new GUIStyle(GUI.skin.label);
			texto.fontSize = 16;
			texto.wordWrap = true;
			texto.richText = false;
			texto.normal.textColor = Color.white;
			texto.padding = new RectOffset(0, 0, 2, 8);
			titulo = new GUIStyle(texto);
			titulo.fontSize = 22;
			titulo.padding = new RectOffset(0, 0, 0, 10);
		}
	}

	private static void Linha(string frase, GUIStyle estilo, float largura)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Expected O, but got Unknown
		float num = estilo.CalcHeight(new GUIContent(frase), largura);
		if (num < (float)estilo.fontSize + 8f)
		{
			num = (float)estilo.fontSize + 8f;
		}
		GUILayout.Label(frase, estilo, (GUILayoutOption[])(object)new GUILayoutOption[2]
		{
			GUILayout.Width(largura),
			GUILayout.Height(num)
		});
	}

	private void OnGUI()
	{
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		if (!Aberto || !Ligado.Value || (Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		GarantirEstilo();
		float num = Largura.Value;
		float num2 = Altura.Value;
		if (num < 360f)
		{
			num = 360f;
		}
		if (num2 < 360f)
		{
			num2 = 360f;
		}
		float num3 = num - 32f;
		float num4 = num2 - 380f;
		if (num4 < 70f)
		{
			num4 = 70f;
		}
		Rect val = default(Rect);
		((Rect)(ref val))..ctor(20f, 20f, num, num2);
		GUI.DrawTexture(val, (Texture)(object)Fundo());
		GUILayout.BeginArea(new Rect(((Rect)(ref val)).x + 16f, ((Rect)(ref val)).y + 14f, num3, ((Rect)(ref val)).height - 28f));
		Linha("Attribute Inheritance", titulo, num3);
		Linha("Helmet, chest, legs, cape and gloves pass effects to each other.", texto, num3);
		Linha("Shield: first the one that is used up, then the one that stays. The one that stays keeps the parry, the parry adrenaline and the higher defense.", texto, num3);
		Linha("While this window is open the character does not walk, look or attack.", texto, num3);
		List<ItemData> list = Itens(Player.m_localPlayer);
		rolagem = GUILayout.BeginScrollView(rolagem, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num4) });
		for (int i = 0; i < list.Count; i++)
		{
			ItemData val2 = list[i];
			string text = "";
			if (val2 == origem)
			{
				text = "  [gives]";
			}
			else if (val2 == destino)
			{
				text = "  [gets]";
			}
			if (GUILayout.Button(Nome(val2) + text, (GUILayoutOption[])(object)new GUILayoutOption[0]))
			{
				Escolher(val2);
			}
		}
		GUILayout.EndScrollView();
		Linha(Resumo(), texto, num3);
		GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
		if (GUILayout.Button("Fuse", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) }))
		{
			Fundir(Player.m_localPlayer);
		}
		if (GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) }))
		{
			origem = null;
			destino = null;
		}
		if (GUILayout.Button("Close", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) }))
		{
			Aberto = false;
		}
		GUILayout.EndHorizontal();
		GUILayout.EndArea();
	}

	private void Escolher(ItemData item)
	{
		if (origem == null || origem == item)
		{
			origem = item;
			if (destino == item)
			{
				destino = null;
			}
		}
		else
		{
			destino = item;
		}
	}

	private string Resumo()
	{
		if (origem == null)
		{
			return "Nothing is giving.";
		}
		if (destino == null)
		{
			return "Gives: " + Nome(origem) + ". Pick who receives.";
		}
		return "Gives: " + Nome(origem) + "  ->  Receives: " + Nome(destino) + "\n" + TextoPassa(origem);
	}

	private void Fundir(Player jogador)
	{
		if (origem == null || destino == null || origem == destino)
		{
			Avisar(jogador, "Pick two different pieces.");
			return;
		}
		if (!((Humanoid)jogador).GetInventory().ContainsItem(origem) || !((Humanoid)jogador).GetInventory().ContainsItem(destino))
		{
			Avisar(jogador, "That piece is no longer in the bag.");
			origem = null;
			destino = null;
			return;
		}
		if (Familia(origem) == 0 || Familia(origem) != Familia(destino))
		{
			Avisar(jogador, "Only a weapon with a weapon, armor with armor, and a shield with a shield.");
			return;
		}
		Bonus bonus = LerDoItem(origem);
		if (!bonus.Tem())
		{
			Avisar(jogador, "That piece has no attribute to pass.");
			return;
		}
		Bonus ja = LerGravado(destino);
		if (Familia(destino) == 2)
		{
			ja = Juntar(ja, LerDoItem(destino));
		}
		Bonus bonus2 = Juntar(ja, bonus);
		if (origem.m_equipped)
		{
			((Humanoid)jogador).UnequipItem(origem, false);
		}
		if (!((Humanoid)jogador).GetInventory().RemoveOneItem(origem))
		{
			Avisar(jogador, "Could not remove the piece that gives.");
			return;
		}
		Gravar(destino, bonus2);
		if (Familia(destino) == 2)
		{
			Avisar(jogador, "The shield that stayed keeps the parry, the parry adrenaline and the higher defense.");
		}
		else
		{
			Avisar(jogador, "Attribute passed to " + Nome(destino) + ".");
		}
		origem = null;
		destino = null;
		ManterEfeitos(jogador);
	}

	private static void Avisar(Player jogador, string texto)
	{
		((Character)jogador).Message((MessageType)2, texto, 0, (Sprite)null, true);
	}

	private static int Familia(ItemData item)
	{
		//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_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Invalid comparison between Unknown and I4
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Invalid comparison between Unknown and I4
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Invalid comparison between Unknown and I4
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Invalid comparison between Unknown and I4
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Invalid comparison between Unknown and I4
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Invalid comparison between Unknown and I4
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Invalid comparison between Unknown and I4
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Invalid comparison between Unknown and I4
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Invalid comparison between Unknown and I4
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Invalid comparison between Unknown and I4
		if (item == null || item.m_shared == null)
		{
			return 0;
		}
		ItemType itemType = item.m_shared.m_itemType;
		if ((int)itemType == 3 || (int)itemType == 14 || (int)itemType == 22 || (int)itemType == 4 || (int)itemType == 15)
		{
			return 1;
		}
		if ((int)itemType == 5)
		{
			return 2;
		}
		if ((int)itemType == 6 || (int)itemType == 7 || (int)itemType == 11 || (int)itemType == 12 || (int)itemType == 17)
		{
			return 3;
		}
		return 0;
	}

	private static List<ItemData> Itens(Player jogador)
	{
		List<ItemData> allItems = ((Humanoid)jogador).GetInventory().GetAllItems();
		List<ItemData> list = new List<ItemData>();
		for (int i = 0; i < allItems.Count; i++)
		{
			if (Familia(allItems[i]) != 0)
			{
				list.Add(allItems[i]);
			}
		}
		return list;
	}

	private static string Nome(ItemData item)
	{
		string name = item.m_shared.m_name;
		string text = name;
		if (Localization.instance != null)
		{
			text = Localization.instance.Localize(name);
		}
		return text + "  q" + item.m_quality;
	}

	private static Bonus LerDoItem(ItemData item)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		Bonus bonus = LerGravado(item);
		DamageTypes damage = item.GetDamage();
		bonus.fogo = Maior(bonus.fogo, damage.m_fire);
		bonus.gelo = Maior(bonus.gelo, damage.m_frost);
		bonus.raio = Maior(bonus.raio, damage.m_lightning);
		bonus.veneno = Maior(bonus.veneno, damage.m_poison);
		bonus.espirito = Maior(bonus.espirito, damage.m_spirit);
		if (item.m_shared.m_damageModifiers != null)
		{
			for (int i = 0; i < item.m_shared.m_damageModifiers.Count; i++)
			{
				DamageModPair val = item.m_shared.m_damageModifiers[i];
				if (Forca(val.m_modifier) >= 3)
				{
					bonus.resistencias = PorRes(bonus.resistencias, val.m_type, val.m_modifier);
				}
			}
		}
		bonus.equipar = Acrescentar(bonus.equipar, NomeEfeito(item.m_shared.m_equipStatusEffect));
		bonus.equipar = Acrescentar(bonus.equipar, NomeEfeito(item.m_shared.m_setStatusEffect));
		bonus.ataque = Acrescentar(bonus.ataque, NomeEfeito(item.m_shared.m_attackStatusEffect));
		bonus.bloqueio = Maior(bonus.bloqueio, item.GetBaseBlockPower());
		bonus.defesa = Maior(bonus.defesa, item.GetDeflectionForce());
		bonus.aparar = Maior(bonus.aparar, item.m_shared.m_timedBlockBonus);
		bonus.adrenalina = Maior(bonus.adrenalina, item.m_shared.m_perfectBlockAdrenaline);
		bonus.parada = Acrescentar(bonus.parada, NomeEfeito(item.m_shared.m_perfectBlockStatusEffect));
		return bonus;
	}

	private static float Maior(float a, float b)
	{
		if (a > b)
		{
			return a;
		}
		return b;
	}

	private static Bonus Juntar(Bonus ja, Bonus extra)
	{
		Bonus bonus = new Bonus();
		bonus.fogo = Maior(ja.fogo, extra.fogo);
		bonus.gelo = Maior(ja.gelo, extra.gelo);
		bonus.raio = Maior(ja.raio, extra.raio);
		bonus.veneno = Maior(ja.veneno, extra.veneno);
		bonus.espirito = Maior(ja.espirito, extra.espirito);
		bonus.resistencias = MesclarRes(ja.resistencias, extra.resistencias);
		bonus.equipar = JuntarNomes(ja.equipar, extra.equipar);
		bonus.ataque = JuntarNomes(ja.ataque, extra.ataque);
		bonus.bloqueio = Maior(ja.bloqueio, extra.bloqueio);
		bonus.defesa = Maior(ja.defesa, extra.defesa);
		bonus.aparar = Maior(ja.aparar, extra.aparar);
		bonus.adrenalina = Maior(ja.adrenalina, extra.adrenalina);
		bonus.parada = JuntarNomes(ja.parada, extra.parada);
		return bonus;
	}

	private static string MesclarRes(string a, string b)
	{
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: 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)
		string text = a;
		string[] array = ((b == null) ? "" : b).Split(new char[1] { ',' });
		for (int i = 0; i < array.Length; i++)
		{
			string[] array2 = array[i].Split(new char[1] { '=' });
			if (array2.Length == 2 && !(array2[0] == ""))
			{
				try
				{
					DamageType tipo = (DamageType)Enum.Parse(typeof(DamageType), array2[0]);
					DamageModifier mod = (DamageModifier)Enum.Parse(typeof(DamageModifier), array2[1]);
					text = PorRes(text, tipo, mod);
				}
				catch
				{
				}
			}
		}
		return text;
	}

	private static string PorRes(string atual, DamageType tipo, DamageModifier mod)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: 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)
		if (Forca(mod) < 3)
		{
			return atual;
		}
		string text = ((object)tipo).ToString();
		string text2 = ((object)mod).ToString();
		int num = Forca(mod);
		string[] array = ((atual == null) ? "" : atual).Split(new char[1] { ',' });
		string text3 = "";
		bool flag = false;
		for (int i = 0; i < array.Length; i++)
		{
			string[] array2 = array[i].Split(new char[1] { '=' });
			if (array2.Length != 2 || array2[0] == "")
			{
				continue;
			}
			string text4 = array[i];
			if (array2[0] == text)
			{
				flag = true;
				try
				{
					DamageModifier mod2 = (DamageModifier)Enum.Parse(typeof(DamageModifier), array2[1]);
					if (num > Forca(mod2))
					{
						text4 = text + "=" + text2;
					}
				}
				catch
				{
					text4 = text + "=" + text2;
				}
			}
			if (text3 != "")
			{
				text3 += ",";
			}
			text3 += text4;
		}
		if (!flag)
		{
			if (text3 != "")
			{
				text3 += ",";
			}
			text3 = text3 + text + "=" + text2;
		}
		return text3;
	}

	private static int Forca(DamageModifier mod)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Invalid comparison between Unknown and I4
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Invalid comparison between Unknown and I4
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Invalid comparison between Unknown and I4
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Invalid comparison between Unknown and I4
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Invalid comparison between Unknown and I4
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Invalid comparison between Unknown and I4
		if ((int)mod == 3)
		{
			return 6;
		}
		if ((int)mod == 5)
		{
			return 5;
		}
		if ((int)mod == 1)
		{
			return 4;
		}
		if ((int)mod == 7)
		{
			return 3;
		}
		if ((int)mod == 4)
		{
			return 2;
		}
		if ((int)mod == 0)
		{
			return 1;
		}
		if ((int)mod == 8)
		{
			return 0;
		}
		if ((int)mod == 2)
		{
			return -1;
		}
		return -2;
	}

	private static void Gravar(ItemData item, Bonus bonus)
	{
		if (item.m_customData == null)
		{
			item.m_customData = new Dictionary<string, string>();
		}
		item.m_customData["yuri.funde"] = Num(bonus.fogo) + "|" + Num(bonus.gelo) + "|" + Num(bonus.raio) + "|" + Num(bonus.veneno) + "|" + Num(bonus.espirito) + "|" + Limpo(bonus.resistencias) + "|" + Limpo(bonus.equipar) + "|" + Limpo(bonus.ataque) + "|" + Num(bonus.bloqueio) + "|" + Num(bonus.defesa) + "|" + Num(bonus.aparar) + "|" + Limpo(bonus.parada) + "|" + Num(bonus.adrenalina);
	}

	private static string Num(float valor)
	{
		return valor.ToString(CultureInfo.InvariantCulture);
	}

	private static string Limpo(string texto)
	{
		if (texto == null)
		{
			return "";
		}
		return texto;
	}

	public static Bonus LerGravado(ItemData item)
	{
		Bonus bonus = new Bonus();
		if (item == null || item.m_customData == null)
		{
			return bonus;
		}
		if (!item.m_customData.TryGetValue("yuri.funde", out var value) || value == null)
		{
			return bonus;
		}
		string[] array = value.Split(new char[1] { '|' });
		if (array.Length < 8)
		{
			return bonus;
		}
		bonus.fogo = Numero(array[0]);
		bonus.gelo = Numero(array[1]);
		bonus.raio = Numero(array[2]);
		bonus.veneno = Numero(array[3]);
		bonus.espirito = Numero(array[4]);
		bonus.resistencias = array[5];
		bonus.equipar = array[6];
		bonus.ataque = array[7];
		if (array.Length >= 12)
		{
			bonus.bloqueio = Numero(array[8]);
			bonus.defesa = Numero(array[9]);
			bonus.aparar = Numero(array[10]);
			bonus.parada = array[11];
		}
		if (array.Length >= 13)
		{
			bonus.adrenalina = Numero(array[12]);
		}
		return bonus;
	}

	private static float Numero(string texto)
	{
		if (float.TryParse(texto, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
		{
			return result;
		}
		return 0f;
	}

	private static string TextoPassa(ItemData item)
	{
		Bonus bonus = LerDoItem(item);
		if (!bonus.Tem())
		{
			return "Nothing to pass.";
		}
		return "Passes: " + bonus.Texto();
	}

	private static void ManterEfeitos(Player jogador)
	{
		List<string> list = new List<string>();
		List<ItemData> equippedItems = ((Humanoid)jogador).GetInventory().GetEquippedItems();
		for (int i = 0; i < equippedItems.Count; i++)
		{
			Bonus bonus = LerGravado(equippedItems[i]);
			AdicionarNomes(list, bonus.equipar);
		}
		SEMan sEMan = ((Character)jogador).GetSEMan();
		if (sEMan == null)
		{
			return;
		}
		for (int num = EfeitosLigados.Count - 1; num >= 0; num--)
		{
			if (!list.Contains(EfeitosLigados[num]) && !EfeitoNativo(jogador, EfeitosLigados[num]))
			{
				StatusEffect val = AcharEfeito(EfeitosLigados[num]);
				if ((Object)(object)val != (Object)null)
				{
					sEMan.RemoveStatusEffect(val, true);
				}
				EfeitosLigados.RemoveAt(num);
			}
		}
		for (int j = 0; j < list.Count; j++)
		{
			StatusEffect val2 = AcharEfeito(list[j]);
			if (!((Object)(object)val2 == (Object)null))
			{
				if (!sEMan.HaveStatusEffect(val2))
				{
					sEMan.AddStatusEffect(val2, false, 1, 0f, (short)0);
				}
				if (!EfeitosLigados.Contains(list[j]))
				{
					EfeitosLigados.Add(list[j]);
				}
			}
		}
	}

	private static bool EfeitoNativo(Player jogador, string nome)
	{
		if ((Object)(object)jogador == (Object)null || ((Humanoid)jogador).GetInventory() == null || nome == null || nome == "")
		{
			return false;
		}
		List<ItemData> equippedItems = ((Humanoid)jogador).GetInventory().GetEquippedItems();
		for (int i = 0; i < equippedItems.Count; i++)
		{
			ItemData val = equippedItems[i];
			if (val != null && val.m_shared != null)
			{
				if (EfeitoEh(val.m_shared.m_equipStatusEffect, nome))
				{
					return true;
				}
				if (EfeitoEh(val.m_shared.m_setStatusEffect, nome))
				{
					return true;
				}
			}
		}
		return false;
	}

	private static bool EfeitoEh(StatusEffect efeito, string nome)
	{
		if ((Object)(object)efeito == (Object)null || nome == null || nome == "")
		{
			return false;
		}
		if (efeito.m_name == nome)
		{
			return true;
		}
		if (((Object)efeito).name == nome)
		{
			return true;
		}
		return false;
	}

	private static string NomeRes(string res)
	{
		string text = "";
		string[] array = res.Split(new char[1] { ',' });
		for (int i = 0; i < array.Length; i++)
		{
			string[] array2 = array[i].Split(new char[1] { '=' });
			if (array2.Length == 2 && !(array2[0] == ""))
			{
				string text2 = array2[0];
				switch (text2)
				{
				case "Pierce":
					text2 = "pierce";
					break;
				case "Slash":
					text2 = "slash";
					break;
				case "Blunt":
					text2 = "blunt";
					break;
				case "Fire":
					text2 = "fire";
					break;
				case "Frost":
					text2 = "frost";
					break;
				case "Lightning":
					text2 = "lightning";
					break;
				case "Poison":
					text2 = "poison";
					break;
				case "Spirit":
					text2 = "spirit";
					break;
				}
				if (text != "")
				{
					text += ", ";
				}
				text += text2;
			}
		}
		if (text == "")
		{
			return "resistance";
		}
		return "resistance to " + text;
	}

	private static string NomeEfeito(StatusEffect efeito)
	{
		if ((Object)(object)efeito == (Object)null)
		{
			return "";
		}
		string text = ((efeito.m_name == null) ? "" : efeito.m_name);
		string text2 = ((((Object)efeito).name == null) ? "" : ((Object)efeito).name);
		if (text != "" && text2 != "" && text != text2)
		{
			return text + "," + text2;
		}
		if (text != "")
		{
			return text;
		}
		return text2;
	}

	private static string JuntarNomes(string a, string b)
	{
		return Acrescentar(a, b);
	}

	private static string Acrescentar(string lista, string nomes)
	{
		string text = ((lista == null) ? "" : lista);
		if (nomes == null || nomes == "")
		{
			return text;
		}
		string[] array = nomes.Split(new char[1] { ',' });
		foreach (string text2 in array)
		{
			if (!(text2 == "") && !ContemNome(text, text2))
			{
				if (text != "")
				{
					text += ",";
				}
				text += text2;
			}
		}
		return text;
	}

	private static bool ContemNome(string lista, string nome)
	{
		if (lista == null || lista == "")
		{
			return false;
		}
		string[] array = lista.Split(new char[1] { ',' });
		for (int i = 0; i < array.Length; i++)
		{
			if (array[i] == nome)
			{
				return true;
			}
		}
		return false;
	}

	private static void AdicionarNomes(List<string> quer, string nomes)
	{
		if (nomes == null || nomes == "")
		{
			return;
		}
		string[] array = nomes.Split(new char[1] { ',' });
		for (int i = 0; i < array.Length; i++)
		{
			if (array[i] != "" && !quer.Contains(array[i]))
			{
				quer.Add(array[i]);
			}
		}
	}

	private static string DescreverEfeitos(string nomes)
	{
		bool flag = false;
		bool flag2 = false;
		string[] array = nomes.Split(new char[1] { ',' });
		for (int i = 0; i < array.Length; i++)
		{
			if (!(array[i] == ""))
			{
				if (EhFurtividade(array[i]))
				{
					flag = true;
				}
				else
				{
					flag2 = true;
				}
			}
		}
		string text = "";
		if (flag)
		{
			text = "stealth";
		}
		if (flag2)
		{
			if (text != "")
			{
				text += ", ";
			}
			text += "inherited effect";
		}
		return text;
	}

	private static bool EhFurtividade(string nome)
	{
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Invalid comparison between Unknown and I4
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Invalid comparison between Unknown and I4
		string text = nome.ToLower();
		if (text.IndexOf("sneak") >= 0 || text.IndexOf("troll") >= 0 || text.IndexOf("stealth") >= 0 || text.IndexOf("furt") >= 0)
		{
			return true;
		}
		StatusEffect val = AcharEfeito(nome);
		SE_Stats val2 = (SE_Stats)(object)((val is SE_Stats) ? val : null);
		if ((Object)(object)val2 == (Object)null)
		{
			return false;
		}
		if (val2.m_stealthModifier > 0.01f)
		{
			return true;
		}
		if ((int)val2.m_skillLevel == 101 || (int)val2.m_skillLevel2 == 101)
		{
			return true;
		}
		return false;
	}

	public static StatusEffect AcharEfeito(string nome)
	{
		if (nome == null || nome == "" || (Object)(object)ObjectDB.instance == (Object)null || ObjectDB.instance.m_StatusEffects == null)
		{
			return null;
		}
		List<StatusEffect> statusEffects = ObjectDB.instance.m_StatusEffects;
		for (int i = 0; i < statusEffects.Count; i++)
		{
			StatusEffect val = statusEffects[i];
			if (!((Object)(object)val == (Object)null))
			{
				if (val.m_name == nome)
				{
					return val;
				}
				if (((Object)val).name == nome)
				{
					return val;
				}
			}
		}
		return null;
	}

	public static void AplicarDano(ref DamageTypes dano, Bonus bonus)
	{
		if (bonus.fogo > dano.m_fire)
		{
			dano.m_fire = bonus.fogo;
		}
		if (bonus.gelo > dano.m_frost)
		{
			dano.m_frost = bonus.gelo;
		}
		if (bonus.raio > dano.m_lightning)
		{
			dano.m_lightning = bonus.raio;
		}
		if (bonus.veneno > dano.m_poison)
		{
			dano.m_poison = bonus.veneno;
		}
		if (bonus.espirito > dano.m_spirit)
		{
			dano.m_spirit = bonus.espirito;
		}
	}

	public static void AplicarRes(ref DamageModifiers mods, string res)
	{
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: 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_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		if (res == null || res == "")
		{
			return;
		}
		string[] array = res.Split(new char[1] { ',' });
		for (int i = 0; i < array.Length; i++)
		{
			string[] array2 = array[i].Split(new char[1] { '=' });
			if (array2.Length != 2)
			{
				continue;
			}
			try
			{
				DamageType tipo = (DamageType)Enum.Parse(typeof(DamageType), array2[0]);
				DamageModifier mod = (DamageModifier)Enum.Parse(typeof(DamageModifier), array2[1]);
				if (Forca(mod) > Forca(LerMod(mods, tipo)))
				{
					EscreverMod(ref mods, tipo, mod);
				}
			}
			catch
			{
			}
		}
	}

	private static DamageModifier LerMod(DamageModifiers mods, DamageType tipo)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Invalid comparison between Unknown and I4
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Invalid comparison between Unknown and I4
		//IL_0006: 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_001a: Invalid comparison between Unknown and I4
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Invalid comparison between Unknown and I4
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Invalid comparison between Unknown and I4
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Invalid comparison between Unknown and I4
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Invalid comparison between Unknown and I4
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Invalid comparison between Unknown and I4
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Invalid comparison between Unknown and I4
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Invalid comparison between Unknown and I4
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		if ((int)tipo == 1)
		{
			return mods.m_blunt;
		}
		if ((int)tipo == 2)
		{
			return mods.m_slash;
		}
		if ((int)tipo == 4)
		{
			return mods.m_pierce;
		}
		if ((int)tipo == 8)
		{
			return mods.m_chop;
		}
		if ((int)tipo == 16)
		{
			return mods.m_pickaxe;
		}
		if ((int)tipo == 32)
		{
			return mods.m_fire;
		}
		if ((int)tipo == 64)
		{
			return mods.m_frost;
		}
		if ((int)tipo == 128)
		{
			return mods.m_lightning;
		}
		if ((int)tipo == 256)
		{
			return mods.m_poison;
		}
		if ((int)tipo == 512)
		{
			return mods.m_spirit;
		}
		return (DamageModifier)0;
	}

	private static void EscreverMod(ref DamageModifiers mods, DamageType tipo, DamageModifier mod)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Invalid comparison between Unknown and I4
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Invalid comparison between Unknown and I4
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Invalid comparison between Unknown and I4
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Invalid comparison between Unknown and I4
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Invalid comparison between Unknown and I4
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Invalid comparison between Unknown and I4
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Invalid comparison between Unknown and I4
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Invalid comparison between Unknown and I4
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Invalid comparison between Unknown and I4
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Invalid comparison between Unknown and I4
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		if ((int)tipo == 1)
		{
			mods.m_blunt = mod;
		}
		else if ((int)tipo == 2)
		{
			mods.m_slash = mod;
		}
		else if ((int)tipo == 4)
		{
			mods.m_pierce = mod;
		}
		else if ((int)tipo == 8)
		{
			mods.m_chop = mod;
		}
		else if ((int)tipo == 16)
		{
			mods.m_pickaxe = mod;
		}
		else if ((int)tipo == 32)
		{
			mods.m_fire = mod;
		}
		else if ((int)tipo == 64)
		{
			mods.m_frost = mod;
		}
		else if ((int)tipo == 128)
		{
			mods.m_lightning = mod;
		}
		else if ((int)tipo == 256)
		{
			mods.m_poison = mod;
		}
		else if ((int)tipo == 512)
		{
			mods.m_spirit = mod;
		}
	}

	private static void GuardarPeca(ItemData item)
	{
		if (DadosMelhoria == null && item != null && item.m_customData != null && item.m_customData.TryGetValue("yuri.funde", out var value) && value != null && !(value == ""))
		{
			DadosMelhoria = new Dictionary<string, string>(item.m_customData);
			if (item.m_shared != null)
			{
				NomeMelhoria = item.m_shared.m_name;
			}
			if ((Object)(object)item.m_dropPrefab != (Object)null)
			{
				PrefabMelhoria = ((Object)item.m_dropPrefab).name;
			}
		}
	}

	private static void ColarPeca(ItemData item)
	{
		if (DadosMelhoria == null || item == null)
		{
			return;
		}
		bool flag = false;
		if (NomeMelhoria != null && item.m_shared != null && item.m_shared.m_name == NomeMelhoria)
		{
			flag = true;
		}
		if (!flag && PrefabMelhoria != null && (Object)(object)item.m_dropPrefab != (Object)null && ((Object)item.m_dropPrefab).name == PrefabMelhoria)
		{
			flag = true;
		}
		if (!flag)
		{
			return;
		}
		if (item.m_customData == null)
		{
			item.m_customData = new Dictionary<string, string>();
		}
		foreach (KeyValuePair<string, string> dadosMelhorium in DadosMelhoria)
		{
			if (!item.m_customData.TryGetValue(dadosMelhorium.Key, out var value) || value == null || value == "")
			{
				item.m_customData[dadosMelhorium.Key] = dadosMelhorium.Value;
			}
		}
	}

	private static void LimparPeca()
	{
		DadosMelhoria = null;
		NomeMelhoria = null;
		PrefabMelhoria = null;
	}
}