Decompiled source of Aura Dourada v0.6.0

plugins/GoldenAura.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyMetadata("AI_Assisted_Creation", "This assembly was created with the assistance of Generative AI (code generation).")]
[assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic (Claude)")]
[assembly: AssemblyVersion("0.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 GoldenAura
{
	[BepInPlugin("pandherya.goldenaura", "Aura Dourada (Pandherya)", "0.6.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[SynchronizationMode(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "pandherya.goldenaura";

		public const string ZAura = "pga_mode";

		internal static ConfigEntry<KeyboardShortcut> Key;

		internal static ConfigEntry<float> EitrStart;

		internal static ConfigEntry<float> EitrPerSec;

		internal static ConfigEntry<float> DamageBonus;

		internal static ConfigEntry<string> ColorHex;

		internal static ConfigEntry<float> Size;

		internal static ConfigEntry<float> Height;

		internal static ConfigEntry<float> Rate;

		internal static ConfigEntry<float> Speed;

		internal static ConfigEntry<float> LightRange;

		internal static ConfigEntry<float> LightIntensity;

		internal static ConfigEntry<float> Shake;

		internal static ConfigEntry<float> BodyRate;

		internal static ConfigEntry<float> BodySize;

		internal static ConfigEntry<float> OuterSize;

		internal static ConfigEntry<bool> BodyFlames;

		internal static ConfigEntry<bool> OuterFlames;

		internal static ConfigEntry<float> Opacity;

		internal static ConfigEntry<bool> TorchFlames;

		internal static ConfigEntry<bool> TorchFlare;

		internal static ConfigEntry<int> TorchRing;

		internal static ConfigEntry<float> TorchScale;

		internal static ConfigEntry<float> TorchTint;

		internal static ConfigEntry<KeyboardShortcut> KeyDark;

		internal static ConfigEntry<KeyboardShortcut> KeyCycleGold;

		internal static ConfigEntry<KeyboardShortcut> KeyCycleDark;

		internal static ConfigEntry<string> Palette;

		internal static ConfigEntry<float> PulseAmount;

		internal static ConfigEntry<float> PulseSpeed;

		public const string ZColGold = "pga_cgold";

		public const string ZColSmoke = "pga_csmoke";

		public const string ZColRim = "pga_crim";

		internal static ConfigEntry<string> DarkSmokeHex;

		internal static ConfigEntry<string> DarkRimHex;

		internal static ConfigEntry<float> DarkOpacity;

		internal static ConfigEntry<float> DarkSmokeSize;

		internal static ConfigEntry<float> DarkSmokeLife;

		internal static ConfigEntry<float> DarkRimSize;

		internal static ConfigEntry<float> DarkLight;

		internal static ConfigEntry<int> DarkRing;

		internal static ConfigEntry<bool> DarkRim;

		internal static ManualLogSource Log;

		private static StatusEffect _se;

		private static int _seHash;

		private static readonly MethodInfo TakeInput = AccessTools.Method(typeof(Player), "TakeInput", (Type[])null, (Type[])null);

		private int _mode;

		internal static ConfigurationManagerAttributes Admin()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			return new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			};
		}

		private void Awake()
		{
			//IL_0022: 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_0069: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Key = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Aura", "Tecla", new KeyboardShortcut((KeyCode)104, Array.Empty<KeyCode>()), "Tecla que liga/desliga a aura.");
			EitrStart = ((BaseUnityPlugin)this).Config.Bind<float>("Aura", "EitrAoAtivar", 20f, new ConfigDescription("Eitr gasto na hora de ligar.", (AcceptableValueBase)null, new object[1] { Admin() }));
			EitrPerSec = ((BaseUnityPlugin)this).Config.Bind<float>("Aura", "EitrPorSegundo", 4f, new ConfigDescription("Eitr gasto por segundo enquanto está ligada. Acabou o eitr, a aura desliga.", (AcceptableValueBase)null, new object[1] { Admin() }));
			DamageBonus = ((BaseUnityPlugin)this).Config.Bind<float>("Aura", "BonusDano", 50f, new ConfigDescription("Dano extra enquanto a aura está ligada, em % (50 = 1,5x). Vale para todas as armas.", (AcceptableValueBase)null, new object[1] { Admin() }));
			ColorHex = ((BaseUnityPlugin)this).Config.Bind<string>("Visual", "Cor", "FFD21A", "Cor da aura em hexadecimal (RRGGBB).");
			KeyCycleGold = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Cor do Jogador", "TrocarCorDourada", new KeyboardShortcut((KeyCode)104, (KeyCode[])(object)new KeyCode[1] { (KeyCode)304 }), "Troca a cor da aura dourada (percorre a paleta). Cada jogador tem a sua; todos veem a cor de cada um.");
			KeyCycleDark = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Cor do Jogador", "TrocarCorSombria", new KeyboardShortcut((KeyCode)106, (KeyCode[])(object)new KeyCode[1] { (KeyCode)304 }), "Troca a cor do contorno da aura sombria (percorre a paleta).");
			Palette = ((BaseUnityPlugin)this).Config.Bind<string>("Cor do Jogador", "Paleta", "FFD21A,FF8C00,B00000,8A2BE2,9B30FF,00FFFF,1E90FF,32CD32,FFFFFF", "Cores disponíveis no atalho, em hex separado por vírgula.");
			PulseAmount = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "PulsoLuz", 0.06f, "Quanto a luz 'respira' (0 = luz fixa, 0.3 = bem pulsante).");
			PulseSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "VelocidadePulso", 1.2f, "Velocidade da respiração da luz (ciclos por segundo).");
			KeyDark = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Aura Sombria", "Tecla", new KeyboardShortcut((KeyCode)106, Array.Empty<KeyCode>()), "Tecla que liga/desliga a aura sombria (mesmo custo de eitr e bônus da dourada).");
			DarkSmokeHex = ((BaseUnityPlugin)this).Config.Bind<string>("Aura Sombria", "CorFumaca", "050508", "Cor da fumaça (pode ser preto).");
			DarkOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Aura Sombria", "OpacidadeFumaca", 0.85f, "Opacidade da fumaça (0 = invisível, 1 = sólida).");
			DarkSmokeSize = ((BaseUnityPlugin)this).Config.Bind<float>("Aura Sombria", "TamanhoFumaca", 0.45f, "Tamanho de cada nuvem de fumaça (1 = tamanho original do jogo).");
			DarkSmokeLife = ((BaseUnityPlugin)this).Config.Bind<float>("Aura Sombria", "DuracaoFumaca", 0.45f, "Quanto a fumaça dura antes de sumir (1 = original). Menor = aura mais 'colada' no corpo.");
			DarkRing = ((BaseUnityPlugin)this).Config.Bind<int>("Aura Sombria", "QuantidadeAnel", 8, "Nuvens de fumaça no anel em volta do corpo (0 = só as do corpo).");
			DarkRim = ((BaseUnityPlugin)this).Config.Bind<bool>("Aura Sombria", "Contorno", true, "Mini chamas coloridas por dentro da fumaça.");
			DarkRimHex = ((BaseUnityPlugin)this).Config.Bind<string>("Aura Sombria", "CorContorno", "8A2BE2", "Cor das chamas do contorno.");
			DarkRimSize = ((BaseUnityPlugin)this).Config.Bind<float>("Aura Sombria", "TamanhoContorno", 0.35f, "Tamanho das chamas do contorno.");
			DarkLight = ((BaseUnityPlugin)this).Config.Bind<float>("Aura Sombria", "IntensidadeLuz", 0.8f, "Força da luz (na cor do contorno). 0 = sem luz.");
			TorchFlames = ((BaseUnityPlugin)this).Config.Bind<bool>("Chamas de Tocha", "Ativar", true, "Usa o fogo original da tocha do jogo: várias mini chamas presas no corpo e em volta.");
			TorchFlare = ((BaseUnityPlugin)this).Config.Bind<bool>("Chamas de Tocha", "ClaraoTocha", false, "Mantém o clarão (flare) da tocha em cada chama. Fica bonito mas PISCA bastante.");
			TorchRing = ((BaseUnityPlugin)this).Config.Bind<int>("Chamas de Tocha", "QuantidadeAnel", 10, "Mini chamas no anel em espiral em volta do corpo (0 = só as do corpo).");
			TorchScale = ((BaseUnityPlugin)this).Config.Bind<float>("Chamas de Tocha", "Tamanho", 0.6f, "Tamanho de cada mini chama (1 = tamanho da tocha).");
			TorchTint = ((BaseUnityPlugin)this).Config.Bind<float>("Chamas de Tocha", "Tingimento", 1f, "Quanto a chama assume a cor da aura (0 = laranja original, 1 = cor da aura).");
			Opacity = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "Opacidade", 0.45f, "Opacidade das chamas (0 = invisível, 1 = sólido).");
			BodyFlames = ((BaseUnityPlugin)this).Config.Bind<bool>("Visual", "ChamasNoCorpo", true, "Energia saindo do corpo inteiro (ossos do personagem).");
			BodyRate = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "DensidadeCorpo", 220f, "Partículas por segundo saindo do corpo.");
			BodySize = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "TamanhoChamaCorpo", 0.45f, "Tamanho das chamas do corpo.");
			OuterFlames = ((BaseUnityPlugin)this).Config.Bind<bool>("Visual", "LabaredaExterna", true, "Chamas grandes subindo em volta do corpo.");
			Size = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "Largura", 0.45f, "Raio da labareda externa em volta do corpo (m).");
			OuterSize = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "TamanhoChamaExterna", 0.8f, "Tamanho das chamas da labareda externa.");
			Height = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "Altura", 2.4f, "Até onde as chamas sobem (m).");
			Rate = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "Densidade", 90f, "Partículas por segundo da labareda externa.");
			Speed = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "Velocidade", 3.5f, "Velocidade com que a energia sobe.");
			LightRange = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "AlcanceLuz", 7f, "Alcance da luz em volta do personagem (m).");
			LightIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "IntensidadeLuz", 2.2f, "Força da luz.");
			Shake = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "TremorAoAtivar", 1.5f, "Força do tremor de câmera ao ligar (0 = nenhum).");
			DamageBonus.SettingChanged += delegate
			{
				ApplyStats();
			};
			ConfigReload.Watch((BaseUnityPlugin)(object)this, ((BaseUnityPlugin)this).Config, "pandherya.goldenaura");
		}

		private static void EnsureSE()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_se != (Object)null))
			{
				SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>();
				((Object)val).name = "SE_PandheryaAuraDourada";
				((StatusEffect)val).m_name = "Aura Dourada";
				val.m_modifyAttackSkill = (SkillType)999;
				((StatusEffect)val).m_ttl = 0f;
				GameObject val2 = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab("Eitr") : null);
				ItemDrop val3 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<ItemDrop>() : null);
				if ((Object)(object)val3 != (Object)null && val3.m_itemData.m_shared.m_icons.Length != 0)
				{
					((StatusEffect)val).m_icon = val3.m_itemData.m_shared.m_icons[0];
				}
				_se = (StatusEffect)(object)val;
				_seHash = ((StatusEffect)val).NameHash();
				ApplyStats();
			}
		}

		private static void ApplyStats()
		{
			//IL_0013: 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)
			if ((Object)(object)_se == (Object)null)
			{
				return;
			}
			((SE_Stats)_se).m_damageModifier = 1f + DamageBonus.Value / 100f;
			_se.m_tooltip = "+" + DamageBonus.Value.ToString("0") + "% de dano. Gasta " + EitrPerSec.Value.ToString("0.#") + " de eitr por segundo.";
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null)
			{
				StatusEffect statusEffect = ((Character)localPlayer).GetSEMan().GetStatusEffect(_seHash);
				SE_Stats val = (SE_Stats)(object)((statusEffect is SE_Stats) ? statusEffect : null);
				if (val != null)
				{
					val.m_damageModifier = ((SE_Stats)_se).m_damageModifier;
					((StatusEffect)val).m_tooltip = _se.m_tooltip;
				}
			}
		}

		private void Update()
		{
			//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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null && !((Character)localPlayer).IsDead())
			{
				EnsureSE();
				PublishColors(localPlayer);
				bool flag = false;
				try
				{
					flag = (bool)TakeInput.Invoke(localPlayer, null);
				}
				catch
				{
				}
				KeyboardShortcut value;
				if (flag)
				{
					value = KeyCycleGold.Value;
					if (((KeyboardShortcut)(ref value)).IsDown())
					{
						CycleColor(localPlayer, ColorHex, "Cor da aura dourada");
						goto IL_00ed;
					}
				}
				if (flag)
				{
					value = KeyCycleDark.Value;
					if (((KeyboardShortcut)(ref value)).IsDown())
					{
						CycleColor(localPlayer, DarkRimHex, "Cor da aura sombria");
						goto IL_00ed;
					}
				}
				if (flag)
				{
					value = Key.Value;
					if (((KeyboardShortcut)(ref value)).IsDown())
					{
						Toggle(localPlayer, (_mode != 1) ? 1 : 0);
						goto IL_00ed;
					}
				}
				if (flag)
				{
					value = KeyDark.Value;
					if (((KeyboardShortcut)(ref value)).IsDown())
					{
						Toggle(localPlayer, (_mode != 2) ? 2 : 0);
					}
				}
				goto IL_00ed;
			}
			if (_mode != 0)
			{
				_mode = 0;
			}
			goto IL_0131;
			IL_00ed:
			if (_mode != 0)
			{
				float num = EitrPerSec.Value * Time.deltaTime;
				if (!((Character)localPlayer).HaveEitr(num))
				{
					Toggle(localPlayer, 0);
				}
				else
				{
					((Character)localPlayer).UseEitr(num);
				}
			}
			goto IL_0131;
			IL_0131:
			AuraVisual.UpdateAll();
		}

		private void Toggle(Player p, int mode)
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			if (mode != 0 && _mode == 0)
			{
				if (((Character)p).GetMaxEitr() <= 0f)
				{
					((Character)p).Message((MessageType)2, "Você não tem eitr. Coma algo que dê eitr.", 0, (Sprite)null, false);
					return;
				}
				if (!((Character)p).HaveEitr(EitrStart.Value))
				{
					((Character)p).Message((MessageType)2, "Eitr insuficiente para a aura.", 0, (Sprite)null, false);
					return;
				}
				((Character)p).UseEitr(EitrStart.Value);
				((Character)p).GetSEMan().AddStatusEffect(_se, true, 0, 0f, (short)(-1));
				ApplyStats();
				if (Shake.Value > 0f && (Object)(object)GameCamera.instance != (Object)null)
				{
					GameCamera.instance.AddShake(((Component)p).transform.position, 10f, Shake.Value, false);
				}
			}
			else if (mode == 0)
			{
				((Character)p).GetSEMan().RemoveStatusEffect(_seHash, true);
			}
			_mode = mode;
			if (mode != 0)
			{
				string name = ((mode == 2) ? "Aura Sombria" : "Aura Dourada");
				_se.m_name = name;
				StatusEffect statusEffect = ((Character)p).GetSEMan().GetStatusEffect(_seHash);
				if ((Object)(object)statusEffect != (Object)null)
				{
					statusEffect.m_name = name;
				}
			}
			ZNetView component = ((Component)p).GetComponent<ZNetView>();
			if ((Object)(object)component != (Object)null && component.IsValid())
			{
				component.GetZDO().Set("pga_mode", mode);
			}
			if (mode != 0)
			{
				AuraVisual.Burst(p);
			}
		}

		private static void CycleColor(Player p, ConfigEntry<string> entry, string label)
		{
			string[] array = Palette.Value.Split(new char[3] { ',', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries);
			if (array.Length != 0)
			{
				int num = Array.FindIndex(array, (string c) => string.Equals(c.Trim().TrimStart('#'), entry.Value.Trim().TrimStart('#'), StringComparison.OrdinalIgnoreCase));
				string text = array[(num + 1) % array.Length].Trim().TrimStart('#');
				entry.Value = text;
				((Character)p).Message((MessageType)1, label + ": #" + text.ToUpperInvariant(), 0, (Sprite)null, false);
				PublishColors(p);
			}
		}

		private static void PublishColors(Player p)
		{
			ZNetView component = ((Component)p).GetComponent<ZNetView>();
			if (!((Object)(object)component == (Object)null) && component.IsValid())
			{
				ZDO zDO = component.GetZDO();
				if (zDO.GetString("pga_cgold", "") != ColorHex.Value)
				{
					zDO.Set("pga_cgold", ColorHex.Value);
				}
				if (zDO.GetString("pga_csmoke", "") != DarkSmokeHex.Value)
				{
					zDO.Set("pga_csmoke", DarkSmokeHex.Value);
				}
				if (zDO.GetString("pga_crim", "") != DarkRimHex.Value)
				{
					zDO.Set("pga_crim", DarkRimHex.Value);
				}
			}
		}

		internal static Color Hex(string h, Color fallback)
		{
			//IL_001d: 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)
			Color result = default(Color);
			if (!ColorUtility.TryParseHtmlString("#" + h.TrimStart('#'), ref result))
			{
				return fallback;
			}
			return result;
		}

		internal static Color AuraColor()
		{
			//IL_0039: 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)
			Color result = default(Color);
			if (!ColorUtility.TryParseHtmlString("#" + ColorHex.Value.TrimStart('#'), ref result))
			{
				return new Color(1f, 0.82f, 0.1f);
			}
			return result;
		}
	}
	internal class AuraVisual : MonoBehaviour
	{
		private static readonly Dictionary<Player, AuraVisual> _all = new Dictionary<Player, AuraVisual>();

		private static Material _mat;

		private static bool _matSearched;

		private static ParticleSystem _srcSystem;

		private readonly List<ParticleSystem> _systems = new List<ParticleSystem>();

		private ParticleSystem _sparks;

		private Light _light;

		private string _sig;

		private float _off;

		private int _mode;

		private static readonly (HumanBodyBones bone, float radius, float weight)[] Bones = new(HumanBodyBones, float, float)[12]
		{
			((HumanBodyBones)0, 0.22f, 1.2f),
			((HumanBodyBones)7, 0.22f, 1.2f),
			((HumanBodyBones)8, 0.25f, 1.4f),
			((HumanBodyBones)10, 0.15f, 0.9f),
			((HumanBodyBones)13, 0.09f, 0.5f),
			((HumanBodyBones)14, 0.09f, 0.5f),
			((HumanBodyBones)15, 0.08f, 0.4f),
			((HumanBodyBones)16, 0.08f, 0.4f),
			((HumanBodyBones)1, 0.12f, 0.7f),
			((HumanBodyBones)2, 0.12f, 0.7f),
			((HumanBodyBones)3, 0.1f, 0.6f),
			((HumanBodyBones)4, 0.1f, 0.6f)
		};

		private static GameObject _smokeFx;

		private static bool _smokeSearched;

		private static GameObject _torchFx;

		private static bool _torchSearched;

		private static readonly Dictionary<HumanBodyBones, string[]> BoneNames = new Dictionary<HumanBodyBones, string[]>
		{
			{
				(HumanBodyBones)0,
				new string[1] { "Hips" }
			},
			{
				(HumanBodyBones)7,
				new string[2] { "Spine", "Spine1" }
			},
			{
				(HumanBodyBones)8,
				new string[3] { "Spine2", "Chest", "Spine1" }
			},
			{
				(HumanBodyBones)10,
				new string[1] { "Head" }
			},
			{
				(HumanBodyBones)13,
				new string[1] { "LeftArm" }
			},
			{
				(HumanBodyBones)14,
				new string[1] { "RightArm" }
			},
			{
				(HumanBodyBones)15,
				new string[1] { "LeftForeArm" }
			},
			{
				(HumanBodyBones)16,
				new string[1] { "RightForeArm" }
			},
			{
				(HumanBodyBones)1,
				new string[1] { "LeftUpLeg" }
			},
			{
				(HumanBodyBones)2,
				new string[1] { "RightUpLeg" }
			},
			{
				(HumanBodyBones)3,
				new string[1] { "LeftLeg" }
			},
			{
				(HumanBodyBones)4,
				new string[1] { "RightLeg" }
			}
		};

		internal static void UpdateAll()
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				if ((Object)(object)allPlayer == (Object)null)
				{
					continue;
				}
				ZNetView component = ((Component)allPlayer).GetComponent<ZNetView>();
				int num = (((Object)(object)component != (Object)null && component.IsValid() && !((Character)allPlayer).IsDead()) ? component.GetZDO().GetInt("pga_mode", 0) : 0);
				_all.TryGetValue(allPlayer, out var value);
				if (num != 0 && (Object)(object)value == (Object)null)
				{
					GameObject val = new GameObject("AuraPandherya");
					val.transform.SetParent(((Component)allPlayer).transform, false);
					value = val.AddComponent<AuraVisual>();
					value._mode = num;
					value.Build();
					_all[allPlayer] = value;
				}
				if ((Object)(object)value != (Object)null)
				{
					if (num != 0 && num != value._mode)
					{
						value._mode = num;
						value.Build();
					}
					value.SetOn(num != 0);
				}
			}
			List<Player> list = new List<Player>();
			foreach (KeyValuePair<Player, AuraVisual> item in _all)
			{
				if ((Object)(object)item.Key == (Object)null || (Object)(object)item.Value == (Object)null)
				{
					list.Add(item.Key);
				}
			}
			foreach (Player item2 in list)
			{
				_all.Remove(item2);
			}
		}

		internal static void Burst(Player p)
		{
			UpdateAll();
			if (_all.TryGetValue(p, out var value) && (Object)(object)value != (Object)null && (Object)(object)value._sparks != (Object)null && value._mode == 1)
			{
				value._sparks.Emit(80);
			}
		}

		private static Material FindMaterial()
		{
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			if (_matSearched)
			{
				return _mat;
			}
			_matSearched = true;
			string[] array = new string[3] { "fire_pit", "bonfire", "piece_brazierfloor01" };
			foreach (string text in array)
			{
				GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(text) : null);
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				ParticleSystemRenderer[] componentsInChildren = val.GetComponentsInChildren<ParticleSystemRenderer>(true);
				foreach (ParticleSystemRenderer val2 in componentsInChildren)
				{
					if (!((Object)(object)((Renderer)val2).sharedMaterial == (Object)null))
					{
						string text2 = (((Object)val2).name + ((Object)((Renderer)val2).sharedMaterial).name).ToLowerInvariant();
						if (text2.Contains("flame") || text2.Contains("fire"))
						{
							_mat = new Material(((Renderer)val2).sharedMaterial);
							_srcSystem = ((Component)val2).GetComponent<ParticleSystem>();
							Plugin.Log.LogInfo((object)("Aura usando material '" + ((Object)((Renderer)val2).sharedMaterial).name + "' de " + text));
							return _mat;
						}
					}
				}
			}
			array = new string[3] { "Legacy Shaders/Particles/Additive", "Particles/Standard Unlit", "Sprites/Default" };
			foreach (string text3 in array)
			{
				Shader val3 = Shader.Find(text3);
				if ((Object)(object)val3 != (Object)null)
				{
					_mat = new Material(val3);
					Plugin.Log.LogInfo((object)("Aura usando shader " + text3));
					return _mat;
				}
			}
			Plugin.Log.LogWarning((object)"Nenhum material de partícula encontrado para a aura.");
			return null;
		}

		private string OwnerHex(string key, ConfigEntry<string> fallback)
		{
			Player componentInParent = ((Component)this).GetComponentInParent<Player>();
			ZNetView val = (((Object)(object)componentInParent != (Object)null) ? ((Component)componentInParent).GetComponent<ZNetView>() : null);
			string text = (((Object)(object)val != (Object)null && val.IsValid()) ? val.GetZDO().GetString(key, "") : "");
			if (!string.IsNullOrEmpty(text))
			{
				return text;
			}
			return fallback.Value;
		}

		private string Signature()
		{
			return _mode + "|" + OwnerHex("pga_cgold", Plugin.ColorHex) + OwnerHex("pga_csmoke", Plugin.DarkSmokeHex) + OwnerHex("pga_crim", Plugin.DarkRimHex) + "|" + Plugin.DarkSmokeHex.Value + Plugin.DarkOpacity.Value + Plugin.DarkSmokeSize.Value + Plugin.DarkSmokeLife.Value + Plugin.DarkRing.Value + Plugin.DarkRim.Value + Plugin.DarkRimHex.Value + Plugin.DarkRimSize.Value + "|" + Plugin.Size.Value + Plugin.Height.Value + Plugin.Rate.Value + Plugin.Speed.Value + Plugin.TorchFlames.Value + Plugin.TorchFlare.Value + Plugin.TorchRing.Value + Plugin.TorchScale.Value + Plugin.TorchTint.Value + Plugin.Opacity.Value + Plugin.BodyFlames.Value + Plugin.BodyRate.Value + Plugin.BodySize.Value + Plugin.OuterFlames.Value + Plugin.OuterSize.Value;
		}

		private unsafe void Build()
		{
			//IL_0068: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_048e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0495: Expected O, but got Unknown
			//IL_04be: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			foreach (ParticleSystem system in _systems)
			{
				if ((Object)(object)system != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)system).gameObject);
				}
			}
			_systems.Clear();
			foreach (Transform item in ((Component)this).transform)
			{
				Object.Destroy((Object)(object)((Component)item).gameObject);
			}
			_sig = Signature();
			_sparks = null;
			if (_mode == 2)
			{
				BuildDark();
				return;
			}
			Color val = Plugin.Hex(OwnerHex("pga_cgold", Plugin.ColorHex), new Color(1f, 0.82f, 0.1f));
			Material mat = FindMaterial();
			float value = Plugin.Speed.Value;
			float num = Mathf.Max(0.2f, Plugin.Height.Value / Mathf.Max(0.5f, value));
			Player componentInParent = ((Component)this).GetComponentInParent<Player>();
			Animator anim = (((Object)(object)componentInParent != (Object)null) ? ((Component)componentInParent).GetComponentInChildren<Animator>() : null);
			if (Plugin.TorchFlames.Value && (Object)(object)componentInParent != (Object)null)
			{
				float value2 = Plugin.TorchScale.Value;
				(HumanBodyBones, float, float)[] bones = Bones;
				for (int i = 0; i < bones.Length; i++)
				{
					(HumanBodyBones, float, float) tuple = bones[i];
					Transform val2 = FindBone(componentInParent, anim, tuple.Item1);
					if ((Object)(object)val2 != (Object)null)
					{
						SpawnTorchFlame(val2, Vector3.zero, value2 * Mathf.Lerp(0.6f, 1.1f, tuple.Item3 / 1.4f), val);
					}
				}
				int num2 = Mathf.Max(0, Plugin.TorchRing.Value);
				for (int j = 0; j < num2; j++)
				{
					float num3 = (float)j * 137.5f * ((float)Math.PI / 180f);
					float num4 = Mathf.Lerp(0.15f, 1.75f, (num2 == 1) ? 0.5f : ((float)j / (float)(num2 - 1)));
					Vector3 localPos = new Vector3(Mathf.Cos(num3), 0f, Mathf.Sin(num3)) * Plugin.Size.Value + Vector3.up * num4;
					SpawnTorchFlame(((Component)this).transform, localPos, value2, val);
				}
			}
			if (Plugin.BodyFlames.Value && (Object)(object)componentInParent != (Object)null)
			{
				float num5 = 0f;
				(HumanBodyBones, float, float)[] bones = Bones;
				for (int i = 0; i < bones.Length; i++)
				{
					(HumanBodyBones, float, float) tuple2 = bones[i];
					num5 += tuple2.Item3;
				}
				bones = Bones;
				for (int i = 0; i < bones.Length; i++)
				{
					(HumanBodyBones, float, float) tuple3 = bones[i];
					Transform val3 = FindBone(componentInParent, anim, tuple3.Item1);
					if (!((Object)(object)val3 == (Object)null))
					{
						List<ParticleSystem> systems = _systems;
						var (val4, _, _) = tuple3;
						systems.Add(MakeSystem("corpo_" + ((object)(*(HumanBodyBones*)(&val4))/*cast due to .constrained prefix*/).ToString(), val3, Quaternion.identity, mat, val, (ParticleSystemShapeType)0, tuple3.Item2, 1f, Plugin.BodyRate.Value * tuple3.Item3 / num5, Plugin.BodySize.Value, num * 0.55f, value, 0.25f, 0f));
					}
				}
			}
			if (Plugin.OuterFlames.Value)
			{
				_systems.Add(MakeSystem("labareda", ((Component)this).transform, Quaternion.Euler(-90f, 0f, 0f), mat, val, (ParticleSystemShapeType)4, Plugin.Size.Value, 0.2f, Plugin.Rate.Value, Plugin.OuterSize.Value, num, 0f, value, -0.25f));
			}
			_sparks = MakeSystem("faiscas", ((Component)this).transform, Quaternion.Euler(-90f, 0f, 0f), mat, Color.Lerp(val, Color.white, 0.5f), (ParticleSystemShapeType)4, Plugin.Size.Value * 0.8f, 1f, Plugin.Rate.Value * 0.15f, 0.05f, num * 1.2f, 0f, value * 1.6f, 0f, sparks: true);
			_systems.Add(_sparks);
			GameObject val5 = new GameObject("luz");
			val5.transform.SetParent(((Component)this).transform, false);
			val5.transform.localPosition = new Vector3(0f, 1.1f, 0f);
			_light = val5.AddComponent<Light>();
			_light.type = (LightType)2;
			_light.color = val;
			_light.shadows = (LightShadows)0;
			_off = Random.value * 10f;
		}

		private static GameObject FindSmokeFx()
		{
			if (_smokeSearched)
			{
				return _smokeFx;
			}
			_smokeSearched = true;
			List<GameObject> list = new List<GameObject>();
			GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab("Torch") : null);
			if ((Object)(object)val != (Object)null)
			{
				list.Add(val);
			}
			string[] array = new string[3] { "fire_pit", "bonfire", "hearth" };
			foreach (string text in array)
			{
				GameObject val2 = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(text) : null);
				if ((Object)(object)val2 != (Object)null)
				{
					list.Add(val2);
				}
			}
			foreach (GameObject item in list)
			{
				ParticleSystem[] componentsInChildren = item.GetComponentsInChildren<ParticleSystem>(true);
				foreach (ParticleSystem val3 in componentsInChildren)
				{
					ParticleSystemRenderer component = ((Component)val3).GetComponent<ParticleSystemRenderer>();
					string text2 = (((Object)val3).name + " " + (((Object)(object)component != (Object)null && (Object)(object)((Renderer)component).sharedMaterial != (Object)null) ? ((Object)((Renderer)component).sharedMaterial).name : "")).ToLowerInvariant();
					if (text2.Contains("smoke"))
					{
						_smokeFx = ((Component)val3).gameObject;
						Plugin.Log.LogInfo((object)("Aura sombria usando a fumaça: " + ((Object)item).name + "/" + ((Object)val3).name + " (" + text2 + ")"));
						return _smokeFx;
					}
				}
			}
			Plugin.Log.LogWarning((object)"Nenhuma fumaça encontrada para a aura sombria.");
			return null;
		}

		private void BuildDark()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Expected O, but got Unknown
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: 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_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: 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_01e3: 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)
			Player componentInParent = ((Component)this).GetComponentInParent<Player>();
			Animator anim = (((Object)(object)componentInParent != (Object)null) ? ((Component)componentInParent).GetComponentInChildren<Animator>() : null);
			Color col = Plugin.Hex(OwnerHex("pga_csmoke", Plugin.DarkSmokeHex), new Color(0.02f, 0.02f, 0.03f));
			Color val = Plugin.Hex(OwnerHex("pga_crim", Plugin.DarkRimHex), new Color(0.54f, 0.17f, 0.89f));
			if ((Object)(object)componentInParent != (Object)null)
			{
				(HumanBodyBones, float, float)[] bones = Bones;
				for (int i = 0; i < bones.Length; i++)
				{
					(HumanBodyBones, float, float) tuple = bones[i];
					Transform val2 = FindBone(componentInParent, anim, tuple.Item1);
					if (!((Object)(object)val2 == (Object)null))
					{
						SpawnSmoke(val2, Vector3.zero, Plugin.DarkSmokeSize.Value * Mathf.Lerp(0.6f, 1.1f, tuple.Item3 / 1.4f), col);
						if (Plugin.DarkRim.Value && tuple.Item3 >= 0.9f)
						{
							SpawnTorchFlame(val2, Vector3.zero, Plugin.DarkRimSize.Value, val);
						}
					}
				}
				int num = Mathf.Max(0, Plugin.DarkRing.Value);
				for (int j = 0; j < num; j++)
				{
					float num2 = (float)j * 137.5f * ((float)Math.PI / 180f);
					float num3 = Mathf.Lerp(0.1f, 1.7f, (num == 1) ? 0.5f : ((float)j / (float)(num - 1)));
					Vector3 localPos = new Vector3(Mathf.Cos(num2), 0f, Mathf.Sin(num2)) * Plugin.Size.Value + Vector3.up * num3;
					SpawnSmoke(((Component)this).transform, localPos, Plugin.DarkSmokeSize.Value, col);
					if (Plugin.DarkRim.Value && j % 2 == 0)
					{
						SpawnTorchFlame(((Component)this).transform, localPos, Plugin.DarkRimSize.Value * 0.8f, val);
					}
				}
			}
			GameObject val3 = new GameObject("luz");
			val3.transform.SetParent(((Component)this).transform, false);
			val3.transform.localPosition = new Vector3(0f, 1.1f, 0f);
			_light = val3.AddComponent<Light>();
			_light.type = (LightType)2;
			_light.color = val;
			_light.shadows = (LightShadows)0;
			_off = Random.value * 10f;
		}

		private void SpawnSmoke(Transform parent, Vector3 localPos, float scale, Color col)
		{
			//IL_0031: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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_0121: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = FindSmokeFx();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			GameObject val2 = Object.Instantiate<GameObject>(val, parent, false);
			((Object)val2).name = "aura_fumaca";
			val2.SetActive(true);
			val2.transform.localPosition = localPos;
			val2.transform.localRotation = Quaternion.identity;
			val2.transform.localScale = Vector3.one * scale;
			Light[] componentsInChildren = val2.GetComponentsInChildren<Light>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren[i]);
			}
			AudioSource[] componentsInChildren2 = val2.GetComponentsInChildren<AudioSource>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren2[i]);
			}
			float num = Mathf.Clamp01(Plugin.DarkOpacity.Value);
			float num2 = Mathf.Max(0.05f, Plugin.DarkSmokeLife.Value);
			ParticleSystem[] componentsInChildren3 = val2.GetComponentsInChildren<ParticleSystem>(true);
			foreach (ParticleSystem val3 in componentsInChildren3)
			{
				val3.Stop(true, (ParticleSystemStopBehavior)0);
				MainModule main = val3.main;
				((MainModule)(ref main)).playOnAwake = false;
				((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0;
				((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
				((MainModule)(ref main)).startLifetimeMultiplier = ((MainModule)(ref main)).startLifetimeMultiplier * num2;
				((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(col.r, col.g, col.b, num));
				ColorOverLifetimeModule colorOverLifetime = val3.colorOverLifetime;
				if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled)
				{
					((ColorOverLifetimeModule)(ref colorOverLifetime)).color = Paint(((ColorOverLifetimeModule)(ref colorOverLifetime)).color, col);
				}
				_systems.Add(val3);
			}
		}

		private static MinMaxGradient Paint(MinMaxGradient g, Color c)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected I4, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_0080: 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_0097: 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_00a7: 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_00bd: 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_00d3: 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_006e: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystemGradientMode mode = ((MinMaxGradient)(ref g)).mode;
			switch (mode - 1)
			{
			case 0:
			case 3:
			{
				MinMaxGradient result = default(MinMaxGradient);
				((MinMaxGradient)(ref result))..ctor(Do(((MinMaxGradient)(ref g)).gradient));
				((MinMaxGradient)(ref result)).mode = ((MinMaxGradient)(ref g)).mode;
				return result;
			}
			case 2:
				return new MinMaxGradient(Do(((MinMaxGradient)(ref g)).gradientMin), Do(((MinMaxGradient)(ref g)).gradientMax));
			case 1:
				return new MinMaxGradient(new Color(c.r, c.g, c.b, ((MinMaxGradient)(ref g)).colorMin.a), new Color(c.r, c.g, c.b, ((MinMaxGradient)(ref g)).colorMax.a));
			default:
				return new MinMaxGradient(new Color(c.r, c.g, c.b, ((MinMaxGradient)(ref g)).color.a));
			}
			Gradient Do(Gradient src)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Expected O, but got Unknown
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				if (src == null)
				{
					return null;
				}
				Gradient val = new Gradient();
				GradientColorKey[] colorKeys = src.colorKeys;
				for (int i = 0; i < colorKeys.Length; i++)
				{
					colorKeys[i].color = new Color(c.r, c.g, c.b);
				}
				val.SetKeys(colorKeys, src.alphaKeys);
				return val;
			}
		}

		private static GameObject FindTorchFx()
		{
			if (_torchSearched)
			{
				return _torchFx;
			}
			_torchSearched = true;
			GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab("Torch") : null);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)"Prefab Torch não encontrado.");
				return null;
			}
			ParticleSystem[] componentsInChildren = val.GetComponentsInChildren<ParticleSystem>(true);
			foreach (ParticleSystem val2 in componentsInChildren)
			{
				ParticleSystemRenderer component = ((Component)val2).GetComponent<ParticleSystemRenderer>();
				string text = (((Object)val2).name + " " + (((Object)(object)component != (Object)null && (Object)(object)((Renderer)component).sharedMaterial != (Object)null) ? ((Object)((Renderer)component).sharedMaterial).name : "")).ToLowerInvariant();
				ManualLogSource log = Plugin.Log;
				string[] obj = new string[7] { "Tocha tem partícula: ", null, null, null, null, null, null };
				Transform parent = ((Component)val2).transform.parent;
				obj[1] = ((parent != null) ? ((Object)parent).name : null);
				obj[2] = "/";
				obj[3] = ((Object)val2).name;
				obj[4] = " (";
				obj[5] = text;
				obj[6] = ")";
				log.LogInfo((object)string.Concat(obj));
				if ((Object)(object)_torchFx == (Object)null && text.Contains("flame"))
				{
					_torchFx = ((Component)val2).gameObject;
				}
			}
			if ((Object)(object)_torchFx == (Object)null)
			{
				ParticleSystem componentInChildren = val.GetComponentInChildren<ParticleSystem>(true);
				if ((Object)(object)componentInChildren != (Object)null)
				{
					_torchFx = ((Component)componentInChildren).gameObject;
				}
			}
			if ((Object)(object)_torchFx != (Object)null)
			{
				Plugin.Log.LogInfo((object)("Aura usando o fogo da tocha: " + ((Object)_torchFx).name));
			}
			return _torchFx;
		}

		private void SpawnTorchFlame(Transform parent, Vector3 localPos, float scale, Color col)
		{
			//IL_0031: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_01da: 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_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = FindTorchFx();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			GameObject val2 = Object.Instantiate<GameObject>(val, parent, false);
			((Object)val2).name = "aura_tocha";
			val2.SetActive(true);
			val2.transform.localPosition = localPos;
			val2.transform.localRotation = Quaternion.identity;
			val2.transform.localScale = Vector3.one * scale;
			Light[] componentsInChildren = val2.GetComponentsInChildren<Light>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren[i]);
			}
			ParticleSystem[] componentsInChildren2 = val2.GetComponentsInChildren<ParticleSystem>(true);
			foreach (ParticleSystem val3 in componentsInChildren2)
			{
				string text = ((Object)val3).name.ToLowerInvariant();
				if ((text.Contains("flare") && !Plugin.TorchFlare.Value) || text.Contains("smoke"))
				{
					((Component)val3).gameObject.SetActive(false);
					Object.Destroy((Object)(object)((Component)val3).gameObject);
				}
			}
			AudioSource[] componentsInChildren3 = val2.GetComponentsInChildren<AudioSource>(true);
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren3[i]);
			}
			float t = Mathf.Clamp01(Plugin.TorchTint.Value);
			float op = Mathf.Clamp01(Plugin.Opacity.Value * 2f);
			componentsInChildren2 = val2.GetComponentsInChildren<ParticleSystem>(false);
			foreach (ParticleSystem val4 in componentsInChildren2)
			{
				string text2 = ((Object)val4).name.ToLowerInvariant();
				if ((!text2.Contains("flare") || Plugin.TorchFlare.Value) && !text2.Contains("smoke"))
				{
					val4.Stop(true, (ParticleSystemStopBehavior)0);
					MainModule main = val4.main;
					((MainModule)(ref main)).playOnAwake = false;
					((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0;
					((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
					((MainModule)(ref main)).startColor = TintGradient(((MainModule)(ref main)).startColor, col, t, op);
					ColorOverLifetimeModule colorOverLifetime = val4.colorOverLifetime;
					if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled)
					{
						((ColorOverLifetimeModule)(ref colorOverLifetime)).color = TintGradient(((ColorOverLifetimeModule)(ref colorOverLifetime)).color, col, t, 1f);
					}
					_systems.Add(val4);
				}
			}
		}

		private static Color TintColor(Color c, Color target, float t, float op)
		{
			//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_0019: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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)
			float num = c.r * 0.3f + c.g * 0.59f + c.b * 0.11f;
			Color val = Color.Lerp(target, Color.white, Mathf.Clamp01(num - 0.6f)) * Mathf.Lerp(0.7f, 1.4f, num);
			Color result = Color.Lerp(c, val, t);
			result.a = c.a * op;
			return result;
		}

		private static MinMaxGradient TintGradient(MinMaxGradient g, Color target, float t, float op)
		{
			//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_0031: 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_0069: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_00a4: 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)
			ParticleSystemGradientMode mode = ((MinMaxGradient)(ref g)).mode;
			switch ((int)mode)
			{
			case 0:
				return new MinMaxGradient(TintColor(((MinMaxGradient)(ref g)).color, target, t, op));
			case 2:
				return new MinMaxGradient(TintColor(((MinMaxGradient)(ref g)).colorMin, target, t, op), TintColor(((MinMaxGradient)(ref g)).colorMax, target, t, op));
			case 1:
			case 4:
			{
				MinMaxGradient result = default(MinMaxGradient);
				((MinMaxGradient)(ref result))..ctor(TintGrad(((MinMaxGradient)(ref g)).gradient, target, t, op));
				((MinMaxGradient)(ref result)).mode = ((MinMaxGradient)(ref g)).mode;
				return result;
			}
			case 3:
				return new MinMaxGradient(TintGrad(((MinMaxGradient)(ref g)).gradientMin, target, t, op), TintGrad(((MinMaxGradient)(ref g)).gradientMax, target, t, op));
			default:
				return g;
			}
		}

		private static Gradient TintGrad(Gradient src, Color target, float t, float op)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			if (src == null)
			{
				return null;
			}
			Gradient val = new Gradient();
			GradientColorKey[] colorKeys = src.colorKeys;
			for (int i = 0; i < colorKeys.Length; i++)
			{
				colorKeys[i].color = TintColor(colorKeys[i].color, target, t, 1f);
			}
			GradientAlphaKey[] alphaKeys = src.alphaKeys;
			for (int j = 0; j < alphaKeys.Length; j++)
			{
				alphaKeys[j].alpha *= op;
			}
			val.SetKeys(colorKeys, alphaKeys);
			val.mode = src.mode;
			return val;
		}

		private static Transform FindBone(Player p, Animator anim, HumanBodyBones bone)
		{
			//IL_0029: 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)
			if ((Object)(object)anim != (Object)null && anim.isHuman)
			{
				Transform boneTransform = anim.GetBoneTransform(bone);
				if ((Object)(object)boneTransform != (Object)null)
				{
					return boneTransform;
				}
			}
			if (!BoneNames.TryGetValue(bone, out var value))
			{
				return null;
			}
			string[] array = value;
			foreach (string text in array)
			{
				Transform[] componentsInChildren = ((Component)p).GetComponentsInChildren<Transform>(true);
				foreach (Transform val in componentsInChildren)
				{
					if (((Object)val).name == text)
					{
						return val;
					}
				}
			}
			return null;
		}

		private ParticleSystem MakeSystem(string name, Transform parent, Quaternion rot, Material mat, Color col, ParticleSystemShapeType shapeType, float radius, float thickness, float rate, float size, float life, float upSpeed, float startSpeed, float radial, bool sparks = false)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_00a4: 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_00d6: 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_00f8: 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_0105: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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_0147: Invalid comparison between Unknown and I4
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Expected O, but got Unknown
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: 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_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Expected O, but got Unknown
			//IL_039e: 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_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: 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_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("aura_" + name);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = (Vector3)(((Object)(object)parent == (Object)(object)((Component)this).transform) ? new Vector3(0f, 0.05f, 0f) : Vector3.zero);
			val.transform.localRotation = rot;
			ParticleSystem val2 = val.AddComponent<ParticleSystem>();
			val2.Stop(true, (ParticleSystemStopBehavior)0);
			MainModule main = val2.main;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).maxParticles = 1000;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(life * 0.6f, life);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(startSpeed * 0.7f, startSpeed * 1.2f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(size * 0.6f, size);
			((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f);
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(col);
			EmissionModule emission = val2.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(rate);
			ShapeModule shape = val2.shape;
			((ShapeModule)(ref shape)).enabled = true;
			((ShapeModule)(ref shape)).shapeType = shapeType;
			((ShapeModule)(ref shape)).radius = radius;
			((ShapeModule)(ref shape)).radiusThickness = thickness;
			if ((int)shapeType == 4)
			{
				((ShapeModule)(ref shape)).angle = 2f;
			}
			VelocityOverLifetimeModule velocityOverLifetime = val2.velocityOverLifetime;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = upSpeed != 0f || radial != 0f;
			if (((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled)
			{
				if (upSpeed != 0f)
				{
					((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1;
					((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(0f, 0f);
					((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(upSpeed * 0.8f, upSpeed * 1.2f);
					((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(0f, 0f);
				}
				else
				{
					((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)0;
					((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(0f, 0f);
					((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0f, 0f);
					((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(0f, 0f);
				}
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).radial = new MinMaxCurve(radial, radial);
			}
			float num = Mathf.Clamp01(Plugin.Opacity.Value);
			ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val3 = new Gradient();
			Color val4 = Color.Lerp(col, Color.white, 0.55f);
			val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
			{
				new GradientColorKey(val4, 0f),
				new GradientColorKey(col, 0.35f),
				new GradientColorKey(col * 0.8f, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[4]
			{
				new GradientAlphaKey(0f, 0f),
				new GradientAlphaKey(0.9f * num, 0.12f),
				new GradientAlphaKey(0.55f * num, 0.6f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val3);
			SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, 0.5f),
				new Keyframe(0.3f, 1f),
				new Keyframe(1f, 0.15f)
			}));
			if (!sparks)
			{
				NoiseModule noise = val2.noise;
				((NoiseModule)(ref noise)).enabled = true;
				((NoiseModule)(ref noise)).strength = MinMaxCurve.op_Implicit(0.45f);
				((NoiseModule)(ref noise)).frequency = 1.3f;
				((NoiseModule)(ref noise)).scrollSpeed = MinMaxCurve.op_Implicit(1.5f);
			}
			if ((Object)(object)_srcSystem != (Object)null)
			{
				TextureSheetAnimationModule textureSheetAnimation = _srcSystem.textureSheetAnimation;
				if (((TextureSheetAnimationModule)(ref textureSheetAnimation)).enabled)
				{
					TextureSheetAnimationModule textureSheetAnimation2 = val2.textureSheetAnimation;
					((TextureSheetAnimationModule)(ref textureSheetAnimation2)).enabled = true;
					((TextureSheetAnimationModule)(ref textureSheetAnimation2)).mode = ((TextureSheetAnimationModule)(ref textureSheetAnimation)).mode;
					((TextureSheetAnimationModule)(ref textureSheetAnimation2)).numTilesX = ((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesX;
					((TextureSheetAnimationModule)(ref textureSheetAnimation2)).numTilesY = ((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesY;
					((TextureSheetAnimationModule)(ref textureSheetAnimation2)).animation = ((TextureSheetAnimationModule)(ref textureSheetAnimation)).animation;
					((TextureSheetAnimationModule)(ref textureSheetAnimation2)).frameOverTime = ((TextureSheetAnimationModule)(ref textureSheetAnimation)).frameOverTime;
					((TextureSheetAnimationModule)(ref textureSheetAnimation2)).startFrame = ((TextureSheetAnimationModule)(ref textureSheetAnimation)).startFrame;
					((TextureSheetAnimationModule)(ref textureSheetAnimation2)).cycleCount = ((TextureSheetAnimationModule)(ref textureSheetAnimation)).cycleCount;
					((TextureSheetAnimationModule)(ref textureSheetAnimation2)).rowIndex = ((TextureSheetAnimationModule)(ref textureSheetAnimation)).rowIndex;
				}
			}
			ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
			if ((Object)(object)mat != (Object)null)
			{
				((Renderer)component).sharedMaterial = mat;
			}
			component.renderMode = (ParticleSystemRenderMode)(sparks ? 1 : 0);
			if (sparks)
			{
				component.lengthScale = 4f;
				component.velocityScale = 0.05f;
			}
			((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)component).receiveShadows = false;
			return val2;
		}

		internal void SetOn(bool on)
		{
			if (on && _sig != Signature())
			{
				Build();
			}
			foreach (ParticleSystem system in _systems)
			{
				if ((Object)(object)system == (Object)null)
				{
					continue;
				}
				if (on)
				{
					if (!system.isPlaying)
					{
						system.Play(true);
					}
				}
				else if (system.isEmitting)
				{
					system.Stop(true, (ParticleSystemStopBehavior)1);
				}
			}
			if (!((Object)(object)_light == (Object)null))
			{
				if (on)
				{
					float num = 1f + Plugin.PulseAmount.Value * Mathf.Sin((Time.time + _off) * Plugin.PulseSpeed.Value * (float)Math.PI * 2f);
					((Behaviour)_light).enabled = true;
					_light.range = Plugin.LightRange.Value;
					_light.intensity = ((_mode == 2) ? Plugin.DarkLight.Value : Plugin.LightIntensity.Value) * num;
				}
				else
				{
					((Behaviour)_light).enabled = false;
				}
			}
		}

		private void OnDestroy()
		{
			foreach (ParticleSystem system in _systems)
			{
				if ((Object)(object)system != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)system).gameObject);
				}
			}
		}
	}
	internal class ConfigReload : MonoBehaviour
	{
		private ConfigFile _cfg;

		private volatile bool _dirty;

		private float _at;

		internal static void Watch(BaseUnityPlugin plugin, ConfigFile cfg, string guid)
		{
			ConfigReload r = ((Component)plugin).gameObject.AddComponent<ConfigReload>();
			r._cfg = cfg;
			try
			{
				FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, guid + ".cfg");
				fileSystemWatcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite;
				fileSystemWatcher.Changed += delegate
				{
					r._dirty = true;
				};
				fileSystemWatcher.Created += delegate
				{
					r._dirty = true;
				};
				fileSystemWatcher.Renamed += delegate
				{
					r._dirty = true;
				};
				fileSystemWatcher.EnableRaisingEvents = true;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Sem recarga automática do cfg: " + ex.Message));
			}
		}

		private void Update()
		{
			if (_dirty)
			{
				_dirty = false;
				_at = Time.time + 0.3f;
			}
			if (_at > 0f && Time.time >= _at)
			{
				_at = 0f;
				try
				{
					_cfg.Reload();
					Plugin.Log.LogInfo((object)"Config recarregada.");
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("Falha ao recarregar cfg: " + ex.Message));
				}
			}
		}
	}
}