Decompiled source of JefesValheim v1.0.1

BepInEx/plugins/JefesValheim/JefesValheim.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Entities;
using Jotunn.Managers;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Networking;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("JefesValheim")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JefesValheim")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e216b55d-0d34-4f2d-9443-dd77c6b0396b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace NeckzillaBossMod
{
	[BepInPlugin("com.yournick.valheim.neckzilla", "Neckzilla Boss", "1.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class MainPlugin : BaseUnityPlugin
	{
		public class NoFleeRefresher : MonoBehaviour
		{
			private BaseAI _ai;

			private float _t;

			private void Start()
			{
				_ai = ((Component)this).GetComponent<BaseAI>();
				Apply();
			}

			private void Update()
			{
				_t += Time.deltaTime;
				if (_t >= 3f)
				{
					_t = 0f;
					Apply();
				}
			}

			private void Apply()
			{
				if (Object.op_Implicit((Object)(object)_ai))
				{
					TrySetField<BaseAI, bool>(_ai, "m_afraidOfFire", value: false);
					TrySetField<BaseAI, bool>(_ai, "m_avoidFire", value: false);
					TrySetField<BaseAI, bool>(_ai, "m_fleeIfHurt", value: false);
					TrySetField<BaseAI, bool>(_ai, "m_backoffOnLowHP", value: false);
					TrySetField<BaseAI, bool>(_ai, "m_avoidPlayer", value: false);
					TrySetField<BaseAI, bool>(_ai, "m_avoidWater", value: false);
					TrySetField<BaseAI, float>(_ai, "m_afraidOfFireRange", 0f);
					TrySetField<BaseAI, float>(_ai, "m_avoidFireDistance", 0f);
					TrySetField<BaseAI, float>(_ai, "m_avoidPlayerDistance", 0f);
					TrySetField<BaseAI, float>(_ai, "m_avoidWaterDistance", 0f);
					ForceNoFleeFlags(_ai);
				}
			}
		}

		[HarmonyPatch(typeof(Character), "Stagger")]
		public static class Patch_Neckzilla_NoStagger_NoArg
		{
			private static bool Prefix(Character __instance)
			{
				try
				{
					if (Object.op_Implicit((Object)(object)__instance) && __instance.m_name == "Neckzilla")
					{
						TrySetField<Character, float>(__instance, "m_staggerDamage", 0f);
						TrySetField<Character, float>(__instance, "m_staggerTimer", 0f);
						return false;
					}
				}
				catch
				{
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Character), "Stagger", new Type[] { typeof(Vector3) })]
		public static class Patch_Neckzilla_NoStagger_WithDir
		{
			private static bool Prefix(Character __instance, Vector3 __0)
			{
				try
				{
					if (Object.op_Implicit((Object)(object)__instance) && __instance.m_name == "Neckzilla")
					{
						TrySetField<Character, float>(__instance, "m_staggerDamage", 0f);
						TrySetField<Character, float>(__instance, "m_staggerTimer", 0f);
						return false;
					}
				}
				catch
				{
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Character), "Damage")]
		public static class Patch_Neckzilla_InvulnerableDuringPhase2
		{
			private static bool Prefix(Character __instance, HitData hit)
			{
				try
				{
					if (Object.op_Implicit((Object)(object)__instance) && __instance.m_name == "Neckzilla")
					{
						if (((DamageTypes)(ref hit.m_damage)).GetTotalDamage() >= 9999f)
						{
							return true;
						}
						NeckzillaPhase2 component = ((Component)__instance).GetComponent<NeckzillaPhase2>();
						if ((Object)(object)component != (Object)null && component.IsActive)
						{
							return false;
						}
						if ((Object)(object)component != (Object)null && component.IsFinalWindup)
						{
							return false;
						}
						if ((Object)(object)hit.GetAttacker() == (Object)null)
						{
							return false;
						}
					}
				}
				catch
				{
				}
				return true;
			}
		}

		public class KeepFireImmunity : MonoBehaviour
		{
			private Character _self;

			private SEMan _seman;

			private float _t;

			private void Start()
			{
				_self = ((Component)this).GetComponent<Character>();
				_seman = ((Component)this).GetComponent<SEMan>();
				MakeFireImmune(_self);
			}

			private void Update()
			{
				_t += Time.deltaTime;
				if (!(_t >= 2f))
				{
					return;
				}
				_t = 0f;
				MakeFireImmune(_self);
				try
				{
					if (_seman == null)
					{
						return;
					}
					BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
					if (!(typeof(SEMan).GetField("m_statusEffects", bindingAttr)?.GetValue(_seman) is IList list) || list.Count == 0)
					{
						return;
					}
					List<object> list2 = new List<object>();
					foreach (object item in list)
					{
						if (item != null)
						{
							string text = item.GetType().Name.ToLowerInvariant();
							FieldInfo field = item.GetType().GetField("m_name", bindingAttr);
							string text2 = ((field != null) ? (field.GetValue(item) as string) : null)?.ToLowerInvariant() ?? "";
							if (text.Contains("burn") || text2.Contains("burn"))
							{
								list2.Add(item);
							}
						}
					}
					if (list2.Count <= 0)
					{
						return;
					}
					MethodInfo method = typeof(SEMan).GetMethod("RemoveStatusEffect", bindingAttr, null, new Type[1] { typeof(int) }, null);
					foreach (object item2 in list2)
					{
						FieldInfo field2 = item2.GetType().GetField("m_nameHash", bindingAttr);
						if (method != null && field2 != null)
						{
							int num = (int)field2.GetValue(item2);
							method.Invoke(_seman, new object[1] { num });
						}
						else
						{
							item2.GetType().GetMethod("Stop", bindingAttr)?.Invoke(item2, new object[1] { _seman });
						}
					}
				}
				catch
				{
				}
			}
		}

		[HarmonyPatch(typeof(Character), "Damage")]
		public static class Patch_Neckzilla_BiteDamage
		{
			private static void Prefix(Character __instance, ref HitData hit)
			{
				if (hit == null)
				{
					return;
				}
				Character attacker = hit.GetAttacker();
				if ((Object)(object)attacker == (Object)null || attacker.m_name != "Neckzilla")
				{
					return;
				}
				float pierce = hit.m_damage.m_pierce;
				float slash = hit.m_damage.m_slash;
				float num = pierce + slash;
				if (!(num <= 0.0001f))
				{
					if (BITE_BASE > 0f)
					{
						float num2 = BITE_BASE / num;
						hit.m_damage.m_pierce = pierce * num2;
						hit.m_damage.m_slash = slash * num2;
					}
					else if (BITE_MULT != 1f)
					{
						hit.m_damage.m_pierce *= BITE_MULT;
						hit.m_damage.m_slash *= BITE_MULT;
					}
				}
			}
		}

		[HarmonyPatch(typeof(Character), "Damage")]
		public static class Patch_Neckzilla_LavaFireDamage
		{
			private static void Prefix(Character __instance, ref HitData hit)
			{
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				if (!(__instance is Player) || hit == null || hit.m_damage.m_fire <= 0f)
				{
					return;
				}
				float lAVA_FIRE_MULT = LAVA_FIRE_MULT;
				if (Mathf.Approximately(lAVA_FIRE_MULT, 1f))
				{
					return;
				}
				bool flag = false;
				List<Character> list = new List<Character>();
				try
				{
					Character.GetCharactersInRange(((Component)__instance).transform.position, 60f, list);
				}
				catch
				{
				}
				for (int i = 0; i < list.Count; i++)
				{
					Character val = list[i];
					if (!((Object)(object)val == (Object)null) && !(val.m_name != "Neckzilla"))
					{
						NeckzillaLavaField component = ((Component)val).GetComponent<NeckzillaLavaField>();
						if ((Object)(object)component != (Object)null && component.IsActive)
						{
							flag = true;
							break;
						}
					}
				}
				if (flag)
				{
					hit.m_damage.m_fire *= lAVA_FIRE_MULT;
				}
			}
		}

		[HarmonyPatch(typeof(Character), "SetLevel")]
		public static class Patch_Neckzilla_NoStars
		{
			private static bool Prefix(Character __instance, int level)
			{
				if (level > 1 && __instance.m_name == "Neckzilla")
				{
					return false;
				}
				return true;
			}
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static ConsoleEvent <>9__93_36;

			public static Action<AudioClip> <>9__95_0;

			public static Action<AudioClip> <>9__95_1;

			internal void <Awake>b__93_36(ConsoleEventArgs _)
			{
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_008e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				GameObject prefab = PrefabManager.Instance.GetPrefab("Boss_Neckzilla");
				if (!Object.op_Implicit((Object)(object)prefab))
				{
					Log.LogError((object)"Prefab no disponible aún.");
					return;
				}
				Player localPlayer = Player.m_localPlayer;
				if (Object.op_Implicit((Object)(object)localPlayer))
				{
					Vector3 val = ((Component)localPlayer).transform.position + ((Component)localPlayer).transform.forward * 5f;
					Quaternion val2 = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f);
					Object.Instantiate<GameObject>(prefab, val, val2);
				}
			}

			internal void <LoadAudioFiles>b__95_0(AudioClip c)
			{
				RoarClip = c;
			}

			internal void <LoadAudioFiles>b__95_1(AudioClip c)
			{
				MusicClip = c;
			}
		}

		public const string ModGuid = "com.yournick.valheim.neckzilla";

		public const string ModName = "Neckzilla Boss";

		public const string ModVersion = "1.1.1";

		internal static MainPlugin Instance;

		internal static ManualLogSource Log;

		private Harmony _harmony;

		private const string BossPrefabName = "Boss_Neckzilla";

		private ConfigEntry<float> _cfgScale;

		private ConfigEntry<float> _cfgHealth;

		private ConfigEntry<float> _stompCooldown;

		private ConfigEntry<float> _stompRange;

		private ConfigEntry<float> _stompDamage;

		private ConfigEntry<float> _stompPush;

		private ConfigEntry<int> _stompFxSteps;

		private ConfigEntry<float> _stompTelegraphSeconds;

		private ConfigEntry<string> _stompTelegraphFx;

		private ConfigEntry<float> _bombCooldown;

		private ConfigEntry<float> _bombMinRange;

		private ConfigEntry<float> _bombMaxRange;

		private ConfigEntry<float> _bombSpeed;

		private ConfigEntry<float> _bombImpactFire;

		private ConfigEntry<float> _bombImpactBlunt;

		private ConfigEntry<float> _bombAoeRadius;

		private ConfigEntry<float> _phase2ThresholdPct;

		private ConfigEntry<float> _phase2Duration;

		private ConfigEntry<float> _phase2AuraRadius;

		private ConfigEntry<float> _phase2AuraTick;

		private ConfigEntry<float> _phase2AuraDamage;

		private ConfigEntry<float> _phase2PlayerStaggerEvery;

		private ConfigEntry<float> _phase2BossLightningAt;

		private ConfigEntry<float> _phase2LeviathanDur;

		private ConfigEntry<string> _phase2BoltPrefab;

		private ConfigEntry<string> _thunderStrikePrefab;

		private ConfigEntry<float> _thunderCooldown;

		private ConfigEntry<float> _thunderDelay;

		private ConfigEntry<float> _thunderDamage;

		private ConfigEntry<float> _thunderRadius;

		private ConfigEntry<string> _lavaPrefabName;

		private ConfigEntry<float> _lavaMinRadius;

		private ConfigEntry<float> _lavaMaxRadius;

		private ConfigEntry<float> _lavaInterval;

		private ConfigEntry<int> _lavaBurst;

		private ConfigEntry<float> _lavaFireDamageMultiplier;

		private ConfigEntry<float> _biteBaseDamage;

		private ConfigEntry<float> _biteDamageMultiplier;

		internal static string LAVA_PREFAB;

		internal static float LAVA_RMIN;

		internal static float LAVA_RMAX;

		internal static float LAVA_INTERVAL;

		internal static int LAVA_BURST;

		internal static float ST_COOLDOWN;

		internal static float ST_RANGE;

		internal static float ST_DAMAGE;

		internal static float ST_PUSH;

		internal static int ST_FXSTEPS;

		internal static string ST_FXNAME = "fx_Abomination_attack2";

		internal static float P2_THRESHOLD_PCT;

		internal static float P2_DURATION;

		internal static float P2_AURA_RADIUS;

		internal static float P2_AURA_TICK;

		internal static float P2_AURA_DAMAGE;

		internal static float P2_STAGGER_EVERY;

		internal static float THU_COOLDOWN;

		internal static float THU_DELAY;

		internal static float THU_DAMAGE;

		internal static float THU_RADIUS;

		internal static string THU_STRIKE_PREFAB = "lightningAOE";

		internal static float P2_BOSS_LIGHTNING_AT = 17f;

		internal static float P2_LEVIATHAN_DUR = 27f;

		internal static string P2_BOLT_PREFAB = "lightningAOE";

		internal static float BMB_CD;

		internal static float BMB_MIN;

		internal static float BMB_MAX;

		internal static float BMB_SPEED;

		internal static float BMB_FIRE;

		internal static float BMB_BLUNT;

		internal static float BMB_AOE;

		internal const string BMB_PROJ_NAME = "DvergerStaffFire_clusterbomb_projectile";

		internal static float ST_TELEGRAPH;

		internal static string ST_TELE_FX;

		internal static float BITE_BASE;

		internal static float BITE_MULT;

		internal static float LAVA_FIRE_MULT;

		private ConfigEntry<string> _cfgDrop1;

		private ConfigEntry<string> _cfgDrop2;

		private ConfigEntry<string> _cfgDrop3;

		private ConfigEntry<string> _cfgDrop4;

		private ConfigEntry<string> _cfgDrop5;

		private ConfigEntry<string> _cfgRoarFile;

		private ConfigEntry<string> _cfgMusicFile;

		internal static AudioClip RoarClip;

		internal static AudioClip MusicClip;

		private static AudioSource _bossMusic;

		private static AudioMixerGroup _sfxMixerGroup;

		internal static bool BossMusicActive;

		private static readonly List<AudioSource> _mutedVanillaSources = new List<AudioSource>();

		private static Material _charredMatCache;

		private void Awake()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Expected O, but got Unknown
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Expected O, but got Unknown
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Expected O, but got Unknown
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Expected O, but got Unknown
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Expected O, but got Unknown
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Expected O, but got Unknown
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Expected O, but got Unknown
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Expected O, but got Unknown
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Expected O, but got Unknown
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Expected O, but got Unknown
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Expected O, but got Unknown
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_044f: Expected O, but got Unknown
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_048d: Expected O, but got Unknown
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cb: Expected O, but got Unknown
			//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0509: Expected O, but got Unknown
			//IL_053d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0547: Expected O, but got Unknown
			//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cf: Expected O, but got Unknown
			//IL_0603: Unknown result type (might be due to invalid IL or missing references)
			//IL_060d: Expected O, but got Unknown
			//IL_0641: Unknown result type (might be due to invalid IL or missing references)
			//IL_064b: Expected O, but got Unknown
			//IL_067f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0689: Expected O, but got Unknown
			//IL_06e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ec: Expected O, but got Unknown
			//IL_0720: Unknown result type (might be due to invalid IL or missing references)
			//IL_072a: Expected O, but got Unknown
			//IL_075e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0768: Expected O, but got Unknown
			//IL_0790: Unknown result type (might be due to invalid IL or missing references)
			//IL_079a: Expected O, but got Unknown
			//IL_07ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d8: Expected O, but got Unknown
			//IL_0856: Unknown result type (might be due to invalid IL or missing references)
			//IL_0860: Expected O, but got Unknown
			//IL_0894: Unknown result type (might be due to invalid IL or missing references)
			//IL_089e: Expected O, but got Unknown
			//IL_0d5e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d4a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d4f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d55: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			_harmony = new Harmony("com.yournick.valheim.neckzilla");
			_harmony.PatchAll();
			ApplyMusicManPatches();
			_cfgScale = ((BaseUnityPlugin)this).Config.Bind<float>("Neckzilla", "Scale", 3f, "Multiplicador de tamaño (1 = Neck normal).");
			_cfgHealth = ((BaseUnityPlugin)this).Config.Bind<float>("Neckzilla", "Health", 2500f, "Vida base de Neckzilla.");
			_stompCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Stomp", "Cooldown", 4f, new ConfigDescription("Segundos entre pisotones.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>()));
			_stompRange = ((BaseUnityPlugin)this).Config.Bind<float>("Stomp", "Range", 8f, new ConfigDescription("Radio del AOE.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 20f), Array.Empty<object>()));
			_stompDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Stomp", "Damage", 80f, new ConfigDescription("Daño blunt por pisotón.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 5000f), Array.Empty<object>()));
			_stompPush = ((BaseUnityPlugin)this).Config.Bind<float>("Stomp", "PushForce", 40f, new ConfigDescription("Empuje radial.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f), Array.Empty<object>()));
			_stompFxSteps = ((BaseUnityPlugin)this).Config.Bind<int>("Stomp", "FxSteps", 6, new ConfigDescription("Número de FX del anillo.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 12), Array.Empty<object>()));
			_bombCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Bombard", "Cooldown", 6f, new ConfigDescription("Segundos entre bombardeos.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 60f), Array.Empty<object>()));
			_bombMinRange = ((BaseUnityPlugin)this).Config.Bind<float>("Bombard", "MinRange", 10f, new ConfigDescription("Distancia mínima para disparar.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 60f), Array.Empty<object>()));
			_bombMaxRange = ((BaseUnityPlugin)this).Config.Bind<float>("Bombard", "MaxRange", 35f, new ConfigDescription("Distancia máxima para disparar.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 120f), Array.Empty<object>()));
			_bombSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Bombard", "ProjectileSpeed", 10f, new ConfigDescription("Velocidad del proyectil.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 80f), Array.Empty<object>()));
			_bombImpactFire = ((BaseUnityPlugin)this).Config.Bind<float>("Bombard", "ImpactFire", 30f, new ConfigDescription("Daño de fuego directo al impactar.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 500f), Array.Empty<object>()));
			_bombImpactBlunt = ((BaseUnityPlugin)this).Config.Bind<float>("Bombard", "ImpactBlunt", 60f, new ConfigDescription("Daño blunt directo al impactar.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 500f), Array.Empty<object>()));
			_bombAoeRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Bombard", "ImpactRadius", 3.5f, new ConfigDescription("Radio del daño directo al impactar.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 12f), Array.Empty<object>()));
			_phase2ThresholdPct = ((BaseUnityPlugin)this).Config.Bind<float>("Phase2", "TriggerAtHealthPct", 0.8f, new ConfigDescription("Umbral de activación (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 0.95f), Array.Empty<object>()));
			_phase2Duration = ((BaseUnityPlugin)this).Config.Bind<float>("Phase2", "Duration", 30f, new ConfigDescription("Duración de la fase 2 en segundos.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 120f), Array.Empty<object>()));
			_phase2AuraRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Phase2", "AuraRadius", 8f, new ConfigDescription("Radio del aura de daño.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 20f), Array.Empty<object>()));
			_phase2AuraTick = ((BaseUnityPlugin)this).Config.Bind<float>("Phase2", "AuraTickSeconds", 0.5f, new ConfigDescription("Periodo del tick de aura.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 2f), Array.Empty<object>()));
			_phase2AuraDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Phase2", "AuraDamageFire", 4f, new ConfigDescription("Daño de fuego por tick del aura.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f), Array.Empty<object>()));
			_phase2PlayerStaggerEvery = ((BaseUnityPlugin)this).Config.Bind<float>("Phase2", "StaggerPlayersEvery", 2f, new ConfigDescription("Cada cuantos segundos se aplica stagger a jugadores.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 10f), Array.Empty<object>()));
			_phase2BossLightningAt = ((BaseUnityPlugin)this).Config.Bind<float>("Phase2", "Transformacion_RayoSegundo", 17f, new ConfigDescription("Segundo del faseo en que cae el rayo sobre el boss.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 55f), Array.Empty<object>()));
			_phase2LeviathanDur = ((BaseUnityPlugin)this).Config.Bind<float>("Phase2", "Transformacion_Duracion", 27f, new ConfigDescription("Duracion del FX leviathan. Al terminar se activan los rayos.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 60f), Array.Empty<object>()));
			_phase2BoltPrefab = ((BaseUnityPlugin)this).Config.Bind<string>("Phase2", "Transformacion_RayoPrefab", "lightningAOE", "Prefab del rayo que cae sobre el boss durante la transformacion (sin danar al boss).");
			_thunderStrikePrefab = ((BaseUnityPlugin)this).Config.Bind<string>("Thunder", "RayoPrefab", "lightningAOE", "Prefab del rayo que cae sobre jugadores.");
			_thunderCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Thunder", "Cooldown", 2f, new ConfigDescription("Segundos entre llamadas de trueno. Debe ser menor que (Phase2.Duration - Transformacion_Duracion).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 30f), Array.Empty<object>()));
			_thunderDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Thunder", "WarningDelay", 1.5f, new ConfigDescription("Segundos de aviso antes de que caiga el rayo.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 4f), Array.Empty<object>()));
			_thunderDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Thunder", "Damage", 55f, new ConfigDescription("Daño de relámpago por rayo.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 500f), Array.Empty<object>()));
			_thunderRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Thunder", "ImpactRadius", 3f, new ConfigDescription("Radio de daño al impactar.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>()));
			_lavaPrefabName = ((BaseUnityPlugin)this).Config.Bind<string>("LavaField", "Prefab", "LavaRock", "Nombre del prefab del geíser/roca de lava (p.ej. 'LavaRock').");
			_lavaMinRadius = ((BaseUnityPlugin)this).Config.Bind<float>("LavaField", "MinRadius", 4f, new ConfigDescription("Radio mínimo desde el boss.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 80f), Array.Empty<object>()));
			_lavaMaxRadius = ((BaseUnityPlugin)this).Config.Bind<float>("LavaField", "MaxRadius", 28f, new ConfigDescription("Radio máximo desde el boss.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(4f, 120f), Array.Empty<object>()));
			_lavaInterval = ((BaseUnityPlugin)this).Config.Bind<float>("LavaField", "Interval", 2f, new ConfigDescription("Segundos entre spawns.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
			_lavaBurst = ((BaseUnityPlugin)this).Config.Bind<int>("LavaField", "BurstCount", 6, new ConfigDescription("Cantidad por tick.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 6), Array.Empty<object>()));
			_stompTelegraphSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Stomp", "TelegraphSeconds", 1.5f, new ConfigDescription("Segundos de aviso antes del golpe del Stomp.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
			_stompTelegraphFx = ((BaseUnityPlugin)this).Config.Bind<string>("Stomp", "TelegraphFx", "fx_Abomination_attack2", "Nombre del FX para marcar el área del Stomp (se repite durante el aviso).");
			_biteBaseDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Neckzilla", "BiteBaseDamage", -1f, "Daño físico TOTAL del mordisco. >0 fija el total físico; <=0 desactiva y usa BiteDamageMultiplier.");
			_biteDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Neckzilla", "BiteDamageMultiplier", 2.3f, new ConfigDescription("Multiplicador para el daño físico del mordisco (melee).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			_lavaFireDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("LavaField", "FireDamageMultiplier", 1f, new ConfigDescription("Multiplica el daño de fuego recibido cerca de nuestros LavaRock (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
			_cfgDrop1 = ((BaseUnityPlugin)this).Config.Bind<string>("Loot", "Drop1", "TrophyNeck, 1, 1, 1.0", "Formato: NombrePrefab, cantMin, cantMax, probabilidad (0.0-1.0). Vacío = desactivado.");
			_cfgDrop2 = ((BaseUnityPlugin)this).Config.Bind<string>("Loot", "Drop2", "Coins, 100, 200, 1.0", "Formato: NombrePrefab, cantMin, cantMax, probabilidad (0.0-1.0). Vacío = desactivado.");
			_cfgDrop3 = ((BaseUnityPlugin)this).Config.Bind<string>("Loot", "Drop3", "NeckTail, 5, 10, 1.0", "Formato: NombrePrefab, cantMin, cantMax, probabilidad (0.0-1.0). Vacío = desactivado.");
			_cfgDrop4 = ((BaseUnityPlugin)this).Config.Bind<string>("Loot", "Drop4", "", "Formato: NombrePrefab, cantMin, cantMax, probabilidad (0.0-1.0). Vacío = desactivado.");
			_cfgDrop5 = ((BaseUnityPlugin)this).Config.Bind<string>("Loot", "Drop5", "", "Formato: NombrePrefab, cantMin, cantMax, probabilidad (0.0-1.0). Vacío = desactivado.");
			_cfgRoarFile = ((BaseUnityPlugin)this).Config.Bind<string>("Audio", "RoarFile", "neckzilla_roar.ogg", "Nombre del archivo de rugido en la carpeta del plugin (ogg/wav/mp3). Dejar vacío para deshabilitar.");
			_cfgMusicFile = ((BaseUnityPlugin)this).Config.Bind<string>("Audio", "MusicFile", "neckzilla_music.ogg", "Nombre del archivo de música en la carpeta del plugin (ogg/wav/mp3). Dejar vacío para deshabilitar.");
			((MonoBehaviour)this).StartCoroutine(LoadAudioFiles());
			_lavaPrefabName.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_lavaMinRadius.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_lavaMaxRadius.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_lavaInterval.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_lavaBurst.SettingChanged += delegate
			{
				UpdateStatics();
			};
			UpdateStatics();
			_stompCooldown.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_stompRange.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_stompDamage.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_stompPush.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_stompFxSteps.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_bombCooldown.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_bombMinRange.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_bombMaxRange.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_bombSpeed.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_bombImpactFire.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_bombImpactBlunt.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_bombAoeRadius.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_phase2ThresholdPct.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_phase2Duration.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_phase2AuraRadius.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_phase2AuraTick.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_phase2AuraDamage.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_phase2PlayerStaggerEvery.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_phase2BossLightningAt.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_phase2LeviathanDur.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_phase2BoltPrefab.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_thunderStrikePrefab.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_stompTelegraphSeconds.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_stompTelegraphFx.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_biteBaseDamage.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_biteDamageMultiplier.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_lavaFireDamageMultiplier.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_thunderCooldown.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_thunderDelay.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_thunderDamage.SettingChanged += delegate
			{
				UpdateStatics();
			};
			_thunderRadius.SettingChanged += delegate
			{
				UpdateStatics();
			};
			PrefabManager.OnVanillaPrefabsAvailable += CreateNeckzillaPrefab;
			object obj = <>c.<>9__93_36;
			if (obj == null)
			{
				ConsoleEvent val = delegate
				{
					//IL_0050: Unknown result type (might be due to invalid IL or missing references)
					//IL_005b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0065: Unknown result type (might be due to invalid IL or missing references)
					//IL_006a: Unknown result type (might be due to invalid IL or missing references)
					//IL_006f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0089: Unknown result type (might be due to invalid IL or missing references)
					//IL_008e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0090: Unknown result type (might be due to invalid IL or missing references)
					//IL_0091: Unknown result type (might be due to invalid IL or missing references)
					GameObject prefab = PrefabManager.Instance.GetPrefab("Boss_Neckzilla");
					if (!Object.op_Implicit((Object)(object)prefab))
					{
						Log.LogError((object)"Prefab no disponible aún.");
					}
					else
					{
						Player localPlayer = Player.m_localPlayer;
						if (Object.op_Implicit((Object)(object)localPlayer))
						{
							Vector3 val2 = ((Component)localPlayer).transform.position + ((Component)localPlayer).transform.forward * 5f;
							Quaternion val3 = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f);
							Object.Instantiate<GameObject>(prefab, val2, val3);
						}
					}
				};
				<>c.<>9__93_36 = val;
				obj = (object)val;
			}
			new ConsoleCommand("spawn_neckzilla", "Invoca a Neckzilla frente a ti.", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
		}

		private void UpdateStatics()
		{
			ST_COOLDOWN = _stompCooldown.Value;
			ST_RANGE = _stompRange.Value;
			ST_DAMAGE = _stompDamage.Value;
			ST_PUSH = _stompPush.Value;
			ST_FXSTEPS = Mathf.Max(1, _stompFxSteps.Value);
			ST_FXNAME = ((_stompTelegraphFx == null || string.IsNullOrWhiteSpace(_stompTelegraphFx.Value)) ? "fx_Abomination_attack2" : _stompTelegraphFx.Value);
			P2_THRESHOLD_PCT = Mathf.Clamp01(_phase2ThresholdPct.Value);
			P2_DURATION = _phase2Duration.Value;
			P2_AURA_RADIUS = _phase2AuraRadius.Value;
			P2_AURA_TICK = _phase2AuraTick.Value;
			P2_AURA_DAMAGE = _phase2AuraDamage.Value;
			P2_STAGGER_EVERY = _phase2PlayerStaggerEvery.Value;
			P2_BOSS_LIGHTNING_AT = Mathf.Max(1f, _phase2BossLightningAt.Value);
			P2_LEVIATHAN_DUR = Mathf.Max(5f, _phase2LeviathanDur.Value);
			P2_BOLT_PREFAB = (string.IsNullOrWhiteSpace(_phase2BoltPrefab.Value) ? "lightningAOE" : _phase2BoltPrefab.Value.Trim());
			THU_STRIKE_PREFAB = (string.IsNullOrWhiteSpace(_thunderStrikePrefab.Value) ? "lightningAOE" : _thunderStrikePrefab.Value.Trim());
			BMB_CD = _bombCooldown.Value;
			BMB_MIN = _bombMinRange.Value;
			BMB_MAX = _bombMaxRange.Value;
			BMB_SPEED = _bombSpeed.Value;
			BMB_FIRE = _bombImpactFire.Value;
			BMB_BLUNT = _bombImpactBlunt.Value;
			BMB_AOE = _bombAoeRadius.Value;
			LAVA_PREFAB = _lavaPrefabName.Value;
			LAVA_RMIN = _lavaMinRadius.Value;
			LAVA_RMAX = Mathf.Max(LAVA_RMIN + 1f, _lavaMaxRadius.Value);
			LAVA_INTERVAL = Mathf.Max(0.05f, _lavaInterval.Value);
			LAVA_BURST = Mathf.Max(1, _lavaBurst.Value);
			ST_TELEGRAPH = Mathf.Max(0f, _stompTelegraphSeconds.Value);
			ST_TELE_FX = _stompTelegraphFx.Value;
			BITE_BASE = _biteBaseDamage.Value;
			BITE_MULT = _biteDamageMultiplier.Value;
			LAVA_FIRE_MULT = Mathf.Max(0f, _lavaFireDamageMultiplier.Value);
			THU_COOLDOWN = Mathf.Max(1f, _thunderCooldown.Value);
			THU_DELAY = Mathf.Max(0.1f, _thunderDelay.Value);
			THU_DAMAGE = Mathf.Max(0f, _thunderDamage.Value);
			THU_RADIUS = Mathf.Max(0.5f, _thunderRadius.Value);
		}

		private IEnumerator LoadAudioFiles()
		{
			string pluginDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			if (!string.IsNullOrWhiteSpace(_cfgRoarFile.Value))
			{
				string path2 = Path.Combine(pluginDir, _cfgRoarFile.Value.Trim());
				yield return LoadClip(path2, delegate(AudioClip c)
				{
					RoarClip = c;
				}, "rugido");
			}
			if (!string.IsNullOrWhiteSpace(_cfgMusicFile.Value))
			{
				string path = Path.Combine(pluginDir, _cfgMusicFile.Value.Trim());
				yield return LoadClip(path, delegate(AudioClip c)
				{
					MusicClip = c;
				}, "música");
			}
		}

		private static IEnumerator LoadClip(string path, Action<AudioClip> onLoaded, string label)
		{
			if (!File.Exists(path))
			{
				Log.LogWarning((object)("[Audio] Archivo de " + label + " no encontrado: " + path));
				yield break;
			}
			string ext = Path.GetExtension(path).ToLowerInvariant();
			AudioType audioType = (AudioType)14;
			if (ext == ".wav")
			{
				audioType = (AudioType)20;
			}
			else if (ext == ".mp3")
			{
				audioType = (AudioType)13;
			}
			UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip("file:///" + path.Replace('\\', '/'), audioType);
			try
			{
				yield return req.SendWebRequest();
				if ((int)req.result != 1)
				{
					Log.LogError((object)("[Audio] Error cargando " + label + ": " + req.error));
					yield break;
				}
				AudioClip clip = DownloadHandlerAudioClip.GetContent(req);
				if ((Object)(object)clip != (Object)null)
				{
					((Object)clip).name = "Neckzilla_" + label;
					onLoaded(clip);
					Log.LogInfo((object)$"[Audio] '{label}' cargado: {clip.length:F1}s");
				}
			}
			finally
			{
				((IDisposable)req)?.Dispose();
			}
		}

		private static AudioMixerGroup GetSFXMixerGroup()
		{
			if ((Object)(object)_sfxMixerGroup != (Object)null)
			{
				return _sfxMixerGroup;
			}
			string[] array = new string[3] { "sfx_hit", "sfx_swing_axe", "sfx_arrow_hit" };
			foreach (string text in array)
			{
				ZNetScene instance = ZNetScene.instance;
				GameObject val = ((instance != null) ? instance.GetPrefab(text) : null);
				if (!((Object)(object)val == (Object)null))
				{
					AudioSource componentInChildren = val.GetComponentInChildren<AudioSource>(true);
					if ((Object)(object)((componentInChildren != null) ? componentInChildren.outputAudioMixerGroup : null) != (Object)null)
					{
						_sfxMixerGroup = componentInChildren.outputAudioMixerGroup;
						break;
					}
				}
			}
			return _sfxMixerGroup;
		}

		internal static void PlayRoar(Vector3 pos)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)RoarClip == (Object)null))
			{
				GameObject val = new GameObject("NeckzillaRoarSFX");
				val.transform.position = pos;
				AudioSource val2 = val.AddComponent<AudioSource>();
				val2.clip = RoarClip;
				val2.spatialBlend = 1f;
				val2.minDistance = 15f;
				val2.maxDistance = 200f;
				val2.rolloffMode = (AudioRolloffMode)0;
				val2.volume = 1f;
				val2.outputAudioMixerGroup = GetSFXMixerGroup();
				val2.Play();
				Object.Destroy((Object)(object)val, RoarClip.length + 0.5f);
			}
		}

		internal static void StartBossMusic()
		{
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			if ((Object)(object)MusicClip == (Object)null || (Object)(object)_bossMusic != (Object)null)
			{
				return;
			}
			_mutedVanillaSources.Clear();
			if ((Object)(object)MusicMan.instance != (Object)null)
			{
				AudioSource[] componentsInChildren = ((Component)MusicMan.instance).GetComponentsInChildren<AudioSource>(true);
				foreach (AudioSource val in componentsInChildren)
				{
					if ((Object)(object)val != (Object)null && val.volume > 0f)
					{
						val.volume = 0f;
						_mutedVanillaSources.Add(val);
					}
				}
			}
			BossMusicActive = true;
			GameObject val2 = new GameObject("NeckzillaBossMusic");
			Object.DontDestroyOnLoad((Object)(object)val2);
			AudioSource val3 = val2.AddComponent<AudioSource>();
			val3.clip = MusicClip;
			val3.loop = true;
			val3.spatialBlend = 0f;
			val3.volume = 0.5f;
			val3.Play();
			_bossMusic = val3;
			Log.LogInfo((object)"[Audio] Música de boss iniciada, vanilla silenciada.");
		}

		internal static void StopBossMusic()
		{
			if ((Object)(object)_bossMusic == (Object)null)
			{
				return;
			}
			Object.Destroy((Object)(object)((Component)_bossMusic).gameObject);
			_bossMusic = null;
			BossMusicActive = false;
			foreach (AudioSource mutedVanillaSource in _mutedVanillaSources)
			{
				if ((Object)(object)mutedVanillaSource != (Object)null)
				{
					mutedVanillaSource.volume = 1f;
				}
			}
			_mutedVanillaSources.Clear();
			Log.LogInfo((object)"[Audio] Música de boss detenida, vanilla restaurada.");
		}

		private static bool MusicManBlockPrefix()
		{
			return !BossMusicActive;
		}

		private void ApplyMusicManPatches()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			HarmonyMethod val = new HarmonyMethod(typeof(MainPlugin).GetMethod("MusicManBlockPrefix", BindingFlags.Static | BindingFlags.NonPublic));
			string[] array = new string[4] { "StartMusic", "StartRandomEventMusic", "UpdateMusic", "QueueMusic" };
			foreach (string text in array)
			{
				try
				{
					MethodInfo method = typeof(MusicMan).GetMethod(text, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (method != null)
					{
						_harmony.Patch((MethodBase)method, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
						Log.LogInfo((object)("[Audio] Parcheado MusicMan." + text));
					}
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)("[Audio] No se pudo parchar MusicMan." + text + ": " + ex.Message));
				}
			}
		}

		private void ApplyLootDrops(GameObject clone)
		{
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: 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_018c: 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_01a8: 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_01bb: Expected O, but got Unknown
			CharacterDrop val = clone.GetComponent<CharacterDrop>() ?? clone.AddComponent<CharacterDrop>();
			val.m_drops.Clear();
			ConfigEntry<string>[] array = new ConfigEntry<string>[5] { _cfgDrop1, _cfgDrop2, _cfgDrop3, _cfgDrop4, _cfgDrop5 };
			foreach (ConfigEntry<string> val2 in array)
			{
				if (val2 == null || string.IsNullOrWhiteSpace(val2.Value))
				{
					continue;
				}
				string[] array2 = val2.Value.Split(new char[1] { ',' });
				if (array2.Length < 4)
				{
					continue;
				}
				string text = array2[0].Trim();
				if (!string.IsNullOrEmpty(text) && int.TryParse(array2[1].Trim(), out var result) && int.TryParse(array2[2].Trim(), out var result2) && float.TryParse(array2[3].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result3))
				{
					PrefabManager instance = PrefabManager.Instance;
					GameObject val3 = ((instance != null) ? instance.GetPrefab(text) : null);
					if ((Object)(object)val3 == (Object)null)
					{
						Log.LogWarning((object)("[Loot] Prefab '" + text + "' no encontrado."));
						continue;
					}
					val.m_drops.Add(new Drop
					{
						m_prefab = val3,
						m_amountMin = Mathf.Max(0, result),
						m_amountMax = Mathf.Max(result, result2),
						m_chance = Mathf.Clamp01(result3),
						m_onePerPlayer = false,
						m_levelMultiplier = false
					});
					Log.LogInfo((object)$"[Loot] Drop: {text} x{result}-{result2} ({result3 * 100f:F0}%)");
				}
			}
		}

		private void OnDestroy()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= CreateNeckzillaPrefab;
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void CreateNeckzillaPrefab()
		{
			//IL_00e6: 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_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)PrefabManager.Instance.GetPrefab("Boss_Neckzilla")))
			{
				return;
			}
			GameObject prefab = PrefabManager.Instance.GetPrefab("Neck");
			if (!Object.op_Implicit((Object)(object)prefab))
			{
				Log.LogError((object)"No se encontró el prefab 'Neck'.");
				return;
			}
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("Boss_Neckzilla", prefab);
			Character component = val.GetComponent<Character>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.m_name = "Neckzilla";
				component.m_boss = true;
				component.m_health = _cfgHealth.Value;
				MakeFireImmune(component);
				val.AddComponent<KeepFireImmunity>();
				TrySetField<Character, bool>(component, "m_fleeIfHurt", value: false);
				TrySetField<Character, float>(component, "m_staggerDamageFactor", 0f);
			}
			float num = Mathf.Max(1f, _cfgScale.Value);
			val.transform.localScale = Vector3.one * num;
			BaseAI component2 = val.GetComponent<BaseAI>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				float factor = Mathf.Clamp(num, 1f, 4f);
				TryScaleFloatField(component2, "m_viewRange", factor);
				TryScaleFloatField(component2, "m_hearRange", factor);
				TryScaleFloatField(component2, "m_noiseRange", factor);
				TryMaxFloatField(component2, "m_interceptTimeMax", 8f);
				TrySetField<BaseAI, bool>(component2, "m_afraidOfFire", value: false);
				TrySetField<BaseAI, bool>(component2, "m_avoidFire", value: false);
				TrySetField<BaseAI, bool>(component2, "m_fleeIfHurt", value: false);
				TrySetField<BaseAI, bool>(component2, "m_backoffOnLowHP", value: false);
				TrySetField<BaseAI, bool>(component2, "m_avoidPlayer", value: false);
				TrySetField<BaseAI, bool>(component2, "m_avoidWater", value: false);
				TrySetField<BaseAI, float>(component2, "m_afraidOfFireRange", 0f);
				TrySetField<BaseAI, float>(component2, "m_avoidFireDistance", 0f);
				TrySetField<BaseAI, float>(component2, "m_avoidPlayerDistance", 0f);
				TrySetField<BaseAI, float>(component2, "m_avoidWaterDistance", 0f);
				TryScaleFloatField(component, "m_walkSpeed", 1.5f);
				TryScaleFloatField(component, "m_runSpeed", 1.5f);
				TryScaleFloatField(component, "m_acceleration", 1.1f);
				TryScaleFloatField(component, "m_turnSpeed", 1.15f);
				ForceNoFleeFlags(component2);
				val.AddComponent<NoFleeRefresher>();
			}
			val.AddComponent<NeckzillaStomp>();
			val.AddComponent<NeckzillaBombardment>();
			val.AddComponent<NeckzillaPhase2>();
			val.AddComponent<NeckzillaLavaField>();
			val.AddComponent<NeckzillaThunder>();
			ApplyLootDrops(val);
			((Object)val).name = "Boss_Neckzilla";
			PrefabManager.Instance.AddPrefab(new CustomPrefab(val, true));
			Log.LogInfo((object)"Boss_Neckzilla creado y registrado correctamente.");
		}

		internal static bool TrySetField<TObj, TValue>(TObj obj, string fieldName, TValue value)
		{
			FieldInfo field = obj.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field == null)
			{
				return false;
			}
			try
			{
				object obj2 = value;
				if (obj2 != null && field.FieldType != obj2.GetType())
				{
					obj2 = Convert.ChangeType(obj2, field.FieldType);
				}
				field.SetValue(obj, obj2);
				return true;
			}
			catch
			{
				return false;
			}
		}

		private static void TryScaleFloatField(object obj, string fieldName, float factor)
		{
			FieldInfo field = obj.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field == null || field.FieldType != typeof(float))
			{
				return;
			}
			try
			{
				float num = (float)field.GetValue(obj);
				field.SetValue(obj, num * factor);
			}
			catch
			{
			}
		}

		private static void TryMaxFloatField(object obj, string fieldName, float minValue)
		{
			FieldInfo field = obj.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field == null || field.FieldType != typeof(float))
			{
				return;
			}
			try
			{
				float num = (float)field.GetValue(obj);
				if (num < minValue)
				{
					field.SetValue(obj, minValue);
				}
			}
			catch
			{
			}
		}

		internal static void ForceNoFleeFlags(object ai)
		{
			if (ai == null)
			{
				return;
			}
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			FieldInfo[] fields = ai.GetType().GetFields(bindingAttr);
			foreach (FieldInfo fieldInfo in fields)
			{
				string text = fieldInfo.Name.ToLowerInvariant();
				if (fieldInfo.FieldType == typeof(bool) && (text.Contains("flee") || text.Contains("afraid") || text.Contains("avoid") || text.Contains("backoff")))
				{
					try
					{
						fieldInfo.SetValue(ai, false);
					}
					catch
					{
					}
				}
				if (fieldInfo.FieldType == typeof(float) && (text.Contains("range") || text.Contains("distance")) && (text.Contains("fire") || text.Contains("flee") || text.Contains("avoid") || text.Contains("afraid")))
				{
					try
					{
						fieldInfo.SetValue(ai, 0f);
					}
					catch
					{
					}
				}
			}
		}

		private static Color ParseHtmlColor(string html, Color fallback)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			Color result = default(Color);
			if (!string.IsNullOrWhiteSpace(html) && ColorUtility.TryParseHtmlString(html.Trim(), ref result))
			{
				return result;
			}
			return fallback;
		}

		internal static void ApplyLiliesEmission(GameObject target)
		{
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Expected O, but got Unknown
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_05af: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b6: Expected O, but got Unknown
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0602: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: 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_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_085a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0851: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Expected O, but got Unknown
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0522: Unknown result type (might be due to invalid IL or missing references)
			//IL_0861: Expected O, but got Unknown
			//IL_07cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d2: Expected O, but got Unknown
			//IL_0745: Unknown result type (might be due to invalid IL or missing references)
			//IL_074c: Expected O, but got Unknown
			//IL_087a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0765: Unknown result type (might be due to invalid IL or missing references)
			//IL_089a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0786: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b4: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_charredMatCache == (Object)null)
			{
				string[] array = new string[2] { "Charred_Melee_Dyrnwyn", "CharredMeleeDyrnwyn" };
				foreach (string text in array)
				{
					GameObject val = null;
					if (PrefabManager.Instance != null)
					{
						val = PrefabManager.Instance.GetPrefab(text);
					}
					if ((Object)(object)val == (Object)null && (Object)(object)ZNetScene.instance != (Object)null)
					{
						val = ZNetScene.instance.GetPrefab(text);
					}
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true);
					foreach (Renderer val2 in componentsInChildren)
					{
						if (string.Equals(((Object)((Component)val2).gameObject).name, "Body", StringComparison.OrdinalIgnoreCase) && val2.sharedMaterials.Length != 0 && (Object)(object)val2.sharedMaterials[0] != (Object)null)
						{
							_charredMatCache = val2.sharedMaterials[0];
							break;
						}
					}
					if ((Object)(object)_charredMatCache != (Object)null)
					{
						break;
					}
					if ((Object)(object)_charredMatCache == (Object)null)
					{
						Renderer componentInChildren = val.GetComponentInChildren<Renderer>(true);
						if ((Object)(object)componentInChildren != (Object)null && componentInChildren.sharedMaterials.Length != 0 && (Object)(object)componentInChildren.sharedMaterials[0] != (Object)null)
						{
							_charredMatCache = componentInChildren.sharedMaterials[0];
							Log.LogWarning((object)("[Phase2] Charred: 'Body' no encontrado, usando primer renderer: " + ((Object)((Component)componentInChildren).gameObject).name));
						}
					}
					if ((Object)(object)_charredMatCache != (Object)null)
					{
						break;
					}
				}
			}
			Material charredMatCache = _charredMatCache;
			if ((Object)(object)target.transform.Find("NeckzillaLiliesLight") == (Object)null)
			{
				GameObject val3 = new GameObject("NeckzillaLiliesLight");
				val3.transform.SetParent(target.transform, false);
				val3.transform.localPosition = new Vector3(0f, 0.6f, -0.3f);
				Light val4 = val3.AddComponent<Light>();
				val4.type = (LightType)2;
				val4.color = new Color(0.15f, 0.6f, 1f);
				val4.intensity = 3f;
				val4.range = 2.5f;
				val4.shadows = (LightShadows)0;
			}
			SkinnedMeshRenderer componentInChildren2 = target.GetComponentInChildren<SkinnedMeshRenderer>(true);
			if ((Object)(object)componentInChildren2 != (Object)null && componentInChildren2.bones != null)
			{
				List<Transform> list = new List<Transform>();
				Transform[] bones = componentInChildren2.bones;
				foreach (Transform val5 in bones)
				{
					if (!((Object)(object)val5 == (Object)null))
					{
						string name = ((Object)val5).name;
						if (name.IndexOf("eye", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("ojo", StringComparison.OrdinalIgnoreCase) >= 0)
						{
							list.Add(val5);
						}
					}
				}
				if (list.Count == 0)
				{
					Transform val6 = null;
					Transform[] bones2 = componentInChildren2.bones;
					foreach (Transform val7 in bones2)
					{
						if (!((Object)(object)val7 == (Object)null) && string.Equals(((Object)val7).name, "Head", StringComparison.OrdinalIgnoreCase))
						{
							val6 = val7;
							break;
						}
					}
					if ((Object)(object)val6 == (Object)null)
					{
						Transform[] bones3 = componentInChildren2.bones;
						foreach (Transform val8 in bones3)
						{
							if (!((Object)(object)val8 == (Object)null))
							{
								string name2 = ((Object)val8).name;
								if (name2.IndexOf("head", StringComparison.OrdinalIgnoreCase) >= 0 || name2.IndexOf("cabeza", StringComparison.OrdinalIgnoreCase) >= 0)
								{
									val6 = val8;
									break;
								}
							}
						}
					}
					if ((Object)(object)val6 != (Object)null)
					{
						Vector3[] array2 = (Vector3[])(object)new Vector3[4]
						{
							new Vector3(-0.12f, 0.04f, 0.18f),
							new Vector3(0.12f, 0.04f, 0.18f),
							new Vector3(-0.12f, -0.04f, 0.14f),
							new Vector3(0.12f, -0.04f, 0.14f)
						};
						for (int n = 0; n < array2.Length; n++)
						{
							string text2 = "NeckzillaEyeLight_" + n;
							if (!((Object)(object)val6.Find(text2) != (Object)null))
							{
								GameObject val9 = new GameObject(text2);
								val9.transform.SetParent(val6, false);
								val9.transform.localPosition = array2[n];
								Light val10 = val9.AddComponent<Light>();
								val10.type = (LightType)2;
								val10.color = new Color(0f, 0.85f, 1f);
								val10.intensity = 6f;
								val10.range = 0.8f;
								val10.shadows = (LightShadows)0;
							}
						}
					}
				}
				else
				{
					for (int num = 0; num < list.Count; num++)
					{
						string text3 = "NeckzillaEyeLight_" + num;
						if (!((Object)(object)list[num].Find(text3) != (Object)null))
						{
							GameObject val11 = new GameObject(text3);
							val11.transform.SetParent(list[num], false);
							val11.transform.localPosition = Vector3.zero;
							Light val12 = val11.AddComponent<Light>();
							val12.type = (LightType)2;
							val12.color = new Color(0f, 0.85f, 1f);
							val12.intensity = 6f;
							val12.range = 0.8f;
							val12.shadows = (LightShadows)0;
						}
					}
				}
			}
			Color val13 = default(Color);
			((Color)(ref val13))..ctor(0f, 0.7f, 3.5f, 1f);
			Renderer[] componentsInChildren2 = target.GetComponentsInChildren<Renderer>(true);
			Color val15 = default(Color);
			foreach (Renderer val14 in componentsInChildren2)
			{
				if ((Object)(object)val14 == (Object)null)
				{
					continue;
				}
				string name3 = ((Object)((Component)val14).gameObject).name;
				if (string.Equals(name3, "Body", StringComparison.OrdinalIgnoreCase) && (Object)(object)charredMatCache != (Object)null)
				{
					val14.SetPropertyBlock((MaterialPropertyBlock)null);
					Material[] sharedMaterials = val14.sharedMaterials;
					Material[] array3 = (Material[])(object)new Material[sharedMaterials.Length];
					((Color)(ref val15))..ctor(0f, 0.85f, 3.5f, 1f);
					for (int num3 = 0; num3 < sharedMaterials.Length; num3++)
					{
						if ((Object)(object)sharedMaterials[num3] != (Object)null && ((Object)sharedMaterials[num3]).name.IndexOf("eye", StringComparison.OrdinalIgnoreCase) >= 0)
						{
							Material val16 = new Material(sharedMaterials[num3]);
							if (val16.HasProperty("_Color"))
							{
								val16.SetColor("_Color", val15);
							}
							if (val16.HasProperty("_BaseColor"))
							{
								val16.SetColor("_BaseColor", val15);
							}
							val16.EnableKeyword("_EMISSION");
							if (val16.HasProperty("_EmissionColor"))
							{
								val16.SetColor("_EmissionColor", val15);
							}
							array3[num3] = val16;
						}
						else
						{
							array3[num3] = new Material(charredMatCache);
						}
					}
					val14.materials = array3;
				}
				else
				{
					if (!string.Equals(name3, "Lillies", StringComparison.OrdinalIgnoreCase))
					{
						continue;
					}
					val14.SetPropertyBlock((MaterialPropertyBlock)null);
					Material[] array4 = (Material[])(object)new Material[val14.sharedMaterials.Length];
					for (int num4 = 0; num4 < array4.Length; num4++)
					{
						Material val17 = val14.sharedMaterials[num4];
						Material val18 = (((Object)(object)val17 != (Object)null) ? new Material(val17) : new Material(Shader.Find("Standard")));
						if (val18.HasProperty("_Color"))
						{
							val18.SetColor("_Color", val13);
						}
						if (val18.HasProperty("_BaseColor"))
						{
							val18.SetColor("_BaseColor", val13);
						}
						array4[num4] = val18;
					}
					val14.materials = array4;
				}
			}
		}

		internal static void ApplySerpentMaterials(GameObject target, GameObject _source)
		{
			ApplyLiliesEmission(target);
		}

		private static void ApplyTintToPrefabMaterials(GameObject root, Color tint, float emission)
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (!Object.op_Implicit((Object)(object)val))
				{
					continue;
				}
				Material[] sharedMaterials = val.sharedMaterials;
				if (sharedMaterials == null || sharedMaterials.Length == 0)
				{
					continue;
				}
				Material[] array = (Material[])(object)new Material[sharedMaterials.Length];
				for (int j = 0; j < sharedMaterials.Length; j++)
				{
					Material val2 = sharedMaterials[j];
					if (!Object.op_Implicit((Object)(object)val2))
					{
						array[j] = null;
						continue;
					}
					Material val3 = new Material(val2);
					TrySetColorProps(val3, tint, emission);
					array[j] = val3;
				}
				val.sharedMaterials = array;
			}
		}

		private static void TrySetColorProps(Material m, Color tint, float emission)
		{
			//IL_0016: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_00a6: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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)
			if (m.HasProperty("_Color"))
			{
				m.SetColor("_Color", tint);
			}
			if (m.HasProperty("_BaseColor"))
			{
				m.SetColor("_BaseColor", tint);
			}
			if (m.HasProperty("_TintColor"))
			{
				m.SetColor("_TintColor", tint);
			}
			if (m.HasProperty("_MainColor"))
			{
				m.SetColor("_MainColor", tint);
			}
			if (emission > 0f && m.HasProperty("_EmissionColor"))
			{
				m.EnableKeyword("_EMISSION");
				Color val = new Color(tint.r, tint.g, tint.b, 1f) * Mathf.Clamp(emission, 0f, 2f);
				m.SetColor("_EmissionColor", val);
			}
			else if (m.IsKeywordEnabled("_EMISSION") && emission <= 0f)
			{
				m.DisableKeyword("_EMISSION");
			}
		}

		internal static void SafeStagger(Character target, Vector3 fromPos)
		{
			//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_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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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)
			if (!Object.op_Implicit((Object)(object)target))
			{
				return;
			}
			try
			{
				MethodInfo method = ((object)target).GetType().GetMethod("Stagger", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(Vector3) }, null);
				if (method != null)
				{
					Vector3 val = ((Component)target).transform.position - fromPos;
					if (((Vector3)(ref val)).sqrMagnitude < 0.001f)
					{
						val = Vector3.forward;
					}
					method.Invoke(target, new object[1] { ((Vector3)(ref val)).normalized });
					return;
				}
			}
			catch
			{
			}
			try
			{
				MethodInfo method2 = ((object)target).GetType().GetMethod("Stagger", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
				if (method2 != null)
				{
					method2.Invoke(target, null);
				}
			}
			catch
			{
			}
		}

		internal static void MakeFireImmune(Character ch)
		{
			//IL_003f: 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_0049: 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)
			if (!Object.op_Implicit((Object)(object)ch))
			{
				return;
			}
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			FieldInfo field = typeof(Character).GetField("m_damageModifiers", bindingAttr);
			if (field == null)
			{
				return;
			}
			try
			{
				DamageModifiers val = (DamageModifiers)field.GetValue(ch);
				val.m_fire = (DamageModifier)3;
				field.SetValue(ch, val);
			}
			catch
			{
			}
		}
	}
	public class NeckzillaStomp : MonoBehaviour
	{
		private Character _self;

		private ZNetView _nview;

		[SerializeField]
		private float _cd;

		[SerializeField]
		private float _range;

		[SerializeField]
		private float _damage;

		[SerializeField]
		private float _push;

		[SerializeField]
		private int _fxSteps = 6;

		[SerializeField]
		private string _fxName = "fx_Abomination_attack2";

		private GameObject _fxPrefab;

		private float _cooldownUntil;

		private float _telegraphUntil;

		private bool _telegraphing;

		private bool _didDamage;

		private GameObject _circleGO;

		private LineRenderer _circleLR;

		private static readonly List<Character> _scratch = new List<Character>();

		private static readonly int SOLID_MASK = LayerMask.GetMask(new string[5] { "Default", "piece", "terrain", "static_solid", "Default_small" });

		private void Awake()
		{
			if (_cd <= 0f)
			{
				_cd = Mathf.Max(1f, MainPlugin.ST_COOLDOWN);
			}
			if (_range <= 0f)
			{
				_range = Mathf.Max(2f, MainPlugin.ST_RANGE);
			}
			if (_damage <= 0f)
			{
				_damage = Mathf.Max(1f, MainPlugin.ST_DAMAGE);
			}
			if (_push <= 0f)
			{
				_push = Mathf.Max(0f, MainPlugin.ST_PUSH);
			}
			if (_fxSteps <= 0)
			{
				_fxSteps = Mathf.Max(1, MainPlugin.ST_FXSTEPS);
			}
			if (string.IsNullOrWhiteSpace(_fxName))
			{
				_fxName = MainPlugin.ST_FXNAME;
			}
		}

		private void Start()
		{
			_self = ((Component)this).GetComponent<Character>();
			_nview = ((Component)this).GetComponent<ZNetView>();
			PrefabManager instance = PrefabManager.Instance;
			if (instance != null)
			{
				_fxPrefab = instance.GetPrefab(_fxName);
			}
			if ((Object)(object)_fxPrefab == (Object)null && (Object)(object)ZNetScene.instance != (Object)null)
			{
				_fxPrefab = ZNetScene.instance.GetPrefab(_fxName);
			}
			_cooldownUntil = Time.time + Random.Range(0f, _cd * 0.5f);
			EnsureCircle();
		}

		private void Update()
		{
			//IL_0084: 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_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_self))
			{
				return;
			}
			NeckzillaPhase2 component = ((Component)this).GetComponent<NeckzillaPhase2>();
			if (Object.op_Implicit((Object)(object)component) && (component.IsActive || component.IsFinalPhase))
			{
				StopTelegraph();
				_cooldownUntil = Time.time + 1f;
			}
			else if (_telegraphing)
			{
				if (!IsDedicatedServer())
				{
					UpdateCross(((Component)this).transform.position, _range);
				}
				if (!(Time.time >= _telegraphUntil))
				{
					return;
				}
				if (!_didDamage)
				{
					if (!IsDedicatedServer())
					{
						SpawnImpactFX(((Component)this).transform.position, _range);
					}
					if (IsOwnerOrServer())
					{
						ApplyAoEDamage();
					}
					_didDamage = true;
				}
				StopTelegraph();
				_cooldownUntil = Time.time + _cd;
			}
			else
			{
				if (Time.time < _cooldownUntil)
				{
					return;
				}
				Player val = FindTargetPlayer(_range + 0.5f, requireLoS: true);
				if (!Object.op_Implicit((Object)(object)val))
				{
					_cooldownUntil = Time.time + Mathf.Min(1f, _cd * 0.25f);
					return;
				}
				float num = Mathf.Max(0f, MainPlugin.ST_TELEGRAPH);
				if (num > 0f)
				{
					_telegraphing = true;
					_didDamage = false;
					_telegraphUntil = Time.time + num;
					EnsureCircle();
					if (Object.op_Implicit((Object)(object)_circleGO))
					{
						_circleGO.SetActive(true);
						UpdateCross(((Component)this).transform.position, _range);
					}
				}
				else
				{
					if (!IsDedicatedServer())
					{
						SpawnImpactFX(((Component)this).transform.position, _range);
					}
					if (IsOwnerOrServer())
					{
						ApplyAoEDamage();
					}
					_cooldownUntil = Time.time + _cd;
				}
			}
		}

		private bool IsInCross(Vector3 playerPos)
		{
			//IL_0001: 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_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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = playerPos - ((Component)this).transform.position;
			val.y = 0f;
			Vector3 forward = ((Component)this).transform.forward;
			forward.y = 0f;
			((Vector3)(ref forward)).Normalize();
			Vector3 right = ((Component)this).transform.right;
			right.y = 0f;
			((Vector3)(ref right)).Normalize();
			float num = Vector3.Dot(val, forward);
			float num2 = Vector3.Dot(val, right);
			float num3 = _range * 0.25f;
			bool flag = Mathf.Abs(num2) <= num3 && Mathf.Abs(num) <= _range;
			bool flag2 = Mathf.Abs(num) <= num3 && Mathf.Abs(num2) <= _range;
			return flag || flag2;
		}

		private void ApplyAoEDamage()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_00f7: 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_0107: 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)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: 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_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			_scratch.Clear();
			try
			{
				Character.GetCharactersInRange(((Component)this).transform.position, _range, _scratch);
			}
			catch
			{
				Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, _range, -1, (QueryTriggerInteraction)2);
				for (int i = 0; i < array.Length; i++)
				{
					Character componentInParent = ((Component)array[i]).GetComponentInParent<Character>();
					if (Object.op_Implicit((Object)(object)componentInParent) && !_scratch.Contains(componentInParent))
					{
						_scratch.Add(componentInParent);
					}
				}
			}
			int num = 0;
			for (int j = 0; j < _scratch.Count; j++)
			{
				Character obj2 = _scratch[j];
				Player val = (Player)(object)((obj2 is Player) ? obj2 : null);
				if (Object.op_Implicit((Object)(object)val) && !((Character)val).IsDead() && IsInCross(((Component)val).transform.position))
				{
					Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position;
					val2.y = 0f;
					float num2 = Mathf.Max(0.05f, ((Vector3)(ref val2)).magnitude);
					HitData val3 = new HitData
					{
						m_point = ((Character)val).GetCenterPoint(),
						m_dir = val2 / num2
					};
					val3.m_damage.m_blunt = _damage;
					val3.m_pushForce = _push;
					val3.m_blockable = true;
					try
					{
						val3.SetAttacker(_self);
					}
					catch
					{
					}
					((Character)val).Damage(val3);
					num++;
				}
			}
		}

		private void SpawnImpactFX(Vector3 center, float length)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_0096: 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_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_00b3: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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_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)
			if ((Object)(object)_fxPrefab == (Object)null)
			{
				return;
			}
			SpawnLocalFX(_fxPrefab, SnapToGround(center));
			Vector3 forward = ((Component)this).transform.forward;
			forward.y = 0f;
			((Vector3)(ref forward)).Normalize();
			Vector3 right = ((Component)this).transform.right;
			right.y = 0f;
			((Vector3)(ref right)).Normalize();
			int num = Mathf.Max(1, _fxSteps / 4);
			Vector3[] array = (Vector3[])(object)new Vector3[4]
			{
				forward,
				-forward,
				right,
				-right
			};
			foreach (Vector3 val in array)
			{
				for (int j = 1; j <= num; j++)
				{
					float num2 = (float)j / (float)num * length;
					SpawnLocalFX(_fxPrefab, SnapToGround(center + val * num2));
				}
			}
		}

		private static void SpawnLocalFX(GameObject prefab, Vector3 pos)
		{
			//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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			GameObject val = Object.Instantiate<GameObject>(prefab, pos, Quaternion.identity);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			Component[] componentsInChildren = val.GetComponentsInChildren<Component>(true);
			foreach (Component val2 in componentsInChildren)
			{
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				FieldInfo field = ((object)val2).GetType().GetField("m_damage", bindingAttr);
				if (field != null)
				{
					try
					{
						field.SetValue(val2, (object?)new HitData());
					}
					catch
					{
					}
				}
			}
			ZNetView component = val.GetComponent<ZNetView>();
			if ((Object)(object)component != (Object)null)
			{
				NeckzillaThunder.MakeLocalOnlyStatic(component);
			}
		}

		private void UpdateCross(Vector3 center, float length)
		{
			//IL_0029: 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_003d: 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_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_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_0088: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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_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_00ee: 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_0104: 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)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: 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_0133: 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_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: 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_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)
			//IL_0165: 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_0174: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_circleLR == (Object)null))
			{
				float num = length * 0.25f;
				Quaternion val = Quaternion.Euler(0f, ((Component)this).transform.eulerAngles.y, 0f);
				Vector3[] array = (Vector3[])(object)new Vector3[12]
				{
					new Vector3(0f - num, 0f, length),
					new Vector3(num, 0f, length),
					new Vector3(num, 0f, num),
					new Vector3(length, 0f, num),
					new Vector3(length, 0f, 0f - num),
					new Vector3(num, 0f, 0f - num),
					new Vector3(num, 0f, 0f - length),
					new Vector3(0f - num, 0f, 0f - length),
					new Vector3(0f - num, 0f, 0f - num),
					new Vector3(0f - length, 0f, 0f - num),
					new Vector3(0f - length, 0f, num),
					new Vector3(0f - num, 0f, num)
				};
				_circleLR.positionCount = 12;
				for (int i = 0; i < 12; i++)
				{
					Vector3 pos = center + val * array[i];
					pos = SnapToGround(pos) + Vector3.up * 0.03f;
					_circleLR.SetPosition(i, pos);
				}
			}
		}

		private void StopTelegraph()
		{
			_telegraphing = false;
			if (Object.op_Implicit((Object)(object)_circleGO))
			{
				_circleGO.SetActive(false);
			}
		}

		private void EnsureCircle()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Expected O, but got Unknown
			//IL_012e: 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_013d: 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)
			//IL_0162: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: 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_00e7: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			if (!IsDedicatedServer() && !((Object)(object)_circleGO != (Object)null))
			{
				_circleGO = new GameObject("Neckzilla_StompTelegraph");
				_circleGO.SetActive(false);
				_circleLR = _circleGO.AddComponent<LineRenderer>();
				_circleLR.useWorldSpace = true;
				_circleLR.loop = true;
				_circleLR.positionCount = 12;
				_circleLR.widthMultiplier = 0.08f;
				((Renderer)_circleLR).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)_circleLR).receiveShadows = false;
				Shader val = Shader.Find("Sprites/Default");
				if ((Object)(object)val == (Object)null)
				{
					val = Shader.Find("Unlit/Color");
				}
				if ((Object)(object)val != (Object)null)
				{
					((Renderer)_circleLR).material = new Material(val);
					((Renderer)_circleLR).material.color = Color.white;
				}
				_circleLR.widthMultiplier = 0.25f;
				Gradient val2 = new Gradient();
				val2.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
				{
					new GradientColorKey(new Color(1f, 0.95f, 0f), 0f),
					new GradientColorKey(new Color(1f, 0.1f, 0f), 1f)
				}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
				{
					new GradientAlphaKey(1f, 0f),
					new GradientAlphaKey(1f, 1f)
				});
				_circleLR.colorGradient = val2;
			}
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)_circleGO))
			{
				Object.Destroy((Object)(object)_circleGO);
			}
		}

		private static Vector3 SnapToGround(Vector3 pos)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_0088: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(pos + Vector3.up * 10f, Vector3.down);
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val, ref val2, 30f, LayerMask.GetMask(new string[6] { "Default", "piece", "terrain", "static_solid", "Default_small", "character" })))
			{
				pos.y = ((RaycastHit)(ref val2)).point.y + 0.05f;
			}
			return pos;
		}

		private bool IsOwnerOrServer()
		{
			return (Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsServer()) || (Object.op_Implicit((Object)(object)_nview) && _nview.IsValid() && _nview.IsOwner());
		}

		private static bool IsDedicatedServer()
		{
			return Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsDedicated();
		}

		private Player FindTargetPlayer(float r, bool requireLoS)
		{
			BaseAI component = ((Component)this).GetComponent<BaseAI>();
			if ((Object)(object)component != (Object)null)
			{
				Player val = TryGetAITargetPlayer(component);
				if (IsValidTarget(val, r, requireLoS))
				{
					return val;
				}
			}
			List<Player> allPlayers = Player.GetAllPlayers();
			for (int i = 0; i < allPlayers.Count; i++)
			{
				if (IsValidTarget(allPlayers[i], r, requireLoS))
				{
					return allPlayers[i];
				}
			}
			return null;
		}

		private Player TryGetAITargetPlayer(BaseAI ai)
		{
			string[] array = new string[4] { "m_targetCreature", "m_targetEnemy", "m_targetCharacter", "m_target" };
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			Type type = ((object)ai).GetType();
			for (int i = 0; i < array.Length; i++)
			{
				FieldInfo field = type.GetField(array[i], bindingAttr);
				if (field == null)
				{
					continue;
				}
				object value = field.GetValue(ai);
				Player val = (Player)((value is Player) ? value : null);
				if (val != null)
				{
					return val;
				}
				Character val2 = (Character)((value is Character) ? value : null);
				if (val2 != null)
				{
					Player val3 = (Player)(object)((val2 is Player) ? val2 : null);
					if (val3 != null)
					{
						return val3;
					}
				}
			}
			return null;
		}

		private bool IsValidTarget(Player p, float r, bool requireLoS)
		{
			//IL_0020: 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)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_0077: 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)
			if (!Object.op_Implicit((Object)(object)p) || ((Character)p).IsDead())
			{
				return false;
			}
			if (Vector3.Distance(((Component)this).transform.position, ((Component)p).transform.position) > r)
			{
				return false;
			}
			if (!requireLoS)
			{
				return true;
			}
			Vector3 val = ((Component)this).transform.position + Vector3.up * 0.5f;
			Vector3 centerPoint = ((Character)p).GetCenterPoint();
			return !Physics.Linecast(val, centerPoint, SOLID_MASK);
		}
	}
	public class NeckzillaPhase2 : MonoBehaviour
	{
		private Character _self;

		private BaseAI _ai;

		private ZNetView _nview;

		private Rigidbody _rb;

		private bool _triggeredOnce;

		private float _thresholdHealth;

		private float _healthSnapDelay = 2.5f;

		private bool _healthSnapped;

		private float _timeLeft;

		private float _seqTimer;

		private float _staggerTimer;

		private GameObject _fxLeviathanPrefab;

		private GameObject _fxLeviathanInst;

		private bool _bossLightningFired;

		private bool _stormTriggered;

		private bool _roarP2Fired;

		private bool _stormForced;

		private bool _moderForced;

		private GameObject _electricAuraRoot;

		private GameObject _lightningAuraRoot;

		private float _himminAflTimer;

		private float _liliesMatTimer;

		private Vector3 _lockPos;

		private RigidbodyConstraints _rbConstraintsBackup;

		private bool _rbHadConstraintsBackup;

		private Animator[] _anims;

		private bool[] _animRootMotionBackup;

		private float _deathRoarThreshold;

		private bool _deathRoarTriggered;

		private bool _deathRoarActive;

		private bool _finalWindupActive;

		private bool _beamRoarFired;

		private bool _finalRainActive;

		private float _finalWindupTimer;

		private const float FinalWindupDuration = 4f;

		private Vector3 _deathRoarLockPos;

		private string _deathRoarAnim;

		private Transform _roarSpine;

		private Transform _roarSpine1;

		private Transform _roarNeckBone;

		private Transform _roarHeadBone;

		private Transform _roarJawBone;

		private Quaternion _roarSpineInitRot;

		private Quaternion _roarSpine1InitRot;

		private Quaternion _roarNeckInitRot;

		private Quaternion _roarHeadInitRot;

		private Quaternion _roarJawInitRot;

		private Vector3 _roarOriginalScale;

		private Quaternion _deathRoarLockRot;

		private float _roarBoneLerpT;

		private float _finalLightningTimer;

		private const float FinalLightningInterval = 2.5f;

		private float _finalMeteorTimer;

		private const float FinalMeteorInterval = 5f;

		private GameObject _activeBeamGO;

		private GameObject _beamAudioGO;

		private GameObject _meteorPrefabCache;

		private GameObject _beamPrefabCache;

		private static readonly List<Character> _scratch = new List<Character>();

		public bool IsActive { get; private set; }

		public bool ThunderUnlocked { get; private set; }

		public bool IsFinalWindup => _finalWindupActive;

		public bool IsFinalPhase => _deathRoarActive;

		private void Start()
		{
			_self = ((Component)this).GetComponent<Character>();
			_ai = ((Component)this).GetComponent<BaseAI>();
			_nview = ((Component)this).GetComponent<ZNetView>();
			_rb = ((Component)this).GetComponent<Rigidbody>();
			_thresholdHealth = float.MaxValue;
			_fxLeviathanPrefab = ((PrefabManager.Instance != null) ? PrefabManager.Instance.GetPrefab("fx_leviathan_leave") : null);
			if ((Object)(object)_fxLeviathanPrefab == (Object)null && (Object)(object)ZNetScene.instance != (Object)null)
			{
				_fxLeviathanPrefab = ZNetScene.instance.GetPrefab("fx_leviathan_leave");
			}
			ZNetScene instance = ZNetScene.instance;
			_beamPrefabCache = ((instance != null) ? instance.GetPrefab("vfx_goblinking_beam_OLD") : null);
			ZNetScene instance2 = ZNetScene.instance;
			_meteorPrefabCache = ((instance2 != null) ? instance2.GetPrefab("projectile_ashlandmeteor") : null);
			_anims = ((Component)this).GetComponentsInChildren<Animator>(true);
			_animRootMotionBackup = new bool[_anims.Length];
			for (int i = 0; i < _anims.Length; i++)
			{
				_animRootMotionBackup[i] = (Object)(object)_anims[i] != (Object)null && _anims[i].applyRootMotion;
			}
		}

		private void Update()
		{
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: 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_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Invalid comparison between Unknown and I4
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Invalid comparison between Unknown and I4
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_self))
			{
				return;
			}
			if (IsActive && _bossLightningFired)
			{
				_liliesMatTimer -= Time.deltaTime;
				if (_liliesMatTimer <= 0f)
				{
					_liliesMatTimer = 0.5f;
					MainPlugin.ApplyLiliesEmission(((Component)this).gameObject);
				}
			}
			if (IsActive && _bossLightningFired)
			{
				_himminAflTimer -= Time.deltaTime;
				if (_himminAflTimer <= 0f)
				{
					_himminAflTimer = 3f;
					SpawnHimminAflOnce();
				}
			}
			if (!_healthSnapped)
			{
				_healthSnapDelay -= Time.deltaTime;
				if (_healthSnapDelay <= 0f)
				{
					float healthSafe = GetHealthSafe(_self);
					if (healthSafe > 1f)
					{
						_thresholdHealth = healthSafe * Mathf.Clamp01(MainPlugin.P2_THRESHOLD_PCT);
						_deathRoarThreshold = healthSafe * 0.3f;
						_healthSnapped = true;
					}
				}
				return;
			}
			if (_healthSnapped && !_deathRoarTriggered && !IsActive && GetHealthSafe(_self) <= _deathRoarThreshold && GetHealthSafe(_self) > 0f)
			{
				BeginDeathRoar();
			}
			if (_deathRoarActive)
			{
				if (Object.op_Implicit((Object)(object)_rb))
				{
					RBCompat.Set(_rb, Vector3.zero);
					_rb.angularVelocity = Vector3.zero;
					if ((int)_rb.constraints != 14)
					{
						_rb.constraints = (RigidbodyConstraints)14;
					}
				}
				((Component)this).transform.position = _deathRoarLockPos;
				((Component)this).transform.rotation = _deathRoarLockRot;
				if (_finalWindupActive)
				{
					_finalWindupTimer -= Time.deltaTime;
					if (!_beamRoarFired && _finalWindupTimer <= 2f)
					{
						_beamRoarFired = true;
						if (!IsDedicatedServer())
						{
							MainPlugin.PlayRoar(((Component)this).transform.position);
						}
					}
					if (_finalWindupTimer <= 0f)
					{
						_finalWindupActive = false;
						_finalRainActive = true;
						FireBeamAtSky();
						StartBeamAudio();
						_finalLightningTimer = 0.5f;
						_finalMeteorTimer = 3f;
						MainPlugin.Log.LogInfo((object)"[FinalPhase] Lluvia activa.");
					}
				}
				if (_finalRainActive)
				{
					_finalLightningTimer -= Time.deltaTime;
					if (_finalLightningTimer <= 0f)
					{
						_finalLightningTimer = 2.5f;
						SpawnRainLightning();
					}
					_finalMeteorTimer -= Time.deltaTime;
					if (_finalMeteorTimer <= 0f)
					{
						_finalMeteorTimer = 5f;
						SpawnRainMeteors();
					}
					if (!Object.op_Implicit((Object)(object)_activeBeamGO))
					{
						FireBeamAtSky();
					}
				}
			}
			else
			{
				if (_triggeredOnce && !IsActive)
				{
					return;
				}
				if (!IsActive)
				{
					if (!_triggeredOnce && GetHealthSafe(_self) <= _thresholdHealth)
					{
						BeginPhase2();
					}
					return;
				}
				if (Object.op_Implicit((Object)(object)_rb))
				{
					RBCompat.Set(_rb, Vector3.zero);
					if ((int)_rb.constraints != 126)
					{
						_rb.constraints = (RigidbodyConstraints)126;
					}
				}
				((Component)this).transform.position = _lockPos;
				_timeLeft -= Time.deltaTime;
				_seqTimer += Time.deltaTime;
				if (!_stormTriggered && _seqTimer >= MainPlugin.P2_BOSS_LIGHTNING_AT - 7f)
				{
					_stormTriggered = true;
					TryForceStorm();
					MainPlugin.Log.LogInfo((object)"[Phase2] Clima ThunderStorm iniciado.");
				}
				if (!_roarP2Fired && _seqTimer >= MainPlugin.P2_BOSS_LIGHTNING_AT - 2f)
				{
					_roarP2Fired = true;
					if (!IsDedicatedServer())
					{
						MainPlugin.PlayRoar(((Component)this).transform.position);
					}
				}
				if (!_bossLightningFired && _seqTimer >= MainPlugin.P2_BOSS_LIGHTNING_AT)
				{
					_bossLightningFired = true;
					SpawnBossLightning();
					SpawnElectricAura();
					SpawnLightningAura();
					_himminAflTimer = 0f;
					MainPlugin.ApplySerpentMaterials(((Component)this).gameObject, null);
					MainPlugin.Log.LogInfo((object)"[Phase2] Rayo + aura + textura activados.");
				}
				if (!ThunderUnlocked && _seqTimer >= MainPlugin.P2_LEVIATHAN_DUR)
				{
					ThunderUnlocked = true;
					MainPlugin.Log.LogInfo((object)"[Phase2] Rayos sobre jugadores ACTIVOS.");
				}
				if (IsOwnerOrServer())
				{
					_staggerTimer -= Time.deltaTime;
					if (_staggerTimer <= 0f)
					{
						_staggerTimer = Mathf.Max(0.1f, MainPlugin.P2_STAGGER_EVERY);
						StaggerPlayersInRadius(MainPlugin.P2_AURA_RADIUS);
						Animator[] anims = _anims;
						foreach (Animator val in anims)
						{
							if (Object.op_Implicit((Object)(object)val))
							{
								val.CrossFade("swimming", 0.15f, 0, 0f);
							}
						}
					}
				}
				if (_timeLeft <= 0f)
				{
					EndPhase2();
				}
			}
		}

		private void BeginDeathRoar()
		{
			//IL_003d: 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_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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: 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_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: 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_0274: 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_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			_deathRoarTriggered = true;
			_deathRoarActive = true;
			TryForceModer();
			_finalWindupActive = true;
			_beamRoarFired = false;
			_finalRainActive = false;
			_finalWindupTimer = 4f;
			_deathRoarLockPos = ((Component)this).transform.pos