Decompiled source of Runeforged v1.1.1

plugins/Runeforged.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("Runeforged")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Runeforged")]
[assembly: AssemblyTitle("Runeforged")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 Runeforged
{
	internal class ArsenalItem
	{
		public string PrefabName;

		public string BasePrefab;

		public string MeshPath;

		public string Visual;

		public string NameEN;

		public string NamePT;

		public string DescEN;

		public string DescPT;

		public bool Hidden;

		public bool CopyBaseRecipe = true;

		public string Station;

		public int StationLevel = 1;

		public Req[] Requirements;

		public string PendulumChildMarker = "Pingente";

		public bool ShowPendant = true;

		public Dictionary<string, Action<GameObject>> ChildSetup;

		public float VisualScale = 1f;

		public float BladeWidth = 1f;

		public bool Mirror;

		public bool KeepMeshPosition;

		public bool TurnAround;

		public Vector3 ModelRotation;

		internal Quaternion MeshBaseRotation;

		internal BladeShape Shape;

		internal Transform MeshTransform;

		internal Vector3 MeshBaseScale;

		public float DamageMultiplier = 1f;

		public DamageTypes? Damages;

		public DamageTypes? DamagesPerLevel;

		public float? BlockArmor;

		public bool PulseEmission;

		public Action<CustomItem, ManualLogSource> Customize;

		public Action<ItemSettings> BindEffects;

		public Func<bool, string> DescribeEffects;

		public string Token => "item_" + PrefabName.ToLowerInvariant();

		internal void ApplyRotation()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)MeshTransform != (Object)null)
			{
				MeshTransform.localRotation = MeshBaseRotation * Quaternion.Euler(ModelRotation) * (TurnAround ? Quaternion.Euler(0f, 180f, 0f) : Quaternion.identity);
			}
		}

		internal void ApplyScale()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)MeshTransform == (Object)null))
			{
				Vector3 val = MeshBaseScale * VisualScale;
				if (Mirror)
				{
					val.x = 0f - val.x;
				}
				MeshTransform.localScale = val;
			}
		}
	}
	internal class Req
	{
		public string Item;

		public int Amount;

		public int PerLevel;

		public Req(string item, int amount, int perLevel = 0)
		{
			Item = item;
			Amount = amount;
			PerLevel = perLevel;
		}
	}
	internal class BladeShape
	{
		public const float BladeStart = 0.42f;

		public const float BladeFull = 0.5f;

		private readonly Vector3[] vertices;

		private readonly Vector3[] normals;

		private readonly Vector4[] tangents;

		private readonly BoxCollider collider;

		internal Mesh Mesh { get; }

		internal float Width { get; private set; } = 1f;

		internal BladeShape(Mesh source, string name, BoxCollider collider)
		{
			Mesh = Object.Instantiate<Mesh>(source);
			((Object)Mesh).name = name;
			vertices = source.vertices;
			normals = source.normals;
			tangents = source.tangents;
			this.collider = collider;
		}

		internal void SetWidth(float width)
		{
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: 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_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			Width = Mathf.Max(0.1f, width);
			int num = vertices.Length;
			Vector3[] array = (Vector3[])(object)new Vector3[num];
			bool flag = normals != null && normals.Length == num;
			bool flag2 = tangents != null && tangents.Length == num;
			Vector3[] array2 = (Vector3[])(object)(flag ? new Vector3[num] : null);
			Vector4[] array3 = (Vector4[])(object)(flag2 ? new Vector4[num] : null);
			for (int i = 0; i < num; i++)
			{
				float num2 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.42f, 0.5f, vertices[i].y));
				float num3 = Mathf.Lerp(1f, Width, num2);
				array[i] = new Vector3(vertices[i].x * num3, vertices[i].y, vertices[i].z);
				Vector3 val;
				if (flag)
				{
					int num4 = i;
					val = new Vector3(normals[i].x / num3, normals[i].y, normals[i].z);
					array2[num4] = ((Vector3)(ref val)).normalized;
				}
				if (flag2)
				{
					val = new Vector3(tangents[i].x * num3, tangents[i].y, tangents[i].z);
					Vector3 normalized = ((Vector3)(ref val)).normalized;
					array3[i] = new Vector4(normalized.x, normalized.y, normalized.z, tangents[i].w);
				}
			}
			Mesh.vertices = array;
			if (flag)
			{
				Mesh.normals = array2;
			}
			if (flag2)
			{
				Mesh.tangents = array3;
			}
			Mesh.RecalculateBounds();
			if ((Object)(object)collider != (Object)null)
			{
				BoxCollider obj = collider;
				Bounds bounds = Mesh.bounds;
				obj.center = ((Bounds)(ref bounds)).center;
				BoxCollider obj2 = collider;
				bounds = Mesh.bounds;
				obj2.size = ((Bounds)(ref bounds)).size;
			}
		}
	}
	internal class BloodStage
	{
		public int Number;

		public string NameEN;

		public string NamePT;

		public string Visual;

		public float Scale;

		public bool Pendant;

		public float Slash;

		public float SlashPerLevel;

		public float Spirit;

		public string StatsFrom;

		public float BleedPerStack;

		public float LifeSteal;

		public float BurstSlash;

		public float BurstSlashPerLevel;

		public bool Execution;

		public bool ShadowCut;

		public string Station;

		public int StationLevel;

		public Req[] Requirements;

		internal SE_Sangramento Bleed;

		internal GameObject Burst;

		internal SharedData Shared;

		public string Id => "Bloodheart" + Number;
	}
	internal static class BloodEffects
	{
		private const string BleedName = "SE_Runeforged_Sangramento";

		private const string BurstName = "Runeforged_ExplosaoSangue";

		private const string CutName = "Runeforged_CorteSombrio";

		private const string BaseSword = "THSwordGold_FrostFire";

		private const float BurstChance = 0.12f;

		private const float BurstRadius = 3.5f;

		internal const float ExecuteThreshold = 0.05f;

		private const float ShadowCutMultiplier = 6f;

		private const float ShadowCutHealthPercent = 33.3f;

		private const float CutSlash = 500f;

		private const float CutSlashPerLevel = 16f;

		private const float CutSpirit = 80f;

		internal static readonly Color BloodRed = new Color(0.85f, 0.03f, 0.06f);

		internal static readonly Color ShadowPurple = new Color(0.42f, 0.04f, 0.85f);

		internal static readonly BloodStage[] Stages = new BloodStage[5]
		{
			new BloodStage
			{
				Number = 1,
				NameEN = "Bloodheart",
				NamePT = "Bloodheart",
				Visual = "Bloodheart_visual",
				Scale = 1f,
				Pendant = false,
				Slash = 90f,
				SlashPerLevel = 6f,
				Spirit = 30f,
				StatsFrom = "Battleaxe",
				BleedPerStack = 3f,
				Station = CraftingStations.Forge,
				StationLevel = 2,
				Requirements = new Req[4]
				{
					new Req("Iron", 20, 10),
					new Req("Bloodbag", 10, 5),
					new Req("Chain", 3),
					new Req("TrophyDraugrElite", 1)
				}
			},
			new BloodStage
			{
				Number = 2,
				NameEN = "Bloodheart II",
				NamePT = "Bloodheart II",
				Visual = "Bloodheart_visual",
				Scale = 1.05f,
				Pendant = false,
				Slash = 110f,
				SlashPerLevel = 6f,
				Spirit = 30f,
				StatsFrom = "BattleaxeCrystal",
				BleedPerStack = 4f,
				LifeSteal = 3f,
				Station = CraftingStations.Forge,
				StationLevel = 3,
				Requirements = new Req[4]
				{
					new Req("Bloodheart1", 1),
					new Req("Silver", 20, 10),
					new Req("WolfClaw", 3),
					new Req("TrophyFenring", 1)
				}
			},
			new BloodStage
			{
				Number = 3,
				NameEN = "Bloodheart III",
				NamePT = "Bloodheart III",
				Visual = "Bloodheart_visual",
				Scale = 1.1f,
				Pendant = false,
				Slash = 130f,
				SlashPerLevel = 6f,
				Spirit = 30f,
				StatsFrom = "BattleaxeBlackmetal",
				BleedPerStack = 5f,
				LifeSteal = 3f,
				BurstSlash = 80f,
				BurstSlashPerLevel = 8f,
				Station = CraftingStations.Forge,
				StationLevel = 4,
				Requirements = new Req[4]
				{
					new Req("Bloodheart2", 1),
					new Req("BlackMetal", 20, 10),
					new Req("Needle", 10, 5),
					new Req("TrophyDeathsquito", 1)
				}
			},
			new BloodStage
			{
				Number = 4,
				NameEN = "Bloodheart IV",
				NamePT = "Bloodheart IV",
				Visual = "Bloodheart_visual",
				Scale = 1.15f,
				Pendant = true,
				Slash = 155f,
				SlashPerLevel = 6f,
				Spirit = 30f,
				StatsFrom = "THSwordKrom",
				BleedPerStack = 7f,
				LifeSteal = 4f,
				BurstSlash = 100f,
				BurstSlashPerLevel = 10f,
				Execution = true,
				Station = CraftingStations.BlackForge,
				StationLevel = 2,
				Requirements = new Req[4]
				{
					new Req("Bloodheart3", 1),
					new Req("Carapace", 15, 8),
					new Req("Eitr", 10, 5),
					new Req("TrophyTick", 1)
				}
			},
			new BloodStage
			{
				Number = 5,
				NameEN = "True Bloodheart",
				NamePT = "Bloodheart Verdadeira",
				Visual = "Bloodheart_visual",
				Scale = 1.4f,
				Pendant = true,
				Slash = 250f,
				SlashPerLevel = 8f,
				Spirit = 40f,
				StatsFrom = "THSwordGold",
				BleedPerStack = 9f,
				LifeSteal = 5f,
				BurstSlash = 125f,
				BurstSlashPerLevel = 12f,
				Execution = true,
				ShadowCut = true,
				Station = CraftingStations.BlackForge,
				StationLevel = 4,
				Requirements = new Req[4]
				{
					new Req("Bloodheart4", 1),
					new Req("Gold", 20, 10),
					new Req("OrbThunderBlood", 1),
					new Req("TrophyJotunWarrior", 1)
				}
			}
		};

		internal static readonly Dictionary<string, float> ExecutionThreshold = Stages.Where((BloodStage s) => s.Execution).ToDictionary((BloodStage s) => s.Id, (BloodStage s) => 0.05f);

		private static GameObject shadowCut;

		internal static GameObject BloodVfx;

		internal static IEnumerable<ArsenalItem> CreateItems()
		{
			BloodStage[] stages = Stages;
			foreach (BloodStage s in stages)
			{
				BloodStage stage = s;
				BloodStage next = Stages.FirstOrDefault((BloodStage x) => x.Number == s.Number + 1);
				yield return new ArsenalItem
				{
					PrefabName = s.Id,
					BasePrefab = "THSwordGold_FrostFire",
					MeshPath = "attach/Krom",
					Visual = s.Visual,
					NameEN = s.NameEN,
					NamePT = s.NamePT,
					DescEN = "A blood greatsword that evolves with you. Its veins drink the blood of every foe.",
					DescPT = "Uma espadona de sangue que evolui contigo. As veias bebem o sangue de cada inimigo.",
					DescribeEffects = (bool pt) => Describe(stage, next, pt),
					BindEffects = delegate(ItemSettings settings)
					{
						BindSettings(stage, settings);
					},
					CopyBaseRecipe = false,
					Station = s.Station,
					StationLevel = s.StationLevel,
					Requirements = s.Requirements,
					ShowPendant = s.Pendant,
					VisualScale = s.Scale,
					PulseEmission = true,
					Customize = delegate(CustomItem item, ManualLogSource log)
					{
						ApplyStage(stage, item, log);
					}
				};
			}
		}

		private static string Describe(BloodStage s, BloodStage next, bool pt)
		{
			List<string> list = new List<string>();
			if ((Object)(object)s.Bleed != (Object)null && s.Bleed.DamagePerStack > 0f)
			{
				list.Add(pt ? string.Format("{0}Sangramento{1}: cada golpe faz o inimigo sangrar ({2:0.#} por segundo, acumula até {3}).", "<color=#FF5A5A>", "</color>", s.Bleed.DamagePerStack, s.Bleed.MaxStacks) : string.Format("{0}Bleeding{1}: every hit makes the enemy bleed ({2:0.#} per second, stacks up to {3}).", "<color=#FF5A5A>", "</color>", s.Bleed.DamagePerStack, s.Bleed.MaxStacks));
			}
			float num = s.Shared?.m_attack.m_attackHealthReturnHit ?? 0f;
			if (num > 0f)
			{
				list.Add(pt ? string.Format("{0}Sede de Sangue{1}: cada golpe cura-te {2:0.#} de vida.", "<color=#FF5A5A>", "</color>", num) : string.Format("{0}Bloodthirst{1}: each hit heals you {2:0.#} health.", "<color=#FF5A5A>", "</color>", num));
			}
			if ((Object)(object)s.Burst != (Object)null && s.Shared != null && s.Shared.m_attack.m_spawnOnHitChance > 0f)
			{
				float num2 = s.Shared.m_attack.m_spawnOnHitChance * 100f;
				list.Add(pt ? string.Format("{0}Explosão de Sangue{1}: {2:0.#}% dos golpes rebentam em sangue à volta do alvo.", "<color=#FF5A5A>", "</color>", num2) : string.Format("{0}Blood Burst{1}: {2:0.#}% of hits burst in blood around the target.", "<color=#FF5A5A>", "</color>", num2));
			}
			if (ExecutionThreshold.TryGetValue(s.Id, out var value) && value > 0f)
			{
				list.Add(pt ? string.Format("{0}Execução{1}: um golpe numa criatura com {2:0.#}% de vida ou menos mata-a.", "<color=#FF5A5A>", "</color>", value * 100f) : string.Format("{0}Execution{1}: a hit on a creature at {2:0.#}% health or less kills it.", "<color=#FF5A5A>", "</color>", value * 100f));
			}
			if (s.ShadowCut && s.Shared != null)
			{
				Attack secondaryAttack = s.Shared.m_secondaryAttack;
				float num3 = secondaryAttack.m_damageMultiplier / 3f;
				float attackHealthPercentage = secondaryAttack.m_attackHealthPercentage;
				list.Add(pt ? string.Format("{0}Corte Sombrio{1}: o ataque secundário faz {2:0.#}x o dano de um golpe forte e lança um corte roxo-preto à distância, mas custa {3:0.#}% da tua vida.", "<color=#B07CFF>", "</color>", num3, attackHealthPercentage) : string.Format("{0}Shadow Cut{1}: the secondary attack deals {2:0.#}x the damage of a heavy attack and throws a purple-black cut at range, but costs {3:0.#}% of your health.", "<color=#B07CFF>", "</color>", num3, attackHealthPercentage));
			}
			if (next != null)
			{
				list.Add(pt ? ("<color=#B4B4B4>Evolui para " + next.NamePT + ".</color>") : ("<color=#B4B4B4>Evolves into " + next.NameEN + ".</color>"));
			}
			return string.Join("\n", list);
		}

		private static void BindSettings(BloodStage s, ItemSettings settings)
		{
			SharedData shared = settings.Custom.ItemDrop.m_itemData.m_shared;
			if ((Object)(object)s.Bleed != (Object)null)
			{
				SE_Sangramento bleed = s.Bleed;
				settings.Bind("Bleeding Damage Per Stack", bleed.DamagePerStack, "Bleeding damage per second for each stack (0 = no bleeding).", delegate(float v)
				{
					bleed.DamagePerStack = v;
				});
				settings.Bind("Bleeding Max Stacks", bleed.MaxStacks, "How many hits can stack the bleeding.", delegate(int v)
				{
					bleed.MaxStacks = v;
				}, (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20));
				settings.Bind("Bleeding Duration", ((StatusEffect)bleed).m_ttl, "Seconds the bleeding lasts after the last hit.", delegate(float v)
				{
					((StatusEffect)bleed).m_ttl = v;
				});
			}
			settings.Bind("Bloodthirst Heal Per Hit", s.LifeSteal, "Health you get back for every enemy hit (0 = off).", delegate(float v)
			{
				shared.m_attack.m_attackHealthReturnHit = v;
				shared.m_secondaryAttack.m_attackHealthReturnHit = v;
			});
			if ((Object)(object)s.Burst != (Object)null)
			{
				Aoe aoe = s.Burst.GetComponent<Aoe>();
				if (aoe != null)
				{
					settings.Bind("Blood Burst Chance", shared.m_attack.m_spawnOnHitChance, "Chance (0-1) that a primary hit bursts in blood.", delegate(float v)
					{
						shared.m_attack.m_spawnOnHitChance = v;
					}, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f));
					settings.Bind("Blood Burst Slash Damage", aoe.m_damage.m_slash, "Slash damage of the blood burst.", delegate(float v)
					{
						aoe.m_damage.m_slash = v;
					});
					settings.Bind("Blood Burst Slash Damage Per Level", aoe.m_damagePerLevel.m_slash, "Extra slash damage of the blood burst per upgrade level.", delegate(float v)
					{
						aoe.m_damagePerLevel.m_slash = v;
					});
					settings.Bind("Blood Burst Radius", aoe.m_radius, "Radius of the blood burst (metres).", delegate(float v)
					{
						aoe.m_radius = v;
					});
				}
			}
			if (ExecutionThreshold.ContainsKey(s.Id))
			{
				settings.Bind("Execution Health Percent", ExecutionThreshold[s.Id] * 100f, "Creatures at or below this % of health die on hit (0 = off). Never players or tames.", delegate(float v)
				{
					ExecutionThreshold[s.Id] = Mathf.Max(0f, v) / 100f;
				}, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f));
			}
			if (!s.ShadowCut)
			{
				return;
			}
			Attack sec = shared.m_secondaryAttack;
			settings.Bind("Shadow Cut Damage Multiplier", sec.m_damageMultiplier, "Damage multiplier of the secondary attack (a normal heavy attack is 3).", delegate(float v)
			{
				sec.m_damageMultiplier = v;
			});
			settings.Bind("Shadow Cut Health Cost Percent", sec.m_attackHealthPercentage, "% of your CURRENT health each Shadow Cut costs (so it never kills you).", delegate(float v)
			{
				sec.m_attackHealthPercentage = v;
			}, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 99f));
			if (!((Object)(object)shadowCut != (Object)null))
			{
				return;
			}
			CorteSombrio cut = shadowCut.GetComponent<CorteSombrio>();
			if (cut != null)
			{
				settings.Bind("Shadow Cut Slash Damage", cut.Damage.m_slash, "Slash damage of the flying cut.", delegate(float v)
				{
					cut.Damage.m_slash = v;
				});
				settings.Bind("Shadow Cut Slash Damage Per Level", cut.DamagePerLevel.m_slash, "Extra slash damage of the flying cut per upgrade level.", delegate(float v)
				{
					cut.DamagePerLevel.m_slash = v;
				});
				settings.Bind("Shadow Cut Spirit Damage", cut.Damage.m_spirit, "Spirit damage of the flying cut.", delegate(float v)
				{
					cut.Damage.m_spirit = v;
				});
				settings.Bind("Shadow Cut Speed", cut.Speed, "Speed of the flying cut (metres per second). Range = speed x lifetime.", delegate(float v)
				{
					cut.Speed = v;
				});
				settings.Bind("Shadow Cut Lifetime", cut.Life, "Seconds the flying cut lasts.", delegate(float v)
				{
					cut.Life = v;
				});
			}
		}

		internal static void AddTranslations(Dictionary<string, string> en, Dictionary<string, string> pt)
		{
			en["se_runeforged_sangramento"] = "Bleeding";
			en["se_runeforged_sangramento_tooltip"] = "Losing blood every second. Up to 3 stacks.";
			pt["se_runeforged_sangramento"] = "Sangramento";
			pt["se_runeforged_sangramento_tooltip"] = "A perder sangue a cada segundo. Acumula até 3.";
		}

		internal static void Build(ManualLogSource log)
		{
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			if ((Object)(object)Stages[0].Bleed != (Object)null)
			{
				return;
			}
			BloodVfx = BloodEffects.Find<GameObject>("fx_bloodweapon_hit");
			if ((Object)(object)BloodVfx == (Object)null)
			{
				log.LogWarning((object)"fx_bloodweapon_hit not found: blood effects will have no vfx");
			}
			GameObject obj = BloodEffects.Find<GameObject>("Bloodbag");
			Sprite icon = ((obj == null) ? null : obj.GetComponent<ItemDrop>()?.m_itemData?.m_shared?.m_icons?.FirstOrDefault());
			BloodStage[] stages = Stages;
			foreach (BloodStage bloodStage in stages)
			{
				SE_Sangramento sE_Sangramento = ScriptableObject.CreateInstance<SE_Sangramento>();
				((Object)sE_Sangramento).name = "SE_Runeforged_Sangramento" + bloodStage.Number;
				((StatusEffect)sE_Sangramento).m_name = "$se_runeforged_sangramento";
				((StatusEffect)sE_Sangramento).m_tooltip = "$se_runeforged_sangramento_tooltip";
				((StatusEffect)sE_Sangramento).m_icon = icon;
				((StatusEffect)sE_Sangramento).m_ttl = 5f;
				sE_Sangramento.DamagePerStack = bloodStage.BleedPerStack;
				if ((Object)(object)BloodVfx != (Object)null)
				{
					EffectList val = new EffectList();
					val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
					{
						new EffectData
						{
							m_prefab = BloodVfx,
							m_enabled = true,
							m_variant = -1
						}
					};
					((SE_Stats)sE_Sangramento).m_tickEffect = val;
				}
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)sE_Sangramento, false));
				bloodStage.Bleed = sE_Sangramento;
				if (bloodStage.BurstSlash > 0f && (Object)(object)BloodVfx != (Object)null)
				{
					bloodStage.Burst = MakeBurst(bloodStage, ((Object)sE_Sangramento).name);
				}
			}
			shadowCut = MakeShadowCut(log);
		}

		private static GameObject MakeBurst(BloodStage s, string bleedName)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("Runeforged_ExplosaoSangue" + s.Number, BloodVfx);
			val.transform.localScale = Vector3.one * 2.5f;
			if ((Object)(object)val.GetComponent<ZNetView>() == (Object)null)
			{
				val.AddComponent<ZNetView>().m_persistent = false;
			}
			Aoe obj = val.AddComponent<Aoe>();
			obj.m_damage = new DamageTypes
			{
				m_slash = s.BurstSlash
			};
			obj.m_damagePerLevel = new DamageTypes
			{
				m_slash = s.BurstSlashPerLevel
			};
			obj.m_radius = 3.5f;
			obj.m_attackForce = 30f;
			obj.m_statusEffect = bleedName;
			obj.m_hitOwner = false;
			obj.m_hitParent = false;
			obj.m_hitSame = false;
			obj.m_hitFriendly = false;
			obj.m_hitEnemy = true;
			obj.m_hitCharacters = true;
			obj.m_hitProps = false;
			obj.m_hitTerrain = false;
			obj.m_dodgeable = false;
			obj.m_blockable = false;
			obj.m_useTriggers = false;
			obj.m_ttl = 2f;
			PrefabManager.Instance.AddPrefab(val);
			return val;
		}

		private static GameObject MakeShadowCut(ManualLogSource log)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			return MakeCrescentCut("Runeforged_CorteSombrio", new DamageTypes
			{
				m_slash = 500f,
				m_spirit = 80f
			}, new DamageTypes
			{
				m_slash = 16f
			}, "SE_Runeforged_Sangramento" + 5, ShadowPurple, 0, log);
		}

		internal static GameObject MakeCrescentCut(string name, DamageTypes damage, DamageTypes perLevel, string statusEffect, Color color, int onComboHit, ManualLogSource log)
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_00ca: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Expected O, but got Unknown
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = PrefabManager.Instance.CreateEmptyPrefab(name, true);
			Collider[] componentsInChildren = val.GetComponentsInChildren<Collider>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
			}
			Renderer[] componentsInChildren2 = val.GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
			}
			MeshFilter[] componentsInChildren3 = val.GetComponentsInChildren<MeshFilter>(true);
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren3[i]);
			}
			val.GetComponent<ZNetView>().m_persistent = false;
			val.AddComponent<ZSyncTransform>();
			CorteSombrio corteSombrio = val.AddComponent<CorteSombrio>();
			corteSombrio.Damage = damage;
			corteSombrio.DamagePerLevel = perLevel;
			corteSombrio.StatusEffect = statusEffect;
			corteSombrio.HitVfx = BloodVfx;
			corteSombrio.OnComboHit = onComboHit;
			GameObject val2 = new GameObject("visual");
			val2.transform.SetParent(val.transform, false);
			val2.transform.localPosition = new Vector3(0f, 0f, -1.2f);
			val2.AddComponent<MeshFilter>().sharedMesh = CorteSombrio.BuildCrescent(1.7f, 0.45f, 150f, 24);
			MeshRenderer val3 = val2.AddComponent<MeshRenderer>();
			GameObject obj = BloodEffects.Find<GameObject>("THSwordGold_FrostFire");
			object obj2;
			if (obj == null)
			{
				obj2 = null;
			}
			else
			{
				Transform obj3 = obj.transform.Find("attach/Krom");
				if (obj3 == null)
				{
					obj2 = null;
				}
				else
				{
					MeshRenderer component = ((Component)obj3).GetComponent<MeshRenderer>();
					obj2 = ((component != null) ? ((Renderer)component).sharedMaterial : null);
				}
			}
			Material val4 = (Material)obj2;
			if ((Object)(object)val4 != (Object)null)
			{
				Material val5 = new Material(val4)
				{
					name = name + "_mat"
				};
				val5.SetTexture("_MainTex", (Texture)(object)Texture2D.blackTexture);
				if (val5.HasProperty("_MetallicGlossMap"))
				{
					val5.SetTexture("_MetallicGlossMap", (Texture)(object)Texture2D.blackTexture);
				}
				if (val5.HasProperty("_Color"))
				{
					val5.SetColor("_Color", new Color(0.02f, 0.01f, 0.03f));
				}
				val5.SetTexture("_EmissionMap", (Texture)(object)CorteSombrio.BuildGlowTexture());
				val5.SetColor("_EmissionColor", color * 5f);
				val5.EnableKeyword("_EMISSION");
				((Renderer)val3).sharedMaterial = val5;
			}
			else
			{
				log.LogWarning((object)"Shadow Cut: sword material not found, the cut will be invisible");
			}
			GameObject obj4 = BloodEffects.Find<GameObject>("THSwordGold_FrostFire");
			Transform val6 = ((obj4 != null) ? obj4.transform.Find("attach/Krom/Burny vfx") : null);
			if ((Object)(object)val6 != (Object)null)
			{
				float[] array = new float[3] { -45f, 0f, 45f };
				foreach (float num in array)
				{
					GameObject obj5 = Object.Instantiate<GameObject>(((Component)val6).gameObject, val2.transform, false);
					((Object)obj5).name = "flames";
					float num2 = num * ((float)Math.PI / 180f);
					obj5.transform.localPosition = new Vector3(Mathf.Sin(num2), 0f, Mathf.Cos(num2)) * 1.55f;
					obj5.transform.localRotation = Quaternion.identity;
					VfxTint.Apply(obj5, color, null, null);
				}
			}
			PrefabManager.Instance.AddPrefab(val);
			return val;
		}

		private static void ApplyStage(BloodStage s, CustomItem item, ManualLogSource log)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			SharedData val = (s.Shared = item.ItemDrop.m_itemData.m_shared);
			val.m_damages = new DamageTypes
			{
				m_slash = s.Slash,
				m_spirit = s.Spirit
			};
			val.m_damagesPerLevel = new DamageTypes
			{
				m_slash = s.SlashPerLevel
			};
			GameObject obj = BloodEffects.Find<GameObject>(s.StatsFrom);
			SharedData val2 = ((obj == null) ? null : obj.GetComponent<ItemDrop>()?.m_itemData?.m_shared);
			if (val2 != null)
			{
				val.m_blockPower = val2.m_blockPower;
				val.m_blockPowerPerLevel = val2.m_blockPowerPerLevel;
				val.m_deflectionForce = val2.m_deflectionForce;
				val.m_deflectionForcePerLevel = val2.m_deflectionForcePerLevel;
				val.m_timedBlockBonus = val2.m_timedBlockBonus;
				val.m_maxDurability = val2.m_maxDurability;
				val.m_durabilityPerLevel = val2.m_durabilityPerLevel;
				val.m_toolTier = val2.m_toolTier;
			}
			else
			{
				log.LogWarning((object)(s.Id + ": reference weapon " + s.StatsFrom + " not found, keeping the Frostfire's block/durability"));
			}
			GameObject obj2 = BloodEffects.Find<GameObject>("THSwordSlayerBlood");
			SharedData val3 = ((obj2 == null) ? null : obj2.GetComponent<ItemDrop>()?.m_itemData?.m_shared);
			if (val3 != null)
			{
				val.m_hitEffect = val3.m_hitEffect;
				val.m_attack.m_hitEffect = val3.m_attack.m_hitEffect;
				val.m_secondaryAttack.m_hitEffect = val3.m_secondaryAttack.m_hitEffect;
			}
			val.m_attackStatusEffect = (StatusEffect)(object)s.Bleed;
			val.m_attackStatusEffectChance = 1f;
			val.m_attack.m_attackHealthReturnHit = s.LifeSteal;
			val.m_secondaryAttack.m_attackHealthReturnHit = s.LifeSteal;
			if ((Object)(object)s.Burst != (Object)null)
			{
				val.m_attack.m_spawnOnHit = s.Burst;
				val.m_attack.m_spawnOnHitChance = 0.12f;
			}
			if (s.ShadowCut)
			{
				Attack secondaryAttack = val.m_secondaryAttack;
				secondaryAttack.m_damageMultiplier = 6f;
				secondaryAttack.m_attackHealthPercentage = 33.3f;
				secondaryAttack.m_attackHealthLowBlockUse = false;
				if ((Object)(object)shadowCut != (Object)null)
				{
					secondaryAttack.m_spawnOnTrigger = shadowCut;
				}
			}
			VfxTint.Apply(item.ItemPrefab, BloodRed, log, s.Id);
		}

		internal static T Find<T>(string name) where T : Object
		{
			Object prefab = Cache.GetPrefab(typeof(T), name);
			return (T)(object)((prefab is T) ? prefab : null);
		}
	}
	public class SE_Sangramento : SE_Stats
	{
		public float DamagePerStack = 3f;

		public int MaxStacks = 3;

		private int stacks;

		public override void Setup(Character character)
		{
			((SE_Stats)this).Setup(character);
			stacks = 1;
			ApplyStacks();
		}

		public override void ResetTime()
		{
			((SE_Stats)this).ResetTime();
			if (stacks < MaxStacks)
			{
				stacks++;
			}
			ApplyStacks();
		}

		private void ApplyStacks()
		{
			base.m_tickInterval = 1f;
			base.m_healthPerTick = (0f - DamagePerStack) * (float)stacks;
			base.m_healthPerTickMinHealthPercentage = 0f;
		}

		public override string GetIconText()
		{
			return stacks.ToString();
		}
	}
	public class CorteSombrio : MonoBehaviour, IProjectile
	{
		public int OnComboHit;

		public bool RequireFullCombustion;

		public float Speed = 18f;

		public float Life = 0.8f;

		public float Radius = 1.6f;

		public DamageTypes Damage;

		public DamageTypes DamagePerLevel;

		public string StatusEffect;

		public GameObject HitVfx;

		private ZNetView nview;

		private Character owner;

		private int quality = 1;

		private float age;

		private Transform visual;

		private readonly HashSet<Character> hit = new HashSet<Character>();

		private static readonly Collider[] buffer = (Collider[])(object)new Collider[64];

		private static int mask;

		private void Awake()
		{
			nview = ((Component)this).GetComponent<ZNetView>();
			visual = ((Component)this).transform.Find("visual");
			if (mask == 0)
			{
				mask = LayerMask.GetMask(new string[4] { "character", "character_net", "character_ghost", "character_noenv" });
			}
		}

		public void Setup(Character owner, Vector3 velocity, float hitNoise, HitData hitData, ItemData item, ItemData ammo)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			if ((OnComboHit > 0 && VoidEffects.ComboHit(owner) != OnComboHit) || (RequireFullCombustion && GauntletEffects.Charges < GauntletEffects.MaxCharges))
			{
				ZNetScene.instance.Destroy(((Component)this).gameObject);
				return;
			}
			this.owner = owner;
			quality = item?.m_quality ?? 1;
			Vector3 val = velocity;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				val = (((Object)(object)owner != (Object)null) ? ((Component)owner).transform.forward : ((Component)this).transform.forward);
			}
			((Component)this).transform.rotation = Quaternion.LookRotation(((Vector3)(ref val)).normalized);
			Transform transform = ((Component)this).transform;
			transform.position += ((Component)this).transform.forward * 0.8f;
		}

		public string GetTooltipString(int itemQuality)
		{
			return "";
		}

		private void Update()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			age += Time.deltaTime;
			float num = Mathf.Clamp01(age / Life);
			if ((Object)(object)visual != (Object)null)
			{
				visual.localScale = new Vector3(1f + 0.4f * num, 1f, 1f + 0.4f * num);
			}
			if (!((Object)(object)nview == (Object)null) && nview.IsValid() && nview.IsOwner())
			{
				Transform transform = ((Component)this).transform;
				transform.position += ((Component)this).transform.forward * (Speed * Time.deltaTime);
				HitAround();
				if (age >= Life)
				{
					ZNetScene.instance.Destroy(((Component)this).gameObject);
				}
			}
		}

		private void HitAround()
		{
			//IL_0015: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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_00e7: 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_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_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Expected O, but got Unknown
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)owner == (Object)null)
			{
				return;
			}
			int num = Physics.OverlapSphereNonAlloc(((Component)this).transform.position, Radius, buffer, mask);
			for (int i = 0; i < num; i++)
			{
				Character componentInParent = ((Component)buffer[i]).GetComponentInParent<Character>();
				if (!((Object)(object)componentInParent == (Object)null) && !((Object)(object)componentInParent == (Object)(object)owner) && !componentInParent.IsDead() && !hit.Contains(componentInParent) && BaseAI.IsEnemy(owner, componentInParent))
				{
					hit.Add(componentInParent);
					DamageTypes damage = ((DamageTypes)(ref Damage)).Clone();
					DamageTypes val = ((DamageTypes)(ref DamagePerLevel)).Clone();
					((DamageTypes)(ref val)).Modify((float)Mathf.Max(0, quality - 1));
					((DamageTypes)(ref damage)).Add(val, 1);
					HitData val2 = new HitData
					{
						m_damage = damage,
						m_point = componentInParent.GetCenterPoint(),
						m_dir = ((Component)this).transform.forward,
						m_pushForce = 40f,
						m_skill = (SkillType)1,
						m_dodgeable = true,
						m_blockable = true,
						m_hitType = (HitType)((!(owner is Player)) ? 1 : 2)
					};
					if (!string.IsNullOrEmpty(StatusEffect))
					{
						val2.m_statusEffectHash = StringExtensionMethods.GetStableHashCode(StatusEffect);
					}
					val2.SetAttacker(owner);
					componentInParent.Damage(val2);
					if ((Object)(object)HitVfx != (Object)null)
					{
						Object.Instantiate<GameObject>(HitVfx, val2.m_point, Quaternion.identity);
					}
				}
			}
		}

		internal static Mesh BuildCrescent(float radius, float width, float arcDegrees, int segments)
		{
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_00cd: 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)
			List<Vector3> list = new List<Vector3>();
			List<Vector3> list2 = new List<Vector3>();
			List<Vector2> list3 = new List<Vector2>();
			List<int> list4 = new List<int>();
			Vector3 val = default(Vector3);
			for (int i = 0; i < 2; i++)
			{
				int count = list.Count;
				Vector3 item = ((i == 0) ? Vector3.up : Vector3.down);
				for (int j = 0; j <= segments; j++)
				{
					float num = (float)j / (float)segments;
					float num2 = (float)Math.PI / 180f * Mathf.Lerp((0f - arcDegrees) / 2f, arcDegrees / 2f, num);
					float num3 = width * Mathf.Sin((float)Math.PI * num);
					((Vector3)(ref val))..ctor(Mathf.Sin(num2), 0f, Mathf.Cos(num2));
					list.Add(val * (radius - num3));
					list2.Add(item);
					list3.Add(new Vector2(num, 0f));
					list.Add(val * radius);
					list2.Add(item);
					list3.Add(new Vector2(num, 1f));
				}
				for (int k = 0; k < segments; k++)
				{
					int num4 = count + k * 2;
					int num5 = num4 + 1;
					int num6 = num4 + 2;
					int num7 = num4 + 3;
					if (i == 0)
					{
						list4.AddRange(new int[6] { num4, num6, num5, num5, num6, num7 });
					}
					else
					{
						list4.AddRange(new int[6] { num4, num5, num6, num5, num7, num6 });
					}
				}
			}
			Mesh val2 = new Mesh
			{
				name = "Runeforged_Corte"
			};
			val2.SetVertices(list);
			val2.SetNormals(list2);
			val2.SetUVs(0, list3);
			val2.SetTriangles(list4, 0);
			val2.RecalculateBounds();
			return val2;
		}

		internal static Texture2D BuildGlowTexture()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_0021: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(128, 32, (TextureFormat)4, false)
			{
				name = "Runeforged_Corte_glow",
				wrapMode = (TextureWrapMode)1
			};
			for (int i = 0; i < 32; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					float num = (float)j / 127f;
					float num2 = (float)i / 31f;
					float num3 = Mathf.Pow(Mathf.Sin((float)Math.PI * num), 0.7f);
					float num4 = Mathf.Pow(num2, 3f);
					float num5 = 0.12f * (1f - num2) * (1f - num2);
					float num6 = Mathf.Clamp01((num4 + num5) * num3);
					val.SetPixel(j, i, new Color(num6, num6, num6, 1f));
				}
			}
			val.Apply();
			return val;
		}
	}
	[HarmonyPatch(typeof(Character), "Damage")]
	internal static class ExecutionPatch
	{
		private static void Prefix(Character __instance, HitData hit)
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			if (hit == null || (Object)(object)__instance == (Object)null || __instance.IsPlayer() || __instance.IsDead() || __instance.IsTamed() || (Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)hit.GetAttacker() != (Object)(object)Player.m_localPlayer)
			{
				return;
			}
			ItemData currentWeapon = ((Humanoid)Player.m_localPlayer).GetCurrentWeapon();
			if (!((Object)(object)currentWeapon?.m_dropPrefab == (Object)null) && BloodEffects.ExecutionThreshold.TryGetValue(((Object)currentWeapon.m_dropPrefab).name, out var value) && !(value <= 0f) && !(__instance.GetHealthPercentage() > value))
			{
				hit.m_damage.m_damage += __instance.GetMaxHealth() * 2f;
				if ((Object)(object)BloodEffects.BloodVfx != (Object)null)
				{
					NetSync.Fx(BloodEffects.BloodVfx, __instance.GetCenterPoint(), Quaternion.identity);
				}
			}
		}
	}
	internal static class VfxTint
	{
		private static readonly FieldInfo TrailColors = typeof(MeleeWeaponTrail).GetField("_colors", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo TrailMaterial = typeof(MeleeWeaponTrail).GetField("_material", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		internal static void Apply(GameObject root, Color target, ManualLogSource log, string label)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			ParticleSystem[] componentsInChildren = root.GetComponentsInChildren<ParticleSystem>(true);
			foreach (ParticleSystem val in componentsInChildren)
			{
				MainModule main = val.main;
				((MainModule)(ref main)).startColor = Tint(((MainModule)(ref main)).startColor, target);
				ColorOverLifetimeModule colorOverLifetime = val.colorOverLifetime;
				if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled)
				{
					((ColorOverLifetimeModule)(ref colorOverLifetime)).color = Tint(((ColorOverLifetimeModule)(ref colorOverLifetime)).color, target);
				}
				ParticleSystemRenderer component = ((Component)val).GetComponent<ParticleSystemRenderer>();
				if ((Object)(object)component != (Object)null && (Object)(object)((Renderer)component).sharedMaterial != (Object)null)
				{
					((Renderer)component).sharedMaterial = TintMaterial(((Renderer)component).sharedMaterial, target);
					if (log != null)
					{
						log.LogDebug((object)(label + ": particles '" + ((Object)val).name + "' material '" + ((Object)((Renderer)component).sharedMaterial).name + "' shader '" + ((Object)((Renderer)component).sharedMaterial.shader).name + "'"));
					}
				}
				num++;
			}
			Light[] componentsInChildren2 = root.GetComponentsInChildren<Light>(true);
			foreach (Light obj in componentsInChildren2)
			{
				obj.color = Tint(obj.color, target);
			}
			MeleeWeaponTrail[] componentsInChildren3 = root.GetComponentsInChildren<MeleeWeaponTrail>(true);
			foreach (MeleeWeaponTrail obj2 in componentsInChildren3)
			{
				if (TrailColors?.GetValue(obj2) is Color[] source)
				{
					TrailColors.SetValue(obj2, source.Select((Color c) => Tint(c, target)).ToArray());
				}
				object? obj3 = TrailMaterial?.GetValue(obj2);
				Material val2 = (Material)((obj3 is Material) ? obj3 : null);
				if (val2 != null && (Object)(object)val2 != (Object)null)
				{
					TrailMaterial.SetValue(obj2, TintMaterial(val2, target));
				}
			}
			if (log != null)
			{
				log.LogInfo((object)$"{label}: {num} particle systems tinted");
			}
		}

		private static Material TintMaterial(Material m, Color target)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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)
			Material val = new Material(m)
			{
				name = ((Object)m).name + "_tinted"
			};
			string[] array = new string[3] { "_TintColor", "_Color", "_EmissionColor" };
			foreach (string text in array)
			{
				if (val.HasProperty(text))
				{
					val.SetColor(text, Tint(val.GetColor(text), target));
				}
			}
			return val;
		}

		internal static Color Tint(Color c, Color target)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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)
			float num = default(float);
			float num2 = default(float);
			float num3 = default(float);
			Color.RGBToHSV(c, ref num, ref num2, ref num3);
			float num4 = default(float);
			float num5 = default(float);
			Color.RGBToHSV(target, ref num4, ref num5, ref num);
			Color result = Color.HSVToRGB(num4, Mathf.Max(num2, num5 * 0.9f), num3, true);
			result.a = c.a;
			return result;
		}

		private static Gradient Tint(Gradient g, Color target)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//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_0012: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			return new Gradient
			{
				mode = g.mode,
				colorKeys = ((IEnumerable<GradientColorKey>)g.colorKeys).Select((Func<GradientColorKey, GradientColorKey>)((GradientColorKey k) => new GradientColorKey(Tint(k.color, target), k.time))).ToArray(),
				alphaKeys = g.alphaKeys
			};
		}

		private static MinMaxGradient Tint(MinMaxGradient g, Color target)
		{
			//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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected I4, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0061: 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_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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_0074: 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)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystemGradientMode mode = ((MinMaxGradient)(ref g)).mode;
			switch ((int)mode)
			{
			case 0:
				return new MinMaxGradient(Tint(((MinMaxGradient)(ref g)).color, target));
			case 2:
				return new MinMaxGradient(Tint(((MinMaxGradient)(ref g)).colorMin, target), Tint(((MinMaxGradient)(ref g)).colorMax, target));
			case 1:
				return new MinMaxGradient(Tint(((MinMaxGradient)(ref g)).gradient, target));
			case 3:
				return new MinMaxGradient(Tint(((MinMaxGradient)(ref g)).gradientMin, target), Tint(((MinMaxGradient)(ref g)).gradientMax, target));
			case 4:
			{
				MinMaxGradient result = default(MinMaxGradient);
				((MinMaxGradient)(ref result))..ctor(Tint(((MinMaxGradient)(ref g)).gradient, target));
				((MinMaxGradient)(ref result)).mode = (ParticleSystemGradientMode)4;
				return result;
			}
			default:
				return g;
			}
		}
	}
	internal static class ChestEffects
	{
		internal const string PieceName = "RF_SealedChest";

		private const string BasePiece = "piece_chest_grausten";

		private const string EmblemVisual = "GlitnirEmblem_visual";

		private const string Section = "Sealed Chest";

		internal const string NameEN = "Sealed Chest";

		internal const string NamePT = "Baú Selado";

		internal const string DescEN = "A sealed chest of golden stone. Only the one who built it can open it.";

		internal const string DescPT = "Um baú selado de pedra dourada. Só quem o construiu o pode abrir.";

		internal static bool Indestructible = true;

		private static CustomPiece custom;

		private static ManualLogSource log;

		private static ConfigEntry<bool> enabled;

		private static ConfigEntry<string> station;

		private static ConfigEntry<string> costs;

		internal static Color StoneColor = new Color(1f, 0.8f, 0.42f);

		internal static Color MetalColor = new Color(1f, 0.7f, 0.22f);

		internal static float Shine = 0.35f;

		private static readonly List<Material> gilded = new List<Material>();

		private static Mesh emblemMesh;

		private static Material emblemMat;

		internal const string SealName = "RF_ChestSeal";

		internal static void Build(ManualLogSource logger, ConfigFile config, AssetBundle bundle)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_00bf: 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)
			log = logger;
			PieceConfig val = new PieceConfig();
			val.Name = "$piece_rf_sealedchest";
			val.Description = "$piece_rf_sealedchest_desc";
			val.PieceTable = PieceTables.Hammer;
			val.Category = PieceCategories.Furniture;
			val.CraftingStation = CraftingStations.Workbench;
			val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig("RF_ChestSeal", 1, 0, true)
			};
			PieceConfig val2 = val;
			custom = new CustomPiece("RF_SealedChest", "piece_chest_grausten", val2);
			GameObject piecePrefab = custom.PiecePrefab;
			if ((Object)(object)piecePrefab == (Object)null)
			{
				log.LogError((object)"piece_chest_grausten not found: no Sealed Chest");
				return;
			}
			Container component = piecePrefab.GetComponent<Container>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_name = "$piece_rf_sealedchest";
				component.m_privacy = (PrivacySetting)0;
			}
			WearNTear component2 = piecePrefab.GetComponent<WearNTear>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.m_noSupportWear = true;
				component2.m_noRoofWear = true;
				component2.m_burnable = false;
				component2.m_ashDamageImmune = true;
				component2.m_snowDamageImmune = true;
			}
			piecePrefab.AddComponent<PersonalChest>();
			Gild(piecePrefab);
			AddEmblem(piecePrefab, bundle);
			try
			{
				Sprite val3 = RenderManager.Instance.Render(piecePrefab, RenderManager.IsometricRotation);
				if ((Object)(object)val3 != (Object)null)
				{
					custom.Piece.m_icon = val3;
				}
			}
			catch (Exception ex)
			{
				log.LogWarning((object)("Sealed Chest: icon render failed, keeping the base icon (" + ex.Message + ")"));
			}
			PieceManager.Instance.AddPiece(custom);
			BindSettings(config);
			PieceManager.OnPiecesRegistered += ApplyPiece;
			ItemManager.OnItemsRegistered += ApplyPiece;
			log.LogInfo((object)string.Format("{0} added (clone of {1}, {2}x{3} slots, private)", "RF_SealedChest", "piece_chest_grausten", component?.m_width, component?.m_height));
		}

		private static ConfigEntry<T> Bind<T>(ConfigFile config, string key, T value, string description, Action<T> apply, AcceptableValueBase acceptable = null)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			ConfigEntry<T> entry = config.Bind<T>("Sealed Chest", key, value, new ConfigDescription(description, acceptable, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			Action run = delegate
			{
				try
				{
					apply(entry.Value);
				}
				catch (Exception ex)
				{
					log.LogError((object)("[Sealed Chest] " + key + ": " + ex.Message));
				}
			};
			run();
			entry.SettingChanged += delegate
			{
				run();
			};
			return entry;
		}

		private static void BindSettings(ConfigFile config)
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			enabled = Bind(config, "Enabled", value: true, "false = the chest is not in the hammer menu (chests already built stay).", delegate
			{
				ApplyPiece();
			});
			station = Bind(config, "Build Station", "piece_workbench", "Prefab of the station that must be nearby to build it (empty = none).", delegate
			{
				ApplyPiece();
			});
			costs = Bind(config, "Build Costs", "RF_ChestSeal:1", "What building it costs: Item:amount,Item:amount (prefab names). Default: one Chest Seal, which comes back when the owner deconstructs the empty chest.", delegate
			{
				ApplyPiece();
			});
			Bind(config, "Chest Color", StoneColor, "Tint of the whole chest (the grey stone turns this colour).", delegate(Color v)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				StoneColor = v;
				ApplyGold();
			});
			Bind(config, "Chest Metal Color", MetalColor, "Tint of the chest's metal fittings.", delegate(Color v)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				MetalColor = v;
				ApplyGold();
			});
			Bind(config, "Chest Shine", Shine, "How glossy the chest is (0 = matte stone, 1 = polished).", delegate(float v)
			{
				Shine = v;
				ApplyGold();
			}, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f));
			Bind(config, "Indestructible", value: true, "true = the chest takes no damage at all (its items can never drop for others to take).", delegate(bool v)
			{
				Indestructible = v;
			});
			Bind(config, "Emblem Side", EmblemPlacer.Side, "Which face of the chest carries the emblem.", delegate(EmblemPlacer.Face v)
			{
				EmblemPlacer.Side = v;
				EmblemPlacer.Version++;
			});
			Bind(config, "Emblem Height", EmblemPlacer.Height, "Height of the emblem's centre, as a fraction of the chest's height (0 = bottom, 1 = top).", delegate(float v)
			{
				EmblemPlacer.Height = v;
				EmblemPlacer.Version++;
			}, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f));
			Bind(config, "Emblem Shift", EmblemPlacer.Shift, "Moves the emblem sideways along the face (m).", delegate(float v)
			{
				EmblemPlacer.Shift = v;
				EmblemPlacer.Version++;
			});
			Bind(config, "Emblem Depth", EmblemPlacer.Depth, "Moves the emblem out of (+) or into (-) the face (m).", delegate(float v)
			{
				EmblemPlacer.Depth = v;
				EmblemPlacer.Version++;
			});
			Bind(config, "Emblem Size", EmblemPlacer.Size, "Size of the emblem (1 = 40 cm across).", delegate(float v)
			{
				EmblemPlacer.Size = v;
				EmblemPlacer.Version++;
			}, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f));
			Bind(config, "Emblem Turn", EmblemPlacer.Turn, "Turns the emblem around the vertical axis (degrees; 180 = shows its back).", delegate(float v)
			{
				EmblemPlacer.Turn = v;
				EmblemPlacer.Version++;
			}, (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f));
			Bind(config, "Emblem Roll", EmblemPlacer.Roll, "Rolls the emblem in its own plane, like a clock hand (degrees).", delegate(float v)
			{
				EmblemPlacer.Roll = v;
				EmblemPlacer.Version++;
			}, (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f));
		}

		internal static void ApplyPiece()
		{
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Expected O, but got Unknown
			CustomPiece obj = custom;
			Piece val = ((obj != null) ? obj.Piece : null);
			if ((Object)(object)val == (Object)null || enabled == null || station == null || costs == null || (Object)(object)ObjectDB.instance == (Object)null || ObjectDB.instance.m_items == null || ObjectDB.instance.m_items.Count == 0)
			{
				return;
			}
			val.m_enabled = enabled.Value;
			string text = station.Value?.Trim();
			if (string.IsNullOrEmpty(text))
			{
				val.m_craftingStation = null;
			}
			else
			{
				GameObject val2 = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(text) : PrefabManager.Instance.GetPrefab(text));
				CraftingStation val3 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<CraftingStation>() : null);
				if ((Object)(object)val3 != (Object)null)
				{
					val.m_craftingStation = val3;
				}
				else
				{
					log.LogWarning((object)("[Sealed Chest] build station '" + text + "' not found"));
				}
			}
			List<Requirement> list = new List<Requirement>();
			string[] array = (costs.Value ?? "").Split(new char[1] { ',' });
			for (int i = 0; i < array.Length; i++)
			{
				string[] array2 = array[i].Trim().Split(new char[1] { ':' });
				if (array2.Length >= 2 && array2[0].Trim().Length != 0 && int.TryParse(array2[1].Trim(), out var result) && result > 0)
				{
					GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(array2[0].Trim());
					ItemDrop val4 = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>() : null);
					if ((Object)(object)val4 == (Object)null)
					{
						log.LogWarning((object)("[Sealed Chest] build cost item '" + array2[0].Trim() + "' not found, skipped"));
						continue;
					}
					list.Add(new Requirement
					{
						m_resItem = val4,
						m_amount = result,
						m_recover = true
					});
				}
			}
			if (list.Count > 0)
			{
				val.m_resources = list.ToArray();
			}
		}

		private static void Gild(GameObject prefab)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			Dictionary<Material, Material> dictionary = new Dictionary<Material, Material>();
			Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (val is ParticleSystemRenderer)
				{
					continue;
				}
				Material[] sharedMaterials = val.sharedMaterials;
				for (int j = 0; j < sharedMaterials.Length; j++)
				{
					if (!((Object)(object)sharedMaterials[j] == (Object)null) && sharedMaterials[j].HasProperty("_Color"))
					{
						if (!dictionary.TryGetValue(sharedMaterials[j], out var value))
						{
							value = new Material(sharedMaterials[j])
							{
								name = ((Object)sharedMaterials[j]).name + "_rf_gold"
							};
							dictionary[sharedMaterials[j]] = value;
							gilded.Add(value);
						}
						sharedMaterials[j] = value;
					}
				}
				val.sharedMaterials = sharedMaterials;
			}
			log.LogInfo((object)string.Format("Sealed Chest: {0} material(s) gilded ({1})", gilded.Count, string.Join(", ", gilded.Select((Material m) => (!((Object)(object)m.shader != (Object)null)) ? "?" : ((Object)m.shader).name).Distinct())));
			ApplyGold();
		}

		private static void ApplyGold()
		{
			//IL_0024: 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)
			foreach (Material item in gilded)
			{
				if (!((Object)(object)item == (Object)null))
				{
					item.SetColor("_Color", StoneColor);
					if (item.HasProperty("_MetalColor"))
					{
						item.SetColor("_MetalColor", MetalColor);
					}
					if (item.HasProperty("_Glossiness"))
					{
						item.SetFloat("_Glossiness", Shine);
					}
				}
			}
		}

		private static bool LoadEmblem(AssetBundle bundle)
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_012f: 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_015d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)emblemMesh != (Object)null)
			{
				return true;
			}
			GameObject val = (((Object)(object)bundle != (Object)null) ? bundle.LoadAsset<GameObject>("GlitnirEmblem_visual") : null);
			MeshFilter val2 = (((Object)(object)val != (Object)null) ? val.GetComponentInChildren<MeshFilter>(true) : null);
			if ((Object)(object)val2 == (Object)null)
			{
				return false;
			}
			Material sharedMaterial = ((Renderer)((Component)val2).GetComponent<MeshRenderer>()).sharedMaterial;
			GameObject prefab = PrefabManager.Instance.GetPrefab("SwordIron");
			Renderer val3 = (Renderer)(object)(((Object)(object)prefab != (Object)null) ? prefab.GetComponentsInChildren<MeshRenderer>(true).FirstOrDefault() : null);
			Material val4 = new Material(((Object)(object)val3 != (Object)null) ? val3.sharedMaterial : sharedMaterial)
			{
				name = "RF_Emblem_mat"
			};
			string[] array = new string[4] { "_MainTex", "_BumpMap", "_MetallicGlossMap", "_EmissionMap" };
			foreach (string text in array)
			{
				if (sharedMaterial.HasProperty(text) && (Object)(object)sharedMaterial.GetTexture(text) != (Object)null && val4.HasProperty(text))
				{
					val4.SetTexture(text, sharedMaterial.GetTexture(text));
				}
			}
			if (val4.HasProperty("_Color"))
			{
				val4.SetColor("_Color", Color.white);
			}
			if ((Object)(object)sharedMaterial.GetTexture("_EmissionMap") != (Object)null)
			{
				val4.SetColor("_EmissionColor", Color.white * 2f);
				val4.EnableKeyword("_EMISSION");
			}
			emblemMesh = val2.sharedMesh;
			emblemMat = val4;
			return true;
		}

		private static void AddEmblem(GameObject prefab, AssetBundle bundle)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: 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_0076: 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)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			if (!LoadEmblem(bundle))
			{
				log.LogWarning((object)"GlitnirEmblem_visual not found in the bundle: the chest has no emblem");
				return;
			}
			Mesh sharedMesh = emblemMesh;
			Material sharedMaterial = emblemMat;
			Bounds val = default(Bounds);
			bool flag = true;
			MeshFilter[] componentsInChildren = prefab.GetComponentsInChildren<MeshFilter>(true);
			Vector3 val3 = default(Vector3);
			foreach (MeshFilter val2 in componentsInChildren)
			{
				if ((Object)(object)val2.sharedMesh == (Object)null || (Object)(object)((Component)val2).GetComponent<MeshRenderer>() == (Object)null)
				{
					continue;
				}
				Bounds bounds = val2.sharedMesh.bounds;
				for (int j = 0; j < 8; j++)
				{
					((Vector3)(ref val3))..ctor(((j & 1) == 0) ? ((Bounds)(ref bounds)).min.x : ((Bounds)(ref bounds)).max.x, ((j & 2) == 0) ? ((Bounds)(ref bounds)).min.y : ((Bounds)(ref bounds)).max.y, ((j & 4) == 0) ? ((Bounds)(ref bounds)).min.z : ((Bounds)(ref bounds)).max.z);
					Vector3 val4 = prefab.transform.InverseTransformPoint(((Component)val2).transform.TransformPoint(val3));
					if (flag)
					{
						((Bounds)(ref val))..ctor(val4, Vector3.zero);
						flag = false;
					}
					else
					{
						((Bounds)(ref val)).Encapsulate(val4);
					}
				}
			}
			log.LogInfo((object)$"Sealed Chest: chest bounds {((Bounds)(ref val)).center:F3} size {((Bounds)(ref val)).size:F3}");
			GameObject val5 = new GameObject("RF_GlitnirEmblem")
			{
				layer = prefab.layer
			};
			val5.transform.SetParent(prefab.transform, false);
			val5.AddComponent<MeshFilter>().sharedMesh = sharedMesh;
			((Renderer)val5.AddComponent<MeshRenderer>()).sharedMaterial = sharedMaterial;
			EmblemPlacer emblemPlacer = val5.AddComponent<EmblemPlacer>();
			emblemPlacer.ChestCenter = ((Bounds)(ref val)).center;
			emblemPlacer.ChestSize = ((Bounds)(ref val)).size;
			emblemPlacer.Apply();
		}

		internal static IEnumerable<ArsenalItem> CreateItems()
		{
			yield return new ArsenalItem
			{
				PrefabName = "RF_ChestSeal",
				BasePrefab = "Ruby",
				NameEN = "Chest Seal",
				NamePT = "Selo de Baú",
				DescEN = "Builds a Sealed Chest with the hammer. Deconstruct your empty chest to get the seal back and place it somewhere else.",
				DescPT = "Constrói um Baú Selado com o martelo. Desmonta o teu baú vazio para recuperar o selo e colocá-lo noutro sítio.",
				Hidden = true,
				CopyBaseRecipe = false,
				Customize = delegate(CustomItem item, ManualLogSource logger)
				{
					MakeSeal(item, logger);
				}
			};
		}

		private static void MakeSeal(CustomItem item, ManualLogSource logger)
		{
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			SharedData shared = item.ItemDrop.m_itemData.m_shared;
			shared.m_maxStackSize = 10;
			shared.m_weight = 1f;
			shared.m_value = 0;
			shared.m_teleportable = true;
			shared.m_maxQuality = 1;
			if (!LoadEmblem(RuneforgedPlugin.Bundle))
			{
				logger.LogWarning((object)"GlitnirEmblem_visual not found in the bundle: the seal keeps the base look");
				return;
			}
			GameObject itemPrefab = item.ItemPrefab;
			MeshFilter val = ((IEnumerable<MeshFilter>)itemPrefab.GetComponentsInChildren<MeshFilter>(true)).FirstOrDefault((Func<MeshFilter, bool>)((MeshFilter mf) => (Object)(object)((Component)mf).GetComponent<MeshRenderer>() != (Object)null));
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			MeshRenderer[] componentsInChildren = itemPrefab.GetComponentsInChildren<MeshRenderer>(true);
			foreach (MeshRenderer val2 in componentsInChildren)
			{
				if ((Object)(object)((Component)val2).gameObject != (Object)(object)((Component)val).gameObject)
				{
					((Renderer)val2).enabled = false;
				}
			}
			Collider[] componentsInChildren2 = itemPrefab.GetComponentsInChildren<Collider>(true);
			for (int num = 0; num < componentsInChildren2.Length; num++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren2[num]);
			}
			val.sharedMesh = emblemMesh;
			((Renderer)((Component)val).GetComponent<MeshRenderer>()).sharedMaterials = (Material[])(object)new Material[1] { emblemMat };
			((Component)val).transform.localPosition = Vector3.zero;
			((Component)val).transform.localRotation = Quaternion.identity;
			((Component)val).transform.localScale = Vector3.one * 0.6f;
			BoxCollider obj = ((Component)val).gameObject.AddComponent<BoxCollider>();
			Bounds bounds = emblemMesh.bounds;
			obj.center = ((Bounds)(ref bounds)).center;
			bounds = emblemMesh.bounds;
			obj.size = ((Bounds)(ref bounds)).size;
			LODGroup component = itemPrefab.GetComponent<LODGroup>();
			if ((Object)(object)component != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component);
			}
		}

		internal static void AddTranslations(Dictionary<string, string> en, Dictionary<string, string> pt)
		{
			en["piece_rf_sealedchest"] = "Sealed Chest";
			en["piece_rf_sealedchest_desc"] = "A sealed chest of golden stone. Only the one who built it can open it.";
			pt["piece_rf_sealedchest"] = "Baú Selado";
			pt["piece_rf_sealedchest_desc"] = "Um baú selado de pedra dourada. Só quem o construiu o pode abrir.";
		}
	}
	public class PersonalChest : MonoBehaviour
	{
	}
	public class EmblemPlacer : MonoBehaviour
	{
		public enum Face
		{
			Front,
			Back,
			Left,
			Right
		}

		public static Face Side = Face.Front;

		public static float Height = 0.45f;

		public static float Shift = -0.139f;

		public static float Depth = -0.2f;

		public static float Size = 1f;

		public static float Turn = 0f;

		public static float Roll = 0f;

		public static int Version;

		public Vector3 ChestCenter;

		public Vector3 ChestSize;

		private int applied = -1;

		private void Update()
		{
			if (applied != Version)
			{
				Apply();
			}
		}

		public void Apply()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			applied = Version;
			Vector3 val = ChestSize * 0.5f;
			float num = ChestCenter.y - val.y + ChestSize.y * Height;
			Vector3 localPosition = default(Vector3);
			float num2;
			switch (Side)
			{
			case Face.Back:
				((Vector3)(ref localPosition))..ctor(ChestCenter.x - Shift, num, ChestCenter.z - val.z - Depth);
				num2 = 180f;
				break;
			case Face.Left:
				((Vector3)(ref localPosition))..ctor(ChestCenter.x - val.x - Depth, num, ChestCenter.z + Shift);
				num2 = -90f;
				break;
			case Face.Right:
				((Vector3)(ref localPosition))..ctor(ChestCenter.x + val.x + Depth, num, ChestCenter.z - Shift);
				num2 = 90f;
				break;
			default:
				((Vector3)(ref localPosition))..ctor(ChestCenter.x + Shift, num, ChestCenter.z + val.z + Depth);
				num2 = 0f;
				break;
			}
			((Component)this).transform.localPosition = localPosition;
			((Component)this).transform.localRotation = Quaternion.Euler(0f, num2 + Turn, 0f) * Quaternion.Euler(0f, 0f, Roll);
			((Component)this).transform.localScale = Vector3.one * Size;
		}
	}
	[HarmonyPatch(typeof(WearNTear), "ApplyDamage")]
	internal static class PersonalChestDamagePatch
	{
		private static bool Prefix(WearNTear __instance, ref bool __result)
		{
			if (!ChestEffects.Indestructible || (Object)(object)__instance == (Object)null || (Object)(object)((Component)__instance).GetComponent<PersonalChest>() == (Object)null)
			{
				return true;
			}
			__result = false;
			return false;
		}
	}
	[HarmonyPatch(typeof(Piece), "CanBeRemoved")]
	internal static class PersonalChestRemovePatch
	{
		private static void Postfix(Piece __instance, ref bool __result)
		{
			if (__result && !((Object)(object)__instance == (Object)null) && !((Object)(object)((Component)__instance).GetComponent<PersonalChest>() == (Object)null))
			{
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null || __instance.GetCreator() != localPlayer.GetPlayerID())
				{
					__result = false;
				}
			}
		}
	}
	internal static class DaggerEffects
	{
		internal const string ItemName = "Thunderfang";

		private const string ChainName = "Runeforged_RaioTrovao";

		private const string DashFxName = "Runeforged_InvestidaFx";

		internal static readonly Color Electric = new Color(0.35f, 0.6f, 1f);

		private static readonly Vector3 GripRight = new Vector3(0.045f, 0.1f, 0.037f);

		private static readonly Vector3 GripLeft = new Vector3(-0.05f, 0.103f, 0.032f);

		private static GameObject chain;

		private static GameObject dashFx;

		private static GameObject aura;

		private static GameObject thunderSfx;

		internal static bool AuraEnabled = true;

		internal static bool DashThunder = true;

		private static Mesh daggerMesh;

		private static Mesh skinned;

		private static int rightBone = -1;

		private static int leftBone = -1;

		private static int boneCount;

		private static SharedData shared;

		internal static bool DashEnabled = true;

		internal static float DashSpeed = 18f;

		internal static float DashUp = 3f;

		internal static float DashStamina = 14f;

		internal static float DashMinSpeed = 1.2f;

		internal static float DashSeconds = 0.28f;

		internal static bool FlipRight;

		internal static bool FlipLeft;

		internal static bool ReverseRight;

		internal static bool ReverseLeft = true;

		internal static float DaggerScale = 1.3f;

		internal static void Build(ManualLogSource log)
		{
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)chain != (Object)null)
			{
				return;
			}
			GameObject val = BloodEffects.Find<GameObject>("ChainLightningRed");
			if ((Object)(object)val != (Object)null)
			{
				chain = PrefabManager.Instance.CreateClonedPrefab("Runeforged_RaioTrovao", val);
				Aoe component = chain.GetComponent<Aoe>();
				if ((Object)(object)component != (Object)null)
				{
					component.m_chainObj = chain;
					component.m_damage = new DamageTypes
					{
						m_lightning = 25f
					};
					component.m_damagePerLevel = new DamageTypes
					{
						m_lightning = 3f
					};
					component.m_radius = 6f;
					if (component.m_chainEffects?.m_effectPrefabs != null)
					{
						EffectData[] effectPrefabs = component.m_chainEffects.m_effectPrefabs;
						foreach (EffectData val2 in effectPrefabs)
						{
							if ((Object)(object)val2.m_prefab != (Object)null)
							{
								val2.m_prefab = PrefabManager.Instance.CreateClonedPrefab(((Object)val2.m_prefab).name + "_Runeforged", val2.m_prefab);
								VfxTint.Apply(val2.m_prefab, Electric, null, null);
							}
						}
					}
				}
				VfxTint.Apply(chain, Electric, null, null);
				PrefabManager.Instance.AddPrefab(chain);
			}
			else
			{
				log.LogWarning((object)"ChainLightningRed not found: Chain Lightning disabled");
			}
			thunderSfx = BloodEffects.Find<GameObject>("sfx_weapons_lightning_impact");
			dashFx = VoidEffects.LocalFx("Runeforged_InvestidaFx", "fx_lightningweapon_hit", Electric, log);
			NetSync.RegisterFx(dashFx);
			if ((Object)(object)dashFx != (Object)null)
			{
				ZSFX[] componentsInChildren = dashFx.GetComponentsInChildren<ZSFX>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
				}
				AudioSource[] componentsInChildren2 = dashFx.GetComponentsInChildren<AudioSource>(true);
				for (int i = 0; i < componentsInChildren2.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
				}
			}
		}

		internal static void Apply(CustomItem item, ManualLogSource log)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Expected O, but got Unknown
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Expected O, but got Unknown
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Expected O, but got Unknown
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Expected O, but got Unknown
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Expected O, but got Unknown
			GameObject itemPrefab = item.ItemPrefab;
			shared = item.ItemDrop.m_itemData.m_shared;
			Transform val = itemPrefab.transform.Find("attach/skoll");
			Transform val2 = itemPrefab.transform.Find("attach/hatti");
			object obj;
			if (val == null)
			{
				obj = null;
			}
			else
			{
				MeshFilter component = ((Component)val).GetComponent<MeshFilter>();
				obj = ((component != null) ? component.sharedMesh : null);
			}
			daggerMesh = (Mesh)obj;
			object obj2;
			if (val == null)
			{
				obj2 = null;
			}
			else
			{
				MeshRenderer component2 = ((Component)val).GetComponent<MeshRenderer>();
				obj2 = ((component2 != null) ? ((Renderer)component2).sharedMaterial : null);
			}
			Material val3 = (Material)obj2;
			if ((Object)(object)val != (Object)null)
			{
				val.localRotation = Quaternion.Euler(90f, 0f, 0f);
			}
			if ((Object)(object)val2 != (Object)null && (Object)(object)daggerMesh != (Object)null)
			{
				((Component)val2).GetComponent<MeshFilter>().sharedMesh = daggerMesh;
				((Renderer)((Component)val2).GetComponent<MeshRenderer>()).sharedMaterials = (Material[])(object)new Material[1] { val3 };
				val2.localPosition = new Vector3(0.09f, 0f, 0f);
				val2.localRotation = Quaternion.Euler(90f, 0f, 180f);
				BoxCollider component3 = ((Component)val2).GetComponent<BoxCollider>();
				if ((Object)(object)component3 != (Object)null)
				{
					Bounds bounds = daggerMesh.bounds;
					component3.center = ((Bounds)(ref bounds)).center;
					bounds = daggerMesh.bounds;
					component3.size = ((Bounds)(ref bounds)).size;
				}
				((Component)val2).gameObject.AddComponent<Faisca>();
			}
			if (val != null)
			{
				((Component)val).gameObject.AddComponent<Faisca>();
			}
			Transform obj3 = itemPrefab.transform.Find("attach_skin");
			SkinnedMeshRenderer val4 = ((obj3 != null) ? ((Component)obj3).GetComponentInChildren<SkinnedMeshRenderer>(true) : null);
			if ((Object)(object)val4 != (Object)null && (Object)(object)daggerMesh != (Object)null)
			{
				Transform[] bones = val4.bones;
				boneCount = bones.Length;
				rightBone = Array.FindIndex(bones, (Transform b) => (Object)(object)b != (Object)null && ((Object)b).name == "RightHand");
				leftBone = Array.FindIndex(bones, (Transform b) => (Object)(object)b != (Object)null && ((Object)b).name == "LeftHand");
				if (rightBone < 0 || leftBone < 0)
				{
					log.LogError((object)"Thunderfang: hand bones not found in Skoll and Hati");
				}
				else
				{
					skinned = new Mesh
					{
						name = "Thunderfang_skinned"
					};
					RebuildSkinned();
					val4.sharedMesh = skinned;
					((Renderer)val4).sharedMaterials = (Material[])(object)new Material[1] { val3 };
					val4.updateWhenOffscreen = true;
					((Component)val4).gameObject.AddComponent<Faisca>();
				}
			}
			else
			{
				log.LogError((object)"Thunderfang: Skoll and Hati's skinned mesh not found");
			}
			if ((Object)(object)daggerMesh != (Object)null && (Object)(object)itemPrefab.transform.Find("attach_back") == (Object)null)
			{
				GameObject val5 = new GameObject("attach_back");
				val5.transform.SetParent(itemPrefab.transform, false);
				val5.transform.SetAsFirstSibling();
				string[] array = new string[2] { "hip_right", "hip_left" };
				for (int num = 0; num < array.Length; num++)
				{
					GameObject val6 = new GameObject(array[num])
					{
						layer = itemPrefab.layer
					};
					val6.transform.SetParent(val5.transform, false);
					val6.AddComponent<MeshFilter>().sharedMesh = daggerMesh;
					((Renderer)val6.AddComponent<MeshRenderer>()).sharedMaterials = (Material[])(object)new Material[1] { val3 };
					val6.AddComponent<Faisca>();
				}
				val5.AddComponent<HipSheath>();
				val5.SetActive(false);
			}
			if ((Object)(object)thunderSfx != (Object)null && shared.m_hitEffect != null)
			{
				List<EffectData> list = new List<EffectData>((IEnumerable<EffectData>)(((object)shared.m_hitEffect.m_effectPrefabs) ?? ((object)new EffectData[0])));
				list.Add(new EffectData
				{
					m_prefab = thunderSfx,
					m_enabled = true,
					m_variant = -1
				});
				shared.m_hitEffect = new EffectList
				{
					m_effectPrefabs = list.ToArray()
				};
			}
			shared.m_damages.m_lightning = 15f;
			shared.m_damagesPerLevel.m_lightning = 2f;
			if ((Object)(object)chain != (Object)null)
			{
				shared.m_attack.m_spawnOnHit = chain;
				shared.m_attack.m_spawnOnHitChance = 0.2f;
				shared.m_secondaryAttack.m_spawnOnHit = chain;
				shared.m_secondaryAttack.m_spawnOnHitChance = 0.2f;
			}
			VfxTint.Apply(itemPrefab, Electric, log, "Thunderfang");
			GameObject val7 = (((Object)(object)RuneforgedPlugin.Bundle != (Object)null) ? RuneforgedPlugin.Bundle.LoadAsset<GameObject>("Runeforged_AuraTrovao") : null);
			Transform val8 = itemPrefab.transform.Find("attach_skin");
			if ((Object)(object)val7 != (Object)null && (Object)(object)val8 != (Object)null)
			{
				aura = Object.Instantiate<GameObject>(val7, val8, false);
				((Object)aura).name = "Runeforged_AuraTrovao";
				ParticleSystem[] componentsInChildren = aura.GetComponentsInChildren<ParticleSystem>(true);
				for (int num = 0; num < componentsInChildren.Length; num++)
				{
					componentsInChildren[num].useAutoRandomSeed = true;
				}
				aura.SetActive(AuraEnabled);
			}
			else
			{
				log.LogWarning((object)"Thunderfang: Thunder Aura effect not found in the bundle");
			}
		}

		internal static void RebuildSkinned()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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_006c: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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_009c: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: 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_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)skinned == (Object)null || (Object)(object)daggerMesh == (Object)null)
			{
				return;
			}
			Vector3[] vertices = daggerMesh.vertices;
			Vector3[] normals = daggerMesh.normals;
			Vector4[] tangents = daggerMesh.tangents;
			Vector2[] uv = daggerMesh.uv;
			int[] triangles = daggerMesh.triangles;
			int num = vertices.Length;
			Quaternion val = Quaternion.LookRotation(Vector3.forward, Vector3.left) * Quaternion.identity;
			Quaternion val2 =