Decompiled source of Einjarheim Server v1.4.5

BepInEx/plugins/AichoGuardian.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("AichoGuardian")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AichoGuardian")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("D28110A9-E229-4700-AD4D-DCD37486A82B")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace NazhiMods.AichoGuardian;

[BepInPlugin("nazhi.aicho.guardian", "Aicho Guardian", "1.3.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class AichoGuardianPlugin : BaseUnityPlugin
{
	public const string PluginGuid = "nazhi.aicho.guardian";

	public const string PluginName = "Aicho Guardian";

	public const string PluginVersion = "1.3.0";

	internal const string GuardianPrefabName = "Aicho_Guardian";

	internal const string WallSourcePrefabName = "piece_dvergr_metal_wall_2x2";

	internal const string WallClonePrefabName = "AichoDverg_Wall";

	public static ConfigEntry<float> CFG_SearchRadius;

	public static ConfigEntry<float> CFG_ResetSeconds;

	private Harmony _harmony;

	private void Awake()
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Expected O, but got Unknown
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Expected O, but got Unknown
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Expected O, but got Unknown
		CFG_SearchRadius = ((BaseUnityPlugin)this).Config.Bind<float>("AichoGuardian", "SearchRadius", 5f, new ConfigDescription("Radio máximo para buscar muros AichoDverg_Wall.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>()));
		CFG_ResetSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("AichoGuardian", "ResetSeconds", 5f, new ConfigDescription("Segundos para que el tótem vuelva a su estado visual activo tras usarse.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 600f), Array.Empty<object>()));
		PrefabManager.OnVanillaPrefabsAvailable += RegisterAichoGuardianAndWall;
		_harmony = new Harmony("nazhi.aicho.guardian");
		_harmony.PatchAll(typeof(AichoGuardianPlugin).Assembly);
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"Aicho Guardian cargado con SearchRadius={CFG_SearchRadius.Value}, ResetSeconds={CFG_ResetSeconds.Value}");
	}

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

	private void RegisterAichoGuardianAndWall()
	{
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Expected O, but got Unknown
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Expected O, but got Unknown
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Expected O, but got Unknown
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Expected O, but got Unknown
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: Expected O, but got Unknown
		//IL_029e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a8: Expected O, but got Unknown
		try
		{
			GameObject prefab = PrefabManager.Instance.GetPrefab("piece_dvergr_metal_wall_2x2");
			if ((Object)(object)prefab == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"No se encontró el prefab 'piece_dvergr_metal_wall_2x2'.");
				return;
			}
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("AichoDverg_Wall", prefab);
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"No se pudo clonar 'piece_dvergr_metal_wall_2x2' a 'AichoDverg_Wall'.");
				return;
			}
			EnsureAdminOnlyPlacement(val, "AichoDverg_Wall");
			Piece component = val.GetComponent<Piece>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_name = "$piece_aicho_dverg_wall";
				component.m_description = "$piece_aicho_dverg_wall_desc";
			}
			PieceConfig val2 = new PieceConfig();
			val2.PieceTable = "_HammerPieceTable";
			val2.Category = "Misc";
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "Stone",
					Amount = 10
				}
			};
			PieceConfig val3 = val2;
			PieceManager.Instance.AddPiece(new CustomPiece(val, true, val3));
			LocalizationManager.Instance.AddToken("piece_aicho_dverg_wall", "Aicho Dvergr Wall", false);
			LocalizationManager.Instance.AddToken("piece_aicho_dverg_wall_desc", "Muro especial (solo admins).", false);
			GameObject prefab2 = PrefabManager.Instance.GetPrefab("guard_stone");
			if ((Object)(object)prefab2 == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"No se encontró el prefab base del tótem (guard_stone / dverger_guardstone).");
				return;
			}
			GameObject val4 = PrefabManager.Instance.CreateClonedPrefab("Aicho_Guardian", prefab2);
			if ((Object)(object)val4 == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"No se pudo clonar el prefab base del tótem.");
				return;
			}
			PrivateArea component2 = val4.GetComponent<PrivateArea>();
			if ((Object)(object)component2 != (Object)null)
			{
				Object.Destroy((Object)(object)component2);
			}
			Transform val5 = val4.transform.Find("AreaMarker");
			if ((Object)(object)val5 != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)val5).gameObject);
			}
			CircleProjector[] componentsInChildren = val4.GetComponentsInChildren<CircleProjector>(true);
			foreach (CircleProjector val6 in componentsInChildren)
			{
				Object.Destroy((Object)(object)((Component)val6).gameObject);
			}
			EnsureAdminOnlyPlacement(val4, "Aicho_Guardian");
			Piece component3 = val4.GetComponent<Piece>();
			if ((Object)(object)component3 != (Object)null)
			{
				component3.m_name = "$piece_aicho_guardian";
				component3.m_description = "$piece_aicho_guardian_desc";
			}
			AichoGuardianBehaviour aichoGuardianBehaviour = val4.GetComponent<AichoGuardianBehaviour>();
			if ((Object)(object)aichoGuardianBehaviour == (Object)null)
			{
				aichoGuardianBehaviour = val4.AddComponent<AichoGuardianBehaviour>();
			}
			aichoGuardianBehaviour.TargetPrefabName = "AichoDverg_Wall";
			val2 = new PieceConfig();
			val2.PieceTable = "_HammerPieceTable";
			val2.Category = "Misc";
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "Stone",
					Amount = 10
				}
			};
			PieceConfig val7 = val2;
			PieceManager.Instance.AddPiece(new CustomPiece(val4, true, val7));
			LocalizationManager.Instance.AddToken("piece_aicho_guardian", "Aicho Guardian", false);
			LocalizationManager.Instance.AddToken("piece_aicho_guardian_desc", "Una piedra guardiana que destruye muros Aicho cercanos al activarse.", false);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Registrado OK: Aicho_Guardian + AichoDverg_Wall (admin-only wall + admin-only guardian).");
		}
		catch (Exception arg)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)$"Error registrando Aicho Guardian/Wall: {arg}");
		}
	}

	private static void EnsureAdminOnlyPlacement(GameObject go, string targetPrefabName)
	{
		AichoAdminOnlyPlacement aichoAdminOnlyPlacement = go.GetComponent<AichoAdminOnlyPlacement>();
		if ((Object)(object)aichoAdminOnlyPlacement == (Object)null)
		{
			aichoAdminOnlyPlacement = go.AddComponent<AichoAdminOnlyPlacement>();
		}
		aichoAdminOnlyPlacement.TargetPrefabName = targetPrefabName;
	}

	internal static bool IsSinglePlayerHost()
	{
		try
		{
			return (Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer() && ZNet.instance.GetConnectedPeers().Count == 0;
		}
		catch
		{
			return false;
		}
	}

	internal static long GetPlayerIdSafe(Player p)
	{
		try
		{
			return ((Object)(object)p != (Object)null) ? p.GetPlayerID() : 0;
		}
		catch
		{
			return 0L;
		}
	}

	internal static bool IsAdminLocal()
	{
		try
		{
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				return false;
			}
			if (IsSinglePlayerHost())
			{
				return true;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return false;
			}
			long playerIdSafe = GetPlayerIdSafe(localPlayer);
			return playerIdSafe != 0L && ZNetExtension.IsAdmin(ZNet.instance, playerIdSafe);
		}
		catch
		{
			return false;
		}
	}

	internal static bool IsAdminId(long playerId)
	{
		try
		{
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				return false;
			}
			if (IsSinglePlayerHost())
			{
				return true;
			}
			return playerId != 0L && ZNetExtension.IsAdmin(ZNet.instance, playerId);
		}
		catch
		{
			return false;
		}
	}
}
public class AichoGuardianBehaviour : MonoBehaviour, Interactable
{
	[CompilerGenerated]
	private sealed class <ResetVisualAfterDelay>d__10 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public float seconds;

		public AichoGuardianBehaviour <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <ResetVisualAfterDelay>d__10(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			int num = <>1__state;
			AichoGuardianBehaviour aichoGuardianBehaviour = <>4__this;
			switch (num)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(seconds);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				aichoGuardianBehaviour.SetActiveVisual(active: true);
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public float SearchRadius = 5f;

	public string TargetPrefabName = "AichoDverg_Wall";

	private Coroutine _resetCoroutine;

	private void Start()
	{
		SetActiveVisual(active: true);
	}

	public string GetHoverText()
	{
		string text = Localization.instance.Localize("$piece_aicho_guardian");
		return Localization.instance.Localize(text + "\n[<color=yellow><b>$KEY_Use</b></color>] Romper muros Aicho cercanos");
	}

	public string GetHoverName()
	{
		return Localization.instance.Localize("$piece_aicho_guardian");
	}

	public bool Interact(Humanoid user, bool hold, bool alt)
	{
		if (hold)
		{
			return false;
		}
		if (!Object.op_Implicit((Object)(object)ZNet.instance) || !ZNet.instance.IsServer())
		{
			return false;
		}
		if (!IsAdminUser(user))
		{
			return false;
		}
		float radius = ((AichoGuardianPlugin.CFG_SearchRadius != null) ? AichoGuardianPlugin.CFG_SearchRadius.Value : SearchRadius);
		float seconds = ((AichoGuardianPlugin.CFG_ResetSeconds != null) ? Mathf.Max(0.01f, AichoGuardianPlugin.CFG_ResetSeconds.Value) : 5f);
		int num = DestroyNearbyWalls(radius);
		Logger.LogInfo((object)$"[AichoGuardian] Muros destruidos: {num}");
		SetActiveVisual(active: false);
		if (_resetCoroutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(_resetCoroutine);
		}
		_resetCoroutine = ((MonoBehaviour)this).StartCoroutine(ResetVisualAfterDelay(seconds));
		return true;
	}

	private static bool IsAdminUser(Humanoid user)
	{
		if (AichoGuardianPlugin.IsSinglePlayerHost())
		{
			return true;
		}
		Player val = (Player)(object)((user is Player) ? user : null);
		if ((Object)(object)val == (Object)null)
		{
			return false;
		}
		long playerIdSafe = AichoGuardianPlugin.GetPlayerIdSafe(val);
		return AichoGuardianPlugin.IsAdminId(playerIdSafe);
	}

	public bool UseItem(Humanoid user, ItemData item)
	{
		return false;
	}

	private int DestroyNearbyWalls(float radius)
	{
		//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_0014: Unknown result type (might be due to invalid IL or missing references)
		int num = 0;
		Vector3 position = ((Component)this).transform.position;
		List<Piece> list = new List<Piece>();
		Piece.GetAllPiecesInRadius(position, radius, list);
		foreach (Piece item in list)
		{
			if ((Object)(object)item == (Object)null)
			{
				continue;
			}
			string prefabName = Utils.GetPrefabName(((Component)item).gameObject);
			if (string.Equals(prefabName, TargetPrefabName, StringComparison.Ordinal))
			{
				WearNTear component = ((Component)item).GetComponent<WearNTear>();
				if (!((Object)(object)component == (Object)null) && !((Object)(object)component.m_nview == (Object)null) && component.m_nview.IsValid())
				{
					component.m_nview.ClaimOwnership();
					ZNetScene.instance.Destroy(((Component)component).gameObject);
					num++;
				}
			}
		}
		return num;
	}

	[IteratorStateMachine(typeof(<ResetVisualAfterDelay>d__10))]
	private IEnumerator ResetVisualAfterDelay(float seconds)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <ResetVisualAfterDelay>d__10(0)
		{
			<>4__this = this,
			seconds = seconds
		};
	}

	private void SetActiveVisual(bool active)
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: 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)
		try
		{
			if (!((Object)(object)MaterialMan.instance == (Object)null))
			{
				if (active)
				{
					MaterialMan.instance.ResetValue(((Component)this).gameObject, ShaderProps._Color);
					MaterialMan.instance.ResetValue(((Component)this).gameObject, ShaderProps._EmissionColor);
				}
				else
				{
					MaterialMan.instance.SetValue<Color>(((Component)this).gameObject, ShaderProps._Color, Color.grey);
					MaterialMan.instance.SetValue<Color>(((Component)this).gameObject, ShaderProps._EmissionColor, Color.grey * 0.1f);
				}
			}
		}
		catch (Exception ex)
		{
			Logger.LogWarning((object)("[AichoGuardian] Error en SetActiveVisual: " + ex.Message));
		}
	}
}
public class AichoAdminOnlyPlacement : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <Start>d__2 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public AichoAdminOnlyPlacement <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <Start>d__2(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			int num = <>1__state;
			AichoAdminOnlyPlacement aichoAdminOnlyPlacement = <>4__this;
			switch (num)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
				{
					return false;
				}
				<>2__current = (object)new WaitForSeconds(0.15f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				try
				{
					if (string.IsNullOrEmpty(aichoAdminOnlyPlacement.TargetPrefabName))
					{
						return false;
					}
					string prefabName = Utils.GetPrefabName(((Component)aichoAdminOnlyPlacement).gameObject);
					if (!string.Equals(prefabName, aichoAdminOnlyPlacement.TargetPrefabName, StringComparison.Ordinal))
					{
						return false;
					}
					if (AichoGuardianPlugin.IsSinglePlayerHost())
					{
						return false;
					}
					Piece component = ((Component)aichoAdminOnlyPlacement).GetComponent<Piece>();
					if ((Object)(object)component == (Object)null)
					{
						return false;
					}
					long creatorIdBestEffort = GetCreatorIdBestEffort(component);
					Player localPlayer = Player.m_localPlayer;
					long num2 = (((Object)(object)localPlayer != (Object)null) ? AichoGuardianPlugin.GetPlayerIdSafe(localPlayer) : 0);
					if (creatorIdBestEffort != 0L && creatorIdBestEffort == num2)
					{
						return false;
					}
					if (creatorIdBestEffort != 0L && !AichoGuardianPlugin.IsAdminId(creatorIdBestEffort))
					{
						Logger.LogWarning((object)$"[AichoGuardian] Bloqueada colocación de {prefabName} por no-admin (creator={creatorIdBestEffort}).");
						WearNTear component2 = ((Component)aichoAdminOnlyPlacement).GetComponent<WearNTear>();
						if ((Object)(object)component2 != (Object)null && (Object)(object)component2.m_nview != (Object)null && component2.m_nview.IsValid())
						{
							component2.m_nview.ClaimOwnership();
						}
						if ((Object)(object)ZNetScene.instance != (Object)null)
						{
							ZNetScene.instance.Destroy(((Component)aichoAdminOnlyPlacement).gameObject);
						}
						else
						{
							Object.Destroy((Object)(object)((Component)aichoAdminOnlyPlacement).gameObject);
						}
					}
				}
				catch (Exception ex)
				{
					Logger.LogWarning((object)("[AichoGuardian] Error en AichoAdminOnlyPlacement: " + ex.Message));
				}
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public string TargetPrefabName = "";

	private const float CheckDelay = 0.15f;

	[IteratorStateMachine(typeof(<Start>d__2))]
	private IEnumerator Start()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <Start>d__2(0)
		{
			<>4__this = this
		};
	}

	private static long GetCreatorIdBestEffort(Piece piece)
	{
		try
		{
			MethodInfo method = typeof(Piece).GetMethod("GetCreator", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (method != null && method.ReturnType == typeof(long))
			{
				return (long)method.Invoke(piece, null);
			}
			FieldInfo field = typeof(Piece).GetField("m_creator", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null && field.FieldType == typeof(long))
			{
				return (long)field.GetValue(piece);
			}
		}
		catch
		{
		}
		return 0L;
	}
}
[HarmonyPatch(typeof(PieceTable), "UpdateAvailable")]
public static class AichoHammerVisibilityPatches
{
	[HarmonyPostfix]
	private static void PieceTable_UpdateAvailable_Postfix(PieceTable __instance, HashSet<string> knownRecipies, Player player, bool hideUnavailable, bool noPlacementCost)
	{
		try
		{
			if ((Object)(object)__instance == (Object)null || AichoGuardianPlugin.IsAdminLocal() || __instance.m_availablePieces == null || __instance.m_availablePieces.Count == 0)
			{
				return;
			}
			for (int i = 0; i < __instance.m_availablePieces.Count; i++)
			{
				List<Piece> list = __instance.m_availablePieces[i];
				if (list == null || list.Count == 0)
				{
					continue;
				}
				list.RemoveAll(delegate(Piece piece)
				{
					if ((Object)(object)piece == (Object)null)
					{
						return false;
					}
					string prefabName = Utils.GetPrefabName(((Component)piece).gameObject);
					return string.Equals(prefabName, "AichoDverg_Wall", StringComparison.Ordinal) || string.Equals(prefabName, "Aicho_Guardian", StringComparison.Ordinal);
				});
			}
		}
		catch
		{
		}
	}
}

BepInEx/plugins/BalrondTitanTroll.dll

Decompiled a week ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BalrondBiomes_Meadows;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ProjectAshlands")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ProjectAshlands")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f405ea1c-ac25-47a3-9aa2-a8f56c14bfd6")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BalrondBiomes_Meadows
{
	public class ShaderReplacment
	{
		public string[] shaderlist = new string[49]
		{
			"Custom/AlphaParticle", "Custom/Blob", "Custom/Bonemass", "Custom/Clouds", "Custom/Creature", "Custom/Decal", "Custom/Distortion", "Custom/Flow", "Custom/FlowOpaque", "Custom/Grass",
			"Custom/GuiScroll", "Custom/Heightmap", "Custom/icon", "Custom/InteriorSide", "Custom/LitGui", "Custom/LitParticles", "Custom/mapshader", "Custom/ParticleDecal", "Custom/Piece", "Custom/Player",
			"Custom/Rug", "Custom/ShadowBlob", "Custom/SkyboxProcedural", "Custom/SkyObject", "Custom/StaticRock", "Custom/Tar", "Custom/Trilinearmap", "Custom/UI/BGBlur", "Custom/Vegetation", "Custom/Water",
			"Custom/WaterBottom", "Custom/WaterMask", "Custom/Yggdrasil", "Custom/Yggdrasil/root", "Hidden/BlitCopyHDRTonemap", "Hidden/Dof/DepthOfFieldHdr", "Hidden/Dof/DX11Dof", "Hidden/Internal-Loading", "Hidden/Internal-UIRDefaultWorld", "Hidden/SimpleClear",
			"Hidden/SunShaftsComposite", "Lux Lit Particles/ Bumped", "Lux Lit Particles/ Tess Bumped", "Particles/Standard Surface2", "Particles/Standard Unlit2", "Standard TwoSided", "ToonDeferredShading2017", "Unlit/DepthWrite", "Unlit/Lighting"
		};

		public List<Shader> shaders = new List<Shader>();

		public void findShadersByName()
		{
			string[] array = shaderlist;
			foreach (string text in array)
			{
				Shader val = Shader.Find(text);
				if ((Object)(object)val != (Object)null)
				{
					shaders.Add(val);
				}
			}
		}

		public void ReplaceShadersInObject(GameObject gameObject)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (new ZNet().IsDedicated() || (Object)(object)gameObject == (Object)null)
			{
				return;
			}
			Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>();
			if (componentsInChildren == null || componentsInChildren.Length == 0)
			{
				return;
			}
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				Material[] sharedMaterials = val.sharedMaterials;
				if (sharedMaterials != null && sharedMaterials.Length != 0)
				{
					fixMaterial(sharedMaterials);
				}
			}
		}

		private void fixMaterial(Material[] shared)
		{
			foreach (Material val in shared)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				Shader shader = val.shader;
				if (!((Object)(object)shader == (Object)null))
				{
					string name = ((Object)shader).name;
					if (!(name == "Standard") && name.Contains("Balrond"))
					{
						setProperValue(val, name);
					}
				}
			}
		}

		public Material setProperValue(Material material, string shaderName)
		{
			string name = shaderName.Replace("Balrond", "Custom");
			name = checkNaming(name);
			Shader val = Shader.Find(name);
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)("Shader not found " + name));
				return material;
			}
			material.shader = val;
			return material;
		}

		private string checkNaming(string name)
		{
			string result = name;
			if (name.Contains("Bumped"))
			{
				result = name.Replace("Custom", "Lux Lit Particles");
			}
			if (name.Contains("Tess Bumped"))
			{
				result = name.Replace("Custom", "Lux Lit Particles");
			}
			if (name.Contains("Standard Surface"))
			{
				result = name.Replace("Custom", "Particles");
				result = result.Replace("Standard Surface2", "Standard Surface");
			}
			if (name.Contains("Standard Unlit"))
			{
				result = name.Replace("Custom", "Particles");
				result = result.Replace("Standard Unlit", "Standard Unlit2");
				result = result.Replace("Standard Unlit22", "Standard Unlit2");
			}
			return result;
		}
	}
}
namespace BalrondTitanTroll
{
	public class FxReplacment
	{
		private List<GameObject> allPrefabs;

		private string projectName = "[BalrondTitanTroll]";

		public void setInstance(List<GameObject> gameObjects)
		{
			allPrefabs = gameObjects;
		}

		public void ReplaceOnObject(GameObject gameObject)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				return;
			}
			SpawnArea component = gameObject.GetComponent<SpawnArea>();
			if ((Object)(object)component != (Object)null)
			{
				EffectList spawnEffects = component.m_spawnEffects;
				if (spawnEffects != null)
				{
					findEffectsAndChange(spawnEffects.m_effectPrefabs);
				}
			}
			Destructible component2 = gameObject.GetComponent<Destructible>();
			if ((Object)(object)component2 != (Object)null)
			{
				EffectList hitEffect = component2.m_hitEffect;
				if (hitEffect != null)
				{
					findEffectsAndChange(hitEffect.m_effectPrefabs);
				}
				EffectList destroyedEffect = component2.m_destroyedEffect;
				if (destroyedEffect != null)
				{
					findEffectsAndChange(destroyedEffect.m_effectPrefabs);
				}
			}
			Projectile component3 = gameObject.GetComponent<Projectile>();
			if ((Object)(object)component3 != (Object)null)
			{
				EffectList hitEffects = component3.m_hitEffects;
				if (hitEffects != null)
				{
					findEffectsAndChange(hitEffects.m_effectPrefabs);
				}
				EffectList hitWaterEffects = component3.m_hitWaterEffects;
				if (hitWaterEffects != null)
				{
					findEffectsAndChange(hitWaterEffects.m_effectPrefabs);
				}
				EffectList spawnOnHitEffects = component3.m_spawnOnHitEffects;
				if (spawnOnHitEffects != null)
				{
					findEffectsAndChange(spawnOnHitEffects.m_effectPrefabs);
				}
			}
		}

		public void ReplaceOnVegetation(GameObject gameObject)
		{
			Pickable component = gameObject.GetComponent<Pickable>();
			if ((Object)(object)component != (Object)null)
			{
				fixPlant(component);
			}
			Destructible component2 = gameObject.GetComponent<Destructible>();
			if ((Object)(object)component2 != (Object)null)
			{
				fixPDestructable(component2);
			}
			MineRock5 component3 = gameObject.GetComponent<MineRock5>();
			if ((Object)(object)component3 != (Object)null)
			{
				fixMineRock5(component3);
			}
			MineRock component4 = gameObject.GetComponent<MineRock>();
			if ((Object)(object)component4 != (Object)null)
			{
				fixMineRock(component4);
			}
		}

		private void fixPlant(Pickable pickable)
		{
			EffectList pickEffector = pickable.m_pickEffector;
			if (pickEffector != null)
			{
				findEffectsAndChange(pickEffector.m_effectPrefabs);
			}
		}

		private void fixPDestructable(Destructible minerock5)
		{
			EffectList hitEffect = minerock5.m_hitEffect;
			if (hitEffect != null)
			{
				findEffectsAndChange(hitEffect.m_effectPrefabs);
			}
			EffectList destroyedEffect = minerock5.m_destroyedEffect;
			if (destroyedEffect != null)
			{
				findEffectsAndChange(destroyedEffect.m_effectPrefabs);
			}
		}

		private void fixMineRock5(MineRock5 minerock5)
		{
			EffectList hitEffect = minerock5.m_hitEffect;
			if (hitEffect != null)
			{
				findEffectsAndChange(hitEffect.m_effectPrefabs);
			}
			EffectList destroyedEffect = minerock5.m_destroyedEffect;
			if (destroyedEffect != null)
			{
				findEffectsAndChange(destroyedEffect.m_effectPrefabs);
			}
		}

		private void fixMineRock(MineRock minerock5)
		{
			EffectList hitEffect = minerock5.m_hitEffect;
			if (hitEffect != null)
			{
				findEffectsAndChange(hitEffect.m_effectPrefabs);
			}
			EffectList destroyedEffect = minerock5.m_destroyedEffect;
			if (destroyedEffect != null)
			{
				findEffectsAndChange(destroyedEffect.m_effectPrefabs);
			}
		}

		public void ReplaceOnMonster(GameObject gameObject)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				Debug.LogWarning((object)(projectName + ":: GameObject not found"));
				return;
			}
			Humanoid component = gameObject.GetComponent<Humanoid>();
			if ((Object)(object)component == (Object)null)
			{
				Debug.LogWarning((object)(projectName + ":: GameObject not found"));
				return;
			}
			EffectList dropEffects = component.m_dropEffects;
			if (dropEffects != null)
			{
				findEffectsAndChange(dropEffects.m_effectPrefabs);
			}
			EffectList backstabHitEffects = ((Character)component).m_backstabHitEffects;
			if (backstabHitEffects != null)
			{
				findEffectsAndChange(backstabHitEffects.m_effectPrefabs);
			}
			EffectList consumeItemEffects = component.m_consumeItemEffects;
			if (consumeItemEffects != null)
			{
				findEffectsAndChange(consumeItemEffects.m_effectPrefabs);
			}
			EffectList critHitEffects = ((Character)component).m_critHitEffects;
			if (critHitEffects != null)
			{
				findEffectsAndChange(critHitEffects.m_effectPrefabs);
			}
			EffectList deathEffects = ((Character)component).m_deathEffects;
			if (deathEffects != null)
			{
				findEffectsAndChange(deathEffects.m_effectPrefabs);
			}
			EffectList hitEffects = ((Character)component).m_hitEffects;
			if (hitEffects != null)
			{
				findEffectsAndChange(hitEffects.m_effectPrefabs);
			}
			EffectList jumpEffects = ((Character)component).m_jumpEffects;
			if (jumpEffects != null)
			{
				findEffectsAndChange(jumpEffects.m_effectPrefabs);
			}
			EffectList perfectBlockEffect = component.m_perfectBlockEffect;
			if (perfectBlockEffect != null)
			{
				findEffectsAndChange(perfectBlockEffect.m_effectPrefabs);
			}
			EffectList pickupEffects = component.m_pickupEffects;
			if (pickupEffects != null)
			{
				findEffectsAndChange(pickupEffects.m_effectPrefabs);
			}
			EffectList slideEffects = ((Character)component).m_slideEffects;
			if (slideEffects != null)
			{
				findEffectsAndChange(slideEffects.m_effectPrefabs);
			}
			EffectList tarEffects = ((Character)component).m_tarEffects;
			if (tarEffects != null)
			{
				findEffectsAndChange(tarEffects.m_effectPrefabs);
			}
			EffectList waterEffects = ((Character)component).m_waterEffects;
			if (waterEffects != null)
			{
				findEffectsAndChange(waterEffects.m_effectPrefabs);
			}
			FootStep component2 = gameObject.GetComponent<FootStep>();
			if (!((Object)(object)component2 != (Object)null))
			{
				return;
			}
			List<StepEffect> effects = component2.m_effects;
			foreach (StepEffect item in effects)
			{
				GameObject[] effectPrefabs = item.m_effectPrefabs;
				List<GameObject> list = new List<GameObject>();
				list.AddRange(effectPrefabs);
				for (int i = 0; i < list.Count; i++)
				{
					if ((Object)(object)list[i] != (Object)null)
					{
						string name = ((Object)list[i]).name;
						GameObject val = allPrefabs.Find((GameObject x) => ((Object)x).name == name);
						if (!((Object)(object)val == (Object)null))
						{
							list[i] = val;
						}
					}
				}
			}
		}

		public void ReplaceOnItem(GameObject gameObject)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				return;
			}
			ItemDrop component = gameObject.GetComponent<ItemDrop>();
			if (!((Object)(object)component == (Object)null))
			{
				EffectList hitEffect = component.m_itemData.m_shared.m_hitEffect;
				if (hitEffect != null)
				{
					findEffectsAndChange(hitEffect.m_effectPrefabs);
				}
				EffectList hitTerrainEffect = component.m_itemData.m_shared.m_hitTerrainEffect;
				if (hitTerrainEffect != null)
				{
					findEffectsAndChange(hitTerrainEffect.m_effectPrefabs);
				}
				EffectList holdStartEffect = component.m_itemData.m_shared.m_holdStartEffect;
				if (holdStartEffect != null)
				{
					findEffectsAndChange(holdStartEffect.m_effectPrefabs);
				}
				EffectList trailStartEffect = component.m_itemData.m_shared.m_trailStartEffect;
				if (trailStartEffect != null)
				{
					findEffectsAndChange(trailStartEffect.m_effectPrefabs);
				}
				EffectList blockEffect = component.m_itemData.m_shared.m_blockEffect;
				if (blockEffect != null)
				{
					findEffectsAndChange(blockEffect.m_effectPrefabs);
				}
			}
		}

		public void ReplaceFxOnPiece(GameObject gameObject)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				return;
			}
			Piece component = gameObject.GetComponent<Piece>();
			if ((Object)(object)component != (Object)null)
			{
				EffectList placeEffect = component.m_placeEffect;
				if (placeEffect != null)
				{
					findEffectsAndChange(placeEffect.m_effectPrefabs);
				}
			}
			WearNTear component2 = gameObject.GetComponent<WearNTear>();
			if ((Object)(object)component2 != (Object)null)
			{
				EffectList hitEffect = component2.m_hitEffect;
				if (hitEffect != null)
				{
					findEffectsAndChange(hitEffect.m_effectPrefabs);
				}
			}
		}

		private void findEffectsAndChange(EffectData[] effects)
		{
			if (effects == null || effects.Length == 0)
			{
				return;
			}
			foreach (EffectData val in effects)
			{
				if ((Object)(object)val.m_prefab != (Object)null)
				{
					string name = ((Object)val.m_prefab).name;
					GameObject val2 = allPrefabs.Find((GameObject x) => ((Object)x).name == name);
					if (!((Object)(object)val2 == (Object)null))
					{
						val.m_prefab = val2;
					}
				}
			}
		}
	}
	public class BuildPieceTargeting
	{
		private static string[] names = new string[0];

		public void changePieceTargeting(List<GameObject> gameObjects)
		{
			List<GameObject> list = gameObjects.FindAll((GameObject x) => (Object)(object)x.GetComponent<WearNTear>() != (Object)null);
			foreach (GameObject item in list)
			{
				Piece component = item.GetComponent<Piece>();
				if ((Object)(object)component != (Object)null && names.Contains(((Object)item).name))
				{
					((StaticTarget)component).m_primaryTarget = true;
				}
				if ((Object)(object)component != (Object)null && shouldBePrimaryTarget(item))
				{
					((StaticTarget)component).m_primaryTarget = true;
				}
				setResistances(item);
			}
		}

		private bool shouldBePrimaryTarget(GameObject gameObject)
		{
			if ((Object)(object)gameObject.GetComponent<Door>() != (Object)null)
			{
				return true;
			}
			if ((Object)(object)gameObject.GetComponent<CraftingStation>() != (Object)null)
			{
				return true;
			}
			if ((Object)(object)gameObject.GetComponent<StationExtension>() != (Object)null)
			{
				return true;
			}
			if ((Object)(object)gameObject.GetComponent<Container>() != (Object)null)
			{
				return false;
			}
			return false;
		}

		private void setResistances(GameObject gameObject)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_0040: 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)
			WearNTear component = gameObject.GetComponent<WearNTear>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_damages.m_chop = setChopDamageResistance(component);
				component.m_damages.m_pickaxe = setPickaxeDamageResistance(component);
				component.m_damages.m_fire = setFireDamageResistance(component);
			}
		}

		private DamageModifier setChopDamageResistance(WearNTear wearNTear)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected I4, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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)
			MaterialType materialType = wearNTear.m_materialType;
			MaterialType val = materialType;
			return (DamageModifier)((int)val switch
			{
				0 => 6, 
				3 => 2, 
				2 => 5, 
				1 => 1, 
				_ => 0, 
			});
		}

		private DamageModifier setPickaxeDamageResistance(WearNTear wearNTear)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected I4, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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)
			MaterialType materialType = wearNTear.m_materialType;
			MaterialType val = materialType;
			return (DamageModifier)((int)val switch
			{
				0 => 0, 
				3 => 1, 
				2 => 2, 
				1 => 6, 
				_ => 0, 
			});
		}

		private DamageModifier setFireDamageResistance(WearNTear wearNTear)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected I4, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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)
			MaterialType materialType = wearNTear.m_materialType;
			MaterialType val = materialType;
			return (DamageModifier)((int)val switch
			{
				0 => 6, 
				3 => 2, 
				2 => 0, 
				1 => 5, 
				_ => 0, 
			});
		}
	}
	public class DatabaseAddMethods
	{
		public void AddItems(List<GameObject> items)
		{
			foreach (GameObject item in items)
			{
				AddItem(item);
			}
		}

		public void AddRecipes(List<Recipe> recipes)
		{
			foreach (Recipe recipe in recipes)
			{
				AddRecipe(recipe);
			}
		}

		public void AddStatuseffects(List<StatusEffect> statusEffects)
		{
			foreach (StatusEffect statusEffect in statusEffects)
			{
				AddStatus(statusEffect);
			}
		}

		private bool IsObjectDBValid()
		{
			return (Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0 && ObjectDB.instance.m_recipes.Count != 0 && (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null;
		}

		private void AddStatus(StatusEffect status)
		{
			if (!IsObjectDBValid())
			{
				return;
			}
			if ((Object)(object)status != (Object)null)
			{
				if ((Object)(object)ObjectDB.instance.GetStatusEffect(((object)status).GetHashCode()) == (Object)null)
				{
					ObjectDB.instance.m_StatusEffects.Add(status);
				}
			}
			else
			{
				Debug.LogError((object)("BalrondTitanTroll:  " + ((Object)status).name + " - Status not found"));
			}
		}

		private void AddRecipe(Recipe recipe)
		{
			if (!IsObjectDBValid())
			{
				return;
			}
			if ((Object)(object)recipe != (Object)null)
			{
				if ((Object)(object)ObjectDB.instance.GetRecipe(recipe.m_item.m_itemData) == (Object)null)
				{
					ObjectDB.instance.m_recipes.Add(recipe);
				}
			}
			else
			{
				Debug.LogError((object)("BalrondTitanTroll:  " + ((Object)recipe).name + " - Recipe not found"));
			}
		}

		private void AddItem(GameObject newPrefab)
		{
			if (!IsObjectDBValid())
			{
				return;
			}
			ItemDrop component = newPrefab.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null)
			{
				if ((Object)(object)ObjectDB.instance.GetItemPrefab(((Object)newPrefab).name) == (Object)null)
				{
					ObjectDB.instance.m_items.Add(newPrefab);
					Dictionary<int, GameObject> dictionary = (Dictionary<int, GameObject>)typeof(ObjectDB).GetField("m_itemByHash", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(ObjectDB.instance);
					dictionary[((Object)newPrefab).name.GetHashCode()] = newPrefab;
				}
			}
			else
			{
				Debug.LogError((object)("BalrondTitanTroll:  " + ((Object)newPrefab).name + " - ItemDrop not found on prefab"));
			}
		}
	}
	[BepInPlugin("balrond.astafaraios.BalrondTitanTroll", "BalrondTitanTroll", "1.0.0")]
	public class Launch : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Game), "Awake")]
		public static class Game_Awake_Path
		{
			public static void Prefix()
			{
				ZNetScene_Awake_Path.hasSpawned = false;
			}
		}

		[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
		public static class Object_CopyOtherDB_Path
		{
			public static void Postfix()
			{
				if (IsObjectDBValid())
				{
				}
			}
		}

		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		public static class ObjectDB_Awake_Path
		{
			public static void Postfix()
			{
				if (IsObjectDBValid())
				{
					databaseAddMethods.AddItems(modResourceLoader.items);
				}
			}
		}

		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		public static class ZNetScene_Awake_Path
		{
			public static bool hasSpawned;

			public static void Prefix(ZNetScene __instance)
			{
				if ((Object)(object)__instance == (Object)null)
				{
					Debug.LogWarning((object)"BalrondTitanTroll: No ZnetScene found");
				}
				else if (!hasSpawned)
				{
					__instance.m_prefabs.Add(modResourceLoader.TitanTroll4);
					__instance.m_prefabs.Add(modResourceLoader.TitanTroll3);
					__instance.m_prefabs.Add(modResourceLoader.TitanTroll2);
					__instance.m_prefabs.Add(modResourceLoader.TitanTroll);
					__instance.m_prefabs.Add(modResourceLoader.groundslamAoE);
					__instance.m_prefabs.Add(modResourceLoader.tauntAoE);
					__instance.m_prefabs.Add(modResourceLoader.screamvfx);
					__instance.m_prefabs.Add(modResourceLoader.soundvfx);
					__instance.m_prefabs.AddRange(modResourceLoader.items);
					hasSpawned = true;
				}
			}
		}

		private readonly Harmony harmony = new Harmony("balrond.astafaraios.BalrondTitanTroll");

		public const string PluginGUID = "balrond.astafaraios.BalrondTitanTroll";

		public const string PluginName = "BalrondTitanTroll";

		public const string PluginVersion = "1.0.0";

		public static ModResourceLoader modResourceLoader = new ModResourceLoader();

		public static ItemEdits itemEdits = new ItemEdits();

		public static DatabaseAddMethods databaseAddMethods = new DatabaseAddMethods();

		public static BuildPieceTargeting pieceTargeting = new BuildPieceTargeting();

		public static GameObject RootObject;

		public static GameObject PrefabContainer;

		private void Awake()
		{
			createPrefabContainer();
			modResourceLoader.loadAssets();
			harmony.PatchAll();
		}

		private void OnDestroy()
		{
			harmony.UnpatchSelf();
		}

		public void createPrefabContainer()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			RootObject = new GameObject("_ValheimReforgedRoot");
			Object.DontDestroyOnLoad((Object)(object)RootObject);
			PrefabContainer = new GameObject("Prefabs");
			PrefabContainer.transform.parent = RootObject.transform;
			PrefabContainer.SetActive(false);
		}

		public static GameObject cloneMe(GameObject source, string name)
		{
			GameObject val = Object.Instantiate<GameObject>(source, PrefabContainer.transform);
			((Object)val).name = name;
			return val;
		}

		private static bool IsObjectDBValid()
		{
			return (Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0 && ObjectDB.instance.m_recipes.Count != 0 && (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null;
		}

		public static void addStatusToAttackField(GameObject gameObject, StatusEffect statusEffect)
		{
			ItemDrop component = gameObject.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_attackStatusEffect = statusEffect;
		}
	}
	public class ModResourceLoader
	{
		public AssetBundle assetBundle;

		public ShaderReplacment shaderReplacment = new ShaderReplacment();

		public GameObject TitanTroll;

		public GameObject TitanTroll2;

		public GameObject TitanTroll3;

		public GameObject TitanTroll4;

		public GameObject swingV;

		public GameObject swingH;

		public GameObject swingH2;

		public GameObject swingV_2hand;

		public GameObject swingH_2hand;

		public GameObject swingH_2hand2;

		public GameObject shield;

		public GameObject charge;

		public GameObject charge2;

		public GameObject charge3;

		public GameObject shieldslam;

		public GameObject groundslam;

		public GameObject punch;

		public GameObject punch2;

		public GameObject throwRock;

		public GameObject slam2h;

		public GameObject taunt;

		public GameObject tauntAoE;

		public GameObject tauntB;

		public GameObject screamvfx;

		public GameObject soundvfx;

		public GameObject groundslamAoE;

		public List<GameObject> items = new List<GameObject>();

		public void loadAssets()
		{
			assetBundle = GetAssetBundleFromResources("titantroll");
			string text = "Assets/Custom/Comission/DarkTroll/";
			TitanTroll = assetBundle.LoadAsset<GameObject>(text + "TitanTroll.prefab");
			shaderReplacment.ReplaceShadersInObject(TitanTroll);
			TitanTroll3 = assetBundle.LoadAsset<GameObject>(text + "TitanTroll1h.prefab");
			shaderReplacment.ReplaceShadersInObject(TitanTroll3);
			TitanTroll2 = assetBundle.LoadAsset<GameObject>(text + "TitanTroll2h.prefab");
			shaderReplacment.ReplaceShadersInObject(TitanTroll2);
			TitanTroll4 = assetBundle.LoadAsset<GameObject>(text + "TitanTrollR.prefab");
			shaderReplacment.ReplaceShadersInObject(TitanTroll4);
			swingV = assetBundle.LoadAsset<GameObject>(text + "Titantroll_log_swing_v.prefab");
			shaderReplacment.ReplaceShadersInObject(swingV);
			swingH = assetBundle.LoadAsset<GameObject>(text + "Titantroll_log_swing_h.prefab");
			shaderReplacment.ReplaceShadersInObject(swingH);
			swingH2 = assetBundle.LoadAsset<GameObject>(text + "Titantroll_log_swing_mace.prefab");
			shaderReplacment.ReplaceShadersInObject(swingH2);
			swingV_2hand = assetBundle.LoadAsset<GameObject>(text + "Titantroll_log_swing_v_2hand.prefab");
			shaderReplacment.ReplaceShadersInObject(swingV_2hand);
			swingH_2hand = assetBundle.LoadAsset<GameObject>(text + "Titantroll_log_swing_h_2hand.prefab");
			shaderReplacment.ReplaceShadersInObject(swingH_2hand);
			swingH_2hand2 = assetBundle.LoadAsset<GameObject>(text + "Titantroll_log_swing_h_2hand1.prefab");
			shaderReplacment.ReplaceShadersInObject(swingH_2hand2);
			shield = assetBundle.LoadAsset<GameObject>(text + "ShieldTroll.prefab");
			shaderReplacment.ReplaceShadersInObject(shield);
			charge = assetBundle.LoadAsset<GameObject>(text + "TitanTroll_dash.prefab");
			shaderReplacment.ReplaceShadersInObject(charge);
			charge2 = assetBundle.LoadAsset<GameObject>(text + "TitanTroll_dash_1hand.prefab");
			shaderReplacment.ReplaceShadersInObject(charge2);
			charge3 = assetBundle.LoadAsset<GameObject>(text + "TitanTroll_dash_2hand.prefab");
			shaderReplacment.ReplaceShadersInObject(charge3);
			shieldslam = assetBundle.LoadAsset<GameObject>(text + "Titantroll_shieldslam.prefab");
			shaderReplacment.ReplaceShadersInObject(shieldslam);
			punch = assetBundle.LoadAsset<GameObject>(text + "Titantroll_punch.prefab");
			shaderReplacment.ReplaceShadersInObject(punch);
			punch2 = assetBundle.LoadAsset<GameObject>(text + "Titantroll_doublepunch.prefab");
			shaderReplacment.ReplaceShadersInObject(punch2);
			throwRock = assetBundle.LoadAsset<GameObject>(text + "Titantroll_throw.prefab");
			shaderReplacment.ReplaceShadersInObject(throwRock);
			groundslam = assetBundle.LoadAsset<GameObject>(text + "Titantroll_groundslam.prefab");
			shaderReplacment.ReplaceShadersInObject(groundslam);
			slam2h = assetBundle.LoadAsset<GameObject>(text + "Titantroll_log_swing_h_2hand_slam.prefab");
			shaderReplacment.ReplaceShadersInObject(groundslam);
			taunt = assetBundle.LoadAsset<GameObject>(text + "Titantroll_taunt.prefab");
			shaderReplacment.ReplaceShadersInObject(taunt);
			tauntAoE = assetBundle.LoadAsset<GameObject>(text + "Titantroll_scream_aoe.prefab");
			shaderReplacment.ReplaceShadersInObject(tauntAoE);
			groundslamAoE = assetBundle.LoadAsset<GameObject>(text + "Titantroll_groundslam_aoe.prefab");
			shaderReplacment.ReplaceShadersInObject(groundslamAoE);
			screamvfx = assetBundle.LoadAsset<GameObject>(text + "sfx_titantroll_scream.prefab");
			shaderReplacment.ReplaceShadersInObject(screamvfx);
			soundvfx = assetBundle.LoadAsset<GameObject>(text + "sfx_titantroll_sound.prefab");
			shaderReplacment.ReplaceShadersInObject(soundvfx);
			items.Add(swingH);
			items.Add(swingH2);
			items.Add(swingV);
			items.Add(swingH_2hand);
			items.Add(swingH_2hand2);
			items.Add(swingV_2hand);
			items.Add(shield);
			items.Add(charge);
			items.Add(charge2);
			items.Add(charge3);
			items.Add(shieldslam);
			items.Add(taunt);
			items.Add(punch);
			items.Add(punch2);
			items.Add(slam2h);
			items.Add(groundslam);
			items.Add(throwRock);
		}

		private AssetBundle GetAssetBundleFromResources(string filename)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(filename));
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			return AssetBundle.LoadFromStream(stream);
		}
	}
	public class ItemEdits
	{
		private string[] itemEditNames = new string[14]
		{
			"draugr_sword", "draugr_bow", "draugr_axe", "skeleton_bow", "skeleton_mace", "skeleton_sword2", "skeleton_bow2", "skeleton_sword2", "imp_fireball_attack", "Ghost_attack",
			"gd_king_shoot", "Greydwarf_shaman_attack", "GoblinKing_Beam", "GoblinShaman_attack_fireball"
		};

		private GameObject FindItem(List<GameObject> list, string name)
		{
			GameObject val = list.Find((GameObject x) => ((Object)x).name == name);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			Debug.LogWarning((object)("BalrondTitanTroll: Item Not Found: " + name));
			return null;
		}

		public void editItems(List<GameObject> list)
		{
			string[] array = itemEditNames;
			foreach (string text in array)
			{
				GameObject val = FindItem(list, text);
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogWarning((object)("Could not find: " + text));
				}
				else
				{
					CheckStats(val);
				}
			}
		}

		private void CheckStats(GameObject gameObject)
		{
			switch (((Object)gameObject).name)
			{
			case "draugr_sword":
				editSpiritDamageStat(gameObject, 25);
				break;
			case "draugr_bow":
				editSpiritDamageStat(gameObject, 15);
				break;
			case "draugr_axe":
				editSpiritDamageStat(gameObject, 15);
				break;
			case "skeleton_bow":
			case "skeleton_sword":
			case "Ghost_attack":
				editSpiritDamageStat(gameObject, 10);
				break;
			case "skeleton_bow2":
			case "skeleton_mace":
			case "skeleton_sword2":
			case "gd_king_shoot":
			case "Greydwarf_shaman_attack":
			case "GoblinKing_Beam":
			case "GoblinShaman_attack_fireball":
				editSpiritDamageStat(gameObject, 20);
				break;
			case "imp_fireball_attack":
				editSpiritDamageStat(gameObject, 10);
				break;
			}
		}

		private void editSpiritDamageStat(GameObject gameObject, int spiritDamage)
		{
			ItemDrop component = gameObject.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_damages.m_spirit = spiritDamage;
			if (((Object)gameObject).name == "skeleton_mace" || ((Object)gameObject).name == "imp_fireball_attack")
			{
				component.m_itemData.m_shared.m_damages.m_blunt += spiritDamage;
			}
		}

		private void editFoodStat(GameObject gameObject, int hp = -99, int stam = -99, int eitr = -99, int time = -99, int regen = -99)
		{
			ItemDrop component = gameObject.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_food = ((hp == -99) ? component.m_itemData.m_shared.m_food : ((float)hp));
			component.m_itemData.m_shared.m_foodStamina = ((stam == -99) ? component.m_itemData.m_shared.m_foodStamina : ((float)stam));
			component.m_itemData.m_shared.m_foodEitr = ((eitr == -99) ? component.m_itemData.m_shared.m_foodEitr : ((float)eitr));
			component.m_itemData.m_shared.m_foodRegen = ((regen == -99) ? component.m_itemData.m_shared.m_foodRegen : ((float)regen));
			component.m_itemData.m_shared.m_foodBurnTime = ((time == -99) ? component.m_itemData.m_shared.m_foodBurnTime : ((float)time));
		}
	}
	public class StatusEffectBuilder
	{
		public List<StatusEffect> statusEffects = new List<StatusEffect>();

		public void setShieldStatus(SE_LevelShield statusEffect, Sprite icon)
		{
			((StatusEffect)statusEffect).m_icon = icon;
			((StatusEffect)statusEffect).m_ttl = 40f;
			((Object)statusEffect).name = "SE_LevelShield";
			((StatusEffect)statusEffect).m_name = "Shield_MonsterRandomizer";
			((StatusEffect)statusEffect).m_tooltip = "You been shielded";
			((StatusEffect)statusEffect).m_activationAnimation = "";
			statusEffects.Add((StatusEffect)(object)statusEffect);
		}

		public void setBleedingStatus(SE_bleed statusEffect, Sprite icon)
		{
			((StatusEffect)statusEffect).m_icon = icon;
			((StatusEffect)statusEffect).m_ttl = 60f;
			((StatusEffect)statusEffect).m_tooltip = "You been slashed open. Any more cuts will hurt more";
			((StatusEffect)statusEffect).m_activationAnimation = "encumbered";
			statusEffects.Add((StatusEffect)(object)statusEffect);
		}

		public void setPiercedStatus(SE_pierced statusEffect, Sprite icon)
		{
			((StatusEffect)statusEffect).m_icon = icon;
			((StatusEffect)statusEffect).m_ttl = 60f;
			((StatusEffect)statusEffect).m_tooltip = "You been pierced. Another stab like that will be more fatal";
			((StatusEffect)statusEffect).m_activationAnimation = "encumbered";
			statusEffects.Add((StatusEffect)(object)statusEffect);
		}

		public void setCrushedStatus(SE_crushed statusEffect, Sprite icon)
		{
			((StatusEffect)statusEffect).m_icon = icon;
			((StatusEffect)statusEffect).m_ttl = 60f;
			((StatusEffect)statusEffect).m_tooltip = "Your bone was crushed. Another blunt hit will be fatal";
			((StatusEffect)statusEffect).m_activationAnimation = "encumbered";
			statusEffects.Add((StatusEffect)(object)statusEffect);
		}

		public void setBadgaesStatus(StatusEffect statusEffect, Sprite icon)
		{
			SE_Bandages sE_Bandages = (SE_Bandages)(object)statusEffect;
			((StatusEffect)sE_Bandages).m_icon = icon;
			((StatusEffect)sE_Bandages).m_name = "First Aid";
			((StatusEffect)sE_Bandages).m_category = "bandages";
			((Object)sE_Bandages).name = "Bandages";
			((StatusEffect)sE_Bandages).m_ttl = 120f;
			((StatusEffect)sE_Bandages).m_tooltip = "Applied first aid. This will help mend the pain";
			((SE_Stats)sE_Bandages).m_healthOverTimeInterval = 5f;
			((SE_Stats)sE_Bandages).m_healthOverTimeDuration = ((StatusEffect)sE_Bandages).m_ttl;
			((SE_Stats)sE_Bandages).m_healthOverTimeTickHP = 3f;
			((StatusEffect)sE_Bandages).m_activationAnimation = "equipping";
			statusEffects.Add((StatusEffect)(object)sE_Bandages);
		}

		public StatusEffect cloneShield(StatusEffect shield, int absorb, string name)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			SE_Shield val = (SE_Shield)shield.Clone();
			val.m_absorbDamage = absorb;
			((StatusEffect)val).m_name = name;
			((Object)val).name = name;
			return (StatusEffect)(object)val;
		}

		public static void setupVisualsForStatus(StatusEffect statusEffect, List<GameObject> list)
		{
			if ((Object)(object)statusEffect == (Object)null)
			{
				Debug.LogWarning((object)"Status Effect is null!");
				return;
			}
			switch (statusEffect.m_name)
			{
			case "Bleeding":
			{
				SE_bleed sE_bleed = (SE_bleed)(object)statusEffect;
				break;
			}
			case "Crushed":
			{
				SE_crushed sE_crushed = (SE_crushed)(object)statusEffect;
				break;
			}
			case "Pierced":
			{
				SE_pierced sE_pierced = (SE_pierced)(object)statusEffect;
				break;
			}
			case "Shield_MonsterRandomizer":
			{
				List<EffectData> list2 = new List<EffectData>();
				SE_LevelShield sE_LevelShield = (SE_LevelShield)(object)statusEffect;
				list2.Add(createEffectData(list, "fx_GoblinShieldBreak", attach: true, "", scale: true));
				list2.RemoveAll((EffectData x) => (Object)(object)x.m_prefab == (Object)null);
				sE_LevelShield.m_breakEffects.m_effectPrefabs = list2.ToArray();
				List<EffectData> list3 = new List<EffectData>();
				list3.Add(createEffectData(list, "fx_GoblinShieldHit", attach: true, "", scale: true));
				list3.RemoveAll((EffectData x) => (Object)(object)x.m_prefab == (Object)null);
				sE_LevelShield.m_hitEffects.m_effectPrefabs = list3.ToArray();
				List<EffectData> list4 = new List<EffectData>();
				list4.Add(createEffectData(list, "vfx_GoblinShield", attach: true, "", scale: true));
				list4.RemoveAll((EffectData x) => (Object)(object)x.m_prefab == (Object)null);
				((StatusEffect)sE_LevelShield).m_startEffects.m_effectPrefabs = list4.ToArray();
				break;
			}
			}
		}

		private static EffectData createEffectData(List<GameObject> list, string name, bool attach = false, string attachName = "", bool scale = false)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			EffectData val = new EffectData();
			val.m_variant = -1;
			val.m_prefab = FindEffect(list, name);
			val.m_enabled = true;
			val.m_attach = attach;
			val.m_scale = scale;
			val.m_childTransform = attachName;
			return val;
		}

		private static GameObject FindEffect(List<GameObject> list, string name)
		{
			GameObject val = list.Find((GameObject x) => ((Object)x).name == name);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			return null;
		}
	}
	public class SE_Bandages : SE_Stats
	{
		[Header("SE_Bandages")]
		public float m_waterDamage;

		public float m_damageInterval = 0.5f;

		private float m_timer;

		public override void Setup(Character character)
		{
			((SE_Stats)this).Setup(character);
		}

		public override void UpdateStatusEffect(float dt)
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			((SE_Stats)this).UpdateStatusEffect(dt);
			if ((double)base.m_tickInterval > 0.0)
			{
				base.m_tickTimer += dt;
				if ((double)base.m_tickTimer >= (double)base.m_tickInterval)
				{
					base.m_tickTimer = 0f;
					if ((double)((StatusEffect)this).m_character.GetHealthPercentage() >= (double)base.m_healthPerTickMinHealthPercentage)
					{
						if ((double)base.m_healthPerTick > 0.0)
						{
							((StatusEffect)this).m_character.Heal(base.m_healthPerTick, true);
						}
						else
						{
							((StatusEffect)this).m_character.Damage(new HitData
							{
								m_damage = 
								{
									m_damage = 0f - base.m_healthPerTick
								},
								m_point = ((StatusEffect)this).m_character.GetTopPoint()
							});
						}
					}
				}
			}
			if ((double)base.m_healthOverTimeTicks > 0.0)
			{
				base.m_healthOverTimeTimer += dt;
				if ((double)base.m_healthOverTimeTimer > (double)base.m_healthOverTimeInterval)
				{
					base.m_healthOverTimeTimer = 0f;
					base.m_healthOverTimeTicks -= 1f;
					((StatusEffect)this).m_character.Heal(base.m_healthOverTimeTickHP, true);
				}
			}
			if (((StatusEffect)this).m_character.GetSEMan().HaveStatusEffect("Pierced") || ((StatusEffect)this).m_character.GetSEMan().HaveStatusEffect("Bleeding") || ((StatusEffect)this).m_character.GetSEMan().HaveStatusEffect("Crushed"))
			{
				((StatusEffect)this).m_time = ((StatusEffect)this).m_time + dt * 10f;
			}
			((StatusEffect)this).m_time = ((StatusEffect)this).m_time + dt * 50f;
		}
	}
	public class SE_LevelShield : StatusEffect
	{
		[Header("SE_LevelShield")]
		public float m_baseAbsorbDamage = 10f;

		private int level = 1;

		private int bonusShield = 10;

		public float m_absorbDamage = 20f;

		public SkillType m_levelUpSkillOnBreak;

		public float m_levelUpSkillFactor = 1f;

		public int m_ttlPerItemLevel;

		public float m_absorbDamagePerSkillLevel;

		public EffectList m_breakEffects = new EffectList();

		public EffectList m_hitEffects = new EffectList();

		private float m_totalAbsorbDamage;

		private float m_damage;

		public override void Setup(Character character)
		{
			((Object)this).name = "SE_LevelShield";
			base.m_name = "Shield_MonsterRandomizer";
			((StatusEffect)this).Setup(character);
			level = base.m_character.m_level;
			CharacterType();
		}

		private void CharacterType()
		{
			switch (((Object)((Component)base.m_character).gameObject).name)
			{
			case "Skeleton_NoArcher":
			case "Skeleton":
				bonusShield = 15;
				break;
			case "Skeleton_Poison":
				bonusShield = 20;
				break;
			case "Draugr":
			case "Draugr_Ranged":
				bonusShield = 25;
				break;
			case "Draugr_Elite":
				bonusShield = 30;
				break;
			case "Goblin":
			case "GoblinArcher":
			case "GoblinShaman":
				bonusShield = 35;
				break;
			case "Surtling":
				bonusShield = 20;
				break;
			}
			m_absorbDamage = (float)level * ((float)bonusShield + m_baseAbsorbDamage);
		}

		public override bool IsDone()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Invalid comparison between Unknown and I4
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			if ((double)m_damage <= (double)m_totalAbsorbDamage)
			{
				return ((StatusEffect)this).IsDone();
			}
			m_breakEffects.Create(base.m_character.GetCenterPoint(), ((Component)base.m_character).transform.rotation, ((Component)base.m_character).transform, base.m_character.GetRadius() * 2f, -1);
			if ((int)m_levelUpSkillOnBreak > 0)
			{
				Skills skills = base.m_character.GetSkills();
				if ((Object)(object)skills != (Object)null && Object.op_Implicit((Object)(object)skills))
				{
					skills.RaiseSkill(m_levelUpSkillOnBreak, m_levelUpSkillFactor);
					Terminal.Log((object)$"{base.m_name} is leveling up {m_levelUpSkillOnBreak} at factor {m_levelUpSkillFactor}");
				}
			}
			return true;
		}

		public override void OnDamaged(HitData hit, Character attacker)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			m_damage += hit.GetTotalDamage();
			hit.ApplyModifier(0f);
			m_hitEffects.Create(hit.m_point, Quaternion.LookRotation(-hit.m_dir), ((Component)base.m_character).transform, 1f, -1);
		}

		public override void SetLevel(int itemLevel, float skillLevel)
		{
			if (m_ttlPerItemLevel > 0)
			{
				base.m_ttl = m_ttlPerItemLevel * itemLevel;
			}
			m_totalAbsorbDamage = m_absorbDamage + m_absorbDamagePerSkillLevel * skillLevel;
			Terminal.Log((object)$"Shield setting itemlevel: {itemLevel} = ttl: {base.m_ttl}, skilllevel: {skillLevel} = absorb: {m_totalAbsorbDamage}");
			((StatusEffect)this).SetLevel(itemLevel, skillLevel);
		}

		public override string GetTooltipString()
		{
			return ((StatusEffect)this).GetTooltipString() + "\n$se_shield_ttl <color=orange>" + base.m_ttl.ToString("0") + "</color>\n$se_shield_damage <color=orange>" + m_totalAbsorbDamage.ToString("0") + "</color>";
		}
	}
	public class SE_bleed : StatusEffect
	{
		[Header("SE_bleed")]
		private float m_timer;

		public List<DamageModPair> m_mods = new List<DamageModPair>();

		public void Awake()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			base.m_name = "Bleeding";
			((Object)this).name = "Bleeding";
			DamageModPair item = default(DamageModPair);
			item.m_type = (DamageType)2;
			item.m_modifier = (DamageModifier)2;
			m_mods.Add(item);
		}

		public override void Setup(Character character)
		{
			((StatusEffect)this).Setup(character);
		}

		public override void UpdateStatusEffect(float dt)
		{
			((StatusEffect)this).UpdateStatusEffect(dt);
			if (base.m_character.GetSEMan().HaveStatusEffect("Bandages"))
			{
				base.m_time += dt * 5f;
			}
			base.m_ttl -= dt;
			if (!((double)base.m_ttl > 0.0))
			{
			}
		}

		public override void ModifyDamageMods(ref DamageModifiers modifiers)
		{
			((DamageModifiers)(ref modifiers)).Apply(m_mods);
		}
	}
	public class SE_BlockStamUse : StatusEffect
	{
		public float m_bonus = 0f;

		public float m_baseConsumption = 0f;

		public void Awake()
		{
			base.m_name = "BlockStaminaUse";
			((Object)this).name = "BlockStaminaUse";
			base.m_tooltip = "Block Stamina Use decreased by " + m_bonus + "x";
		}

		public void setBlockStaminaUse(float bonus)
		{
			m_bonus = bonus;
			base.m_tooltip = "Block Stamina Use decreased by " + bonus + "x";
		}

		public float getBlockStaminaUse()
		{
			return m_bonus;
		}
	}
	public class SE_BonusHealth : StatusEffect
	{
		public float m_bonus = 0f;

		public void Awake()
		{
			base.m_name = "BonusHealth";
			((Object)this).name = "BonusHealth";
			base.m_tooltip = "Health is increased by " + (m_bonus + 1f) + " points.";
		}

		public void SetHealthBonus(float bonus)
		{
			m_bonus = bonus;
			base.m_tooltip = "Health is increased by " + (m_bonus + 1f) + " points.";
		}

		public float getHealthBonus()
		{
			return m_bonus;
		}
	}
	public class SE_BonusHealthRegen : StatusEffect
	{
		public float m_bonus = 0f;

		public void Awake()
		{
			base.m_name = "HpRegen";
			((Object)this).name = "HpRegen";
			base.m_tooltip = "Health Regen is increased by " + (m_bonus + 1f) + "x.";
		}

		public void setHealPercent(float bonus)
		{
			m_bonus = bonus;
			base.m_tooltip = "Health Regen is increased by " + (m_bonus + 1f) + "x.";
		}

		public float getHealPercent()
		{
			return m_bonus;
		}
	}
	public class SE_BonusStamina : StatusEffect
	{
		public float m_bonus = 0f;

		public void Awake()
		{
			base.m_name = "BonusStamina";
			((Object)this).name = "BonusStamina";
			base.m_tooltip = "Stamina is increased by " + (m_bonus + 1f) + " points.";
		}

		public void SetStaminaBonus(float bonus)
		{
			m_bonus = bonus;
			base.m_tooltip = "Stamina is increased by " + (m_bonus + 1f) + " points.";
		}

		public float GetStaminaBonus()
		{
			return m_bonus;
		}
	}
	public class SE_BonusStaminaRegen : StatusEffect
	{
		public float m_bonus = 0f;

		public void Awake()
		{
			base.m_name = "StaminaRegen";
			((Object)this).name = "StaminaRegen";
			base.m_tooltip = "Stamina Regen is increased by " + m_bonus + "%.";
		}

		public void SetRegenPercent(float bonus)
		{
			m_bonus = bonus;
			base.m_tooltip = "Stamina Regen is increased by " + m_bonus + "%.";
		}

		public float GetRegenPercent()
		{
			return m_bonus;
		}
	}
	public class SE_crushed : StatusEffect
	{
		[Header("SE_crushed")]
		public List<DamageModPair> m_mods = new List<DamageModPair>();

		private float m_timer;

		public float m_speedModifier;

		public void Awake()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			base.m_name = "Crushed";
			((Object)this).name = "Crushed";
			DamageModPair item = default(DamageModPair);
			item.m_type = (DamageType)1;
			item.m_modifier = (DamageModifier)2;
			m_mods.Add(item);
		}

		public override void Setup(Character character)
		{
			((StatusEffect)this).Setup(character);
		}

		public override void UpdateStatusEffect(float dt)
		{
			((StatusEffect)this).UpdateStatusEffect(dt);
			if (base.m_character.GetSEMan().HaveStatusEffect("Bandages"))
			{
				base.m_time += dt * 5f;
			}
			base.m_ttl -= dt;
			if (!((double)base.m_ttl > 0.0))
			{
			}
		}

		public override void ModifyDamageMods(ref DamageModifiers modifiers)
		{
			((DamageModifiers)(ref modifiers)).Apply(m_mods);
		}

		public override void ModifySpeed(float baseSpeed, ref float speed)
		{
			if (base.m_character.IsSwimming())
			{
				speed += (float)((double)baseSpeed * (double)m_speedModifier * 0.5);
			}
			else
			{
				speed += baseSpeed * m_speedModifier;
			}
			if (!((double)speed >= 0.0))
			{
				speed = 0f;
			}
		}
	}
	public class SE_pierced : StatusEffect
	{
		[Header("SE_pierced")]
		private float m_timer;

		public List<DamageModPair> m_mods = new List<DamageModPair>();

		public void Awake()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			base.m_name = "Pierced";
			((Object)this).name = "Pierced";
			DamageModPair item = default(DamageModPair);
			item.m_type = (DamageType)4;
			item.m_modifier = (DamageModifier)2;
			m_mods.Add(item);
		}

		public override void Setup(Character character)
		{
			((StatusEffect)this).Setup(character);
		}

		public override void UpdateStatusEffect(float dt)
		{
			((StatusEffect)this).UpdateStatusEffect(dt);
			if (base.m_character.GetSEMan().HaveStatusEffect("Bandages"))
			{
				base.m_time += dt * 5f;
			}
			base.m_ttl -= dt;
			if (!((double)base.m_ttl > 0.0))
			{
			}
		}

		public override void ModifyDamageMods(ref DamageModifiers modifiers)
		{
			((DamageModifiers)(ref modifiers)).Apply(m_mods);
		}
	}
}

BepInEx/plugins/Barquero.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("AichoGuardian")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AichoGuardian")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("D28110A9-E229-4700-AD4D-DCD37486A82B")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BoatLoanMod;

[BepInPlugin("com.nazhi.boatloanmod", "Boat Loan Mod", "2.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class BoatLoanPlugin : BaseUnityPlugin
{
	public const string ModGuid = "com.nazhi.boatloanmod";

	public const string ModName = "Boat Loan Mod";

	public const string ModVersion = "2.0.0";

	public static BoatLoanPlugin Instance;

	private Harmony _harmony;

	private LoanNpcPanel _panel;

	private GameObject _boatPrefab;

	private GameObject _jaroldPrefab;

	private ConfigEntry<float> _boatLifetime;

	private ConfigEntry<float> _waterSearchRadius;

	private bool _prefabsReady;

	public ManualLogSource Logger => ((BaseUnityPlugin)this).Logger;

	private void Awake()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		Instance = this;
		_harmony = new Harmony("com.nazhi.boatloanmod");
		_harmony.PatchAll();
		_boatLifetime = ((BaseUnityPlugin)this).Config.Bind<float>("Barco", "BoatLifetime", 30f, "Segundos que dura el barco prestado antes de desaparecer.");
		_waterSearchRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Barco", "WaterSearchRadius", 60f, "Radio máximo (en metros) en el que se busca agua para spawnear el barco.");
		PrefabManager.OnVanillaPrefabsAvailable += RegisterJarold;
		GUIManager.OnCustomGUIAvailable += OnCustomGUIAvailable;
		Logger.LogInfo((object)"Boat Loan Mod v2.0.0 loaded");
	}

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

	private void RegisterJarold()
	{
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Expected O, but got Unknown
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Expected O, but got Unknown
		try
		{
			GameObject prefab = PrefabManager.Instance.GetPrefab("MLNPC_Male0");
			if ((Object)(object)prefab == (Object)null)
			{
				Logger.LogError((object)"No se encontró MLNPC_Male0.");
				return;
			}
			_boatPrefab = PrefabManager.Instance.GetPrefab("Karve");
			if ((Object)(object)_boatPrefab == (Object)null)
			{
				Logger.LogError((object)"No se encontró el prefab Karve.");
			}
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("Jarold_BLM", prefab);
			Character component = val.GetComponent<Character>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_speed = 0f;
				component.m_walkSpeed = 0f;
				component.m_crouchSpeed = 0f;
				component.m_runSpeed = 0f;
				component.m_swimSpeed = 0f;
				component.m_turnSpeed = 0f;
				component.m_runTurnSpeed = 0f;
				component.m_flySlowSpeed = 0f;
				component.m_flyFastSpeed = 0f;
				component.m_flyTurnSpeed = 0f;
				component.m_acceleration = 0f;
				component.m_jumpForce = 0f;
				component.m_swimTurnSpeed = 0f;
			}
			BaseAI component2 = val.GetComponent<BaseAI>();
			if ((Object)(object)component2 != (Object)null)
			{
				((Behaviour)component2).enabled = false;
			}
			MonsterAI component3 = val.GetComponent<MonsterAI>();
			if ((Object)(object)component3 != (Object)null)
			{
				((Behaviour)component3).enabled = false;
			}
			CustomCreature val2 = new CustomCreature(val, true, new CreatureConfig
			{
				Faction = (Faction)10
			});
			CreatureManager.Instance.AddCreature(val2);
			_jaroldPrefab = val;
			_prefabsReady = true;
			Logger.LogInfo((object)"Jarold_BLM registrado como CustomCreature estático.");
		}
		catch (Exception arg)
		{
			Logger.LogError((object)$"RegisterJarold: {arg}");
		}
		finally
		{
			PrefabManager.OnVanillaPrefabsAvailable -= RegisterJarold;
		}
	}

	private void Update()
	{
		if (!((Object)(object)Player.m_localPlayer == (Object)null) && _panel != null && _panel.IsVisible && Input.GetKeyDown((KeyCode)27))
		{
			_panel.HideAndResetCurrentNpc();
		}
	}

	private void TrySpawnJarold()
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: 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_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_jaroldPrefab == (Object)null)
		{
			((Character)Player.m_localPlayer).Message((MessageType)2, "Prefab de Jarold no disponible aún.", 0, (Sprite)null);
			return;
		}
		if (JaroldExistsInWorld())
		{
			((Character)Player.m_localPlayer).Message((MessageType)2, "Jarold ya está en el mundo.", 0, (Sprite)null);
			return;
		}
		Vector3 position = ((Component)Player.m_localPlayer).transform.position;
		Vector3 forward = ((Component)Player.m_localPlayer).transform.forward;
		Vector3 val = position + forward * 3f;
		if ((Object)(object)ZoneSystem.instance != (Object)null)
		{
			val.y = ZoneSystem.instance.GetGroundHeight(val) + 0.1f;
		}
		Quaternion val2 = Quaternion.LookRotation(-forward);
		ZNetScene.instance.SpawnObject(val, val2, _jaroldPrefab);
		((Character)Player.m_localPlayer).Message((MessageType)2, "Jarold El Mercante ha aparecido.", 0, (Sprite)null);
		Logger.LogInfo((object)$"Jarold spawneado en {val}");
	}

	private void TryDespawnJarold()
	{
		_panel?.HideAndResetCurrentNpc();
		int num = 0;
		foreach (Character item in Character.GetAllCharacters().ToList())
		{
			if ((Object)(object)item == (Object)null)
			{
				continue;
			}
			ZNetView component = ((Component)item).GetComponent<ZNetView>();
			if (!((Object)(object)component == (Object)null) && component.IsValid() && component.GetZDO().GetPrefab() == StringExtensionMethods.GetStableHashCode("Jarold_BLM"))
			{
				try
				{
					((Component)item).gameObject.SetActive(false);
					ZNetScene.instance.Destroy(((Component)item).gameObject);
					num++;
				}
				catch (Exception ex)
				{
					Logger.LogWarning((object)("TryDespawnJarold (scene): " + ex.Message));
				}
			}
		}
		List<ZDO> list = new List<ZDO>();
		int num2 = 0;
		while (!ZDOMan.instance.GetAllZDOsWithPrefabIterative("Jarold_BLM", list, ref num2))
		{
		}
		foreach (ZDO item2 in list)
		{
			try
			{
				item2.SetOwner(ZDOMan.GetSessionID());
				ZDOMan.instance.DestroyZDO(item2);
				num++;
			}
			catch (Exception ex2)
			{
				Logger.LogWarning((object)("TryDespawnJarold (ZDO): " + ex2.Message));
			}
		}
		string text = ((num > 0) ? $"Jarold eliminado ({num})." : "No se encontró a Jarold en el mundo.");
		((Character)Player.m_localPlayer).Message((MessageType)2, text, 0, (Sprite)null);
		Logger.LogInfo((object)text);
	}

	private bool JaroldExistsInWorld()
	{
		foreach (Character allCharacter in Character.GetAllCharacters())
		{
			if (!((Object)(object)allCharacter == (Object)null))
			{
				ZNetView component = ((Component)allCharacter).GetComponent<ZNetView>();
				if ((Object)(object)component != (Object)null && component.IsValid() && component.GetZDO().GetPrefab() == StringExtensionMethods.GetStableHashCode("Jarold_BLM"))
				{
					return true;
				}
			}
		}
		List<ZDO> list = new List<ZDO>();
		int num = 0;
		while (!ZDOMan.instance.GetAllZDOsWithPrefabIterative("Jarold_BLM", list, ref num))
		{
		}
		return list.Count > 0;
	}

	private void OnCustomGUIAvailable()
	{
		RebuildPanel();
	}

	private void RebuildPanel()
	{
		if (GUIManager.Instance == null || (Object)(object)GUIManager.CustomGUIFront == (Object)null)
		{
			return;
		}
		try
		{
			_panel?.Destroy();
			_panel = null;
			_panel = new LoanNpcPanel(this, Logger);
			_panel.Build();
		}
		catch (Exception arg)
		{
			Logger.LogError((object)$"Error construyendo LoanNpcPanel: {arg}");
		}
	}

	private void EnsurePanelReady()
	{
		if (_panel == null || !_panel.IsValid)
		{
			RebuildPanel();
		}
	}

	public void OpenLoanUI(LoanNpcBehaviour npc)
	{
		EnsurePanelReady();
		if (_panel != null && _panel.IsValid)
		{
			_panel.Show(npc);
		}
	}

	public void CloseLoanUI()
	{
		_panel?.Hide();
	}

	public void RequestBoat(LoanNpcBehaviour npc)
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: 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)
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null)
		{
			CloseLoanUI();
			npc.ResetInteraction();
			return;
		}
		if ((Object)(object)_boatPrefab == (Object)null)
		{
			((Character)localPlayer).Message((MessageType)2, "No pude encontrar el prefab del barco.", 0, (Sprite)null);
			CloseLoanUI();
			npc.ResetInteraction();
			return;
		}
		if (WaterSpawnHelper.TryFindNearbyWaterPosition(((Component)localPlayer).transform.position, 12f, _waterSearchRadius.Value, out var result, ((Component)npc).transform.forward))
		{
			GameObject val = Object.Instantiate<GameObject>(_boatPrefab, result, Quaternion.LookRotation(((Component)localPlayer).transform.forward));
			Rigidbody component = val.GetComponent<Rigidbody>();
			if ((Object)(object)component != (Object)null)
			{
				component.linearVelocity = Vector3.zero;
				component.angularVelocity = Vector3.zero;
			}
			TemporaryBoat temporaryBoat = val.AddComponent<TemporaryBoat>();
			temporaryBoat.Setup(_boatLifetime.Value, Logger);
			((Character)localPlayer).Message((MessageType)2, $"¡Tienes {_boatLifetime.Value:F0} segundos con el barco!", 0, (Sprite)null);
		}
		else
		{
			((Character)localPlayer).Message((MessageType)2, "No encontré agua cercana para dejarte un barco.", 0, (Sprite)null);
		}
		CloseLoanUI();
		npc.ResetInteraction();
	}
}
public class LoanNpcBehaviour : MonoBehaviour, Interactable, Hoverable
{
	private BoatLoanPlugin _plugin;

	private bool _busy;

	public void Setup(BoatLoanPlugin plugin)
	{
		_plugin = plugin;
	}

	public string GetHoverName()
	{
		return "Jarold El Mercante";
	}

	public string GetHoverText()
	{
		return "<color=#E7C07A>Jarold El Mercante</color>\n[E] Hablar";
	}

	public bool Interact(Humanoid user, bool hold, bool alt)
	{
		if (hold)
		{
			return false;
		}
		if ((Object)(object)_plugin == (Object)null || (Object)(object)user != (Object)(object)Player.m_localPlayer || _busy)
		{
			return false;
		}
		_busy = true;
		_plugin.OpenLoanUI(this);
		return true;
	}

	public bool UseItem(Humanoid user, ItemData item)
	{
		return false;
	}

	public void ResetInteraction()
	{
		_busy = false;
	}
}
public static class NpcArmorApplier
{
	private static readonly string[] ChestKeywords = new string[4] { "chest", "body", "torso", "armor" };

	private static readonly string[] LegKeywords = new string[5] { "leg", "legs", "pants", "legitem", "legsitem" };

	public static bool ApplyArmor(GameObject npc, ManualLogSource logger)
	{
		if ((Object)(object)npc == (Object)null)
		{
			return false;
		}
		Humanoid val = npc.GetComponent<Humanoid>() ?? npc.GetComponentInChildren<Humanoid>();
		Component componentInChildren = npc.GetComponentInChildren(typeof(VisEquipment));
		PrefabManager instance = PrefabManager.Instance;
		GameObject val2 = ((instance != null) ? instance.GetPrefab("ArmorHarvester1") : null);
		ItemDrop itemDrop = (Object.op_Implicit((Object)(object)val2) ? val2.GetComponent<ItemDrop>() : null);
		List<string> candidates = BuildCandidates("ArmorHarvester1", val2, itemDrop);
		bool flag = false;
		bool flag2 = false;
		if ((Object)(object)val != (Object)null)
		{
			flag = TryApplyOnTarget(val, ChestKeywords, candidates, itemDrop, logger, "Humanoid");
			TryInvokeRefresh(val, logger);
		}
		if ((Object)(object)componentInChildren != (Object)null)
		{
			flag2 = TryApplyOnTarget(componentInChildren, ChestKeywords, candidates, itemDrop, logger, "VisEquipment");
			TryClearOnTarget(componentInChildren, LegKeywords, logger);
			TryInvokeRefresh(componentInChildren, logger);
		}
		return flag || flag2;
	}

	private static bool TryApplyOnTarget(object target, string[] keywords, List<string> candidates, ItemDrop itemDrop, ManualLogSource logger, string tag)
	{
		Type type = target.GetType();
		foreach (string value in keywords)
		{
			MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo in methods)
			{
				if (!methodInfo.Name.ToLowerInvariant().Contains(value))
				{
					continue;
				}
				ParameterInfo[] parameters = methodInfo.GetParameters();
				if (parameters.Length != 1)
				{
					continue;
				}
				try
				{
					Type parameterType = parameters[0].ParameterType;
					if (parameterType == typeof(string))
					{
						using List<string>.Enumerator enumerator = candidates.GetEnumerator();
						if (enumerator.MoveNext())
						{
							string current = enumerator.Current;
							methodInfo.Invoke(target, new object[1] { current });
							return true;
						}
					}
					if (parameterType == typeof(int))
					{
						using List<string>.Enumerator enumerator2 = candidates.GetEnumerator();
						if (enumerator2.MoveNext())
						{
							string current2 = enumerator2.Current;
							methodInfo.Invoke(target, new object[1] { StringExtensionMethods.GetStableHashCode(current2) });
							return true;
						}
					}
					if (typeof(ItemData).IsAssignableFrom(parameterType) && (Object)(object)itemDrop != (Object)null)
					{
						methodInfo.Invoke(target, new object[1] { itemDrop.m_itemData });
						return true;
					}
					if (typeof(GameObject).IsAssignableFrom(parameterType) && (Object)(object)itemDrop != (Object)null)
					{
						methodInfo.Invoke(target, new object[1] { ((Component)itemDrop).gameObject });
						return true;
					}
				}
				catch (Exception ex)
				{
					logger.LogWarning((object)("[" + tag + "] " + methodInfo.Name + ": " + ex.Message));
				}
			}
			FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				if (!fieldInfo.Name.ToLowerInvariant().Contains(value))
				{
					continue;
				}
				try
				{
					if (fieldInfo.FieldType == typeof(string))
					{
						fieldInfo.SetValue(target, candidates[0]);
						return true;
					}
					if (fieldInfo.FieldType == typeof(int))
					{
						fieldInfo.SetValue(target, StringExtensionMethods.GetStableHashCode(candidates[0]));
						return true;
					}
					if (typeof(ItemData).IsAssignableFrom(fieldInfo.FieldType) && (Object)(object)itemDrop != (Object)null)
					{
						fieldInfo.SetValue(target, itemDrop.m_itemData);
						return true;
					}
					if (typeof(GameObject).IsAssignableFrom(fieldInfo.FieldType) && (Object)(object)itemDrop != (Object)null)
					{
						fieldInfo.SetValue(target, ((Component)itemDrop).gameObject);
						return true;
					}
				}
				catch (Exception ex2)
				{
					logger.LogWarning((object)("[" + tag + "] field " + fieldInfo.Name + ": " + ex2.Message));
				}
			}
		}
		return false;
	}

	private static void TryClearOnTarget(object target, string[] keywords, ManualLogSource logger)
	{
		Type type = target.GetType();
		foreach (string value in keywords)
		{
			MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo in methods)
			{
				if (!methodInfo.Name.ToLowerInvariant().Contains(value))
				{
					continue;
				}
				ParameterInfo[] parameters = methodInfo.GetParameters();
				if (parameters.Length != 1)
				{
					continue;
				}
				try
				{
					Type parameterType = parameters[0].ParameterType;
					if (parameterType == typeof(string))
					{
						methodInfo.Invoke(target, new object[1] { "" });
						return;
					}
					if (parameterType == typeof(int))
					{
						methodInfo.Invoke(target, new object[1] { 0 });
						return;
					}
					if (!parameterType.IsValueType)
					{
						methodInfo.Invoke(target, new object[1]);
						return;
					}
				}
				catch
				{
				}
			}
			FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				if (!fieldInfo.Name.ToLowerInvariant().Contains(value))
				{
					continue;
				}
				try
				{
					if (fieldInfo.FieldType == typeof(string))
					{
						fieldInfo.SetValue(target, "");
						return;
					}
					if (fieldInfo.FieldType == typeof(int))
					{
						fieldInfo.SetValue(target, 0);
						return;
					}
					if (!fieldInfo.FieldType.IsValueType)
					{
						fieldInfo.SetValue(target, null);
						return;
					}
				}
				catch
				{
				}
			}
		}
	}

	private static void TryInvokeRefresh(object target, ManualLogSource logger)
	{
		string[] array = new string[6] { "SetupVisEquipment", "SetupEquipment", "UpdateEquipment", "UpdateEquipmentVisuals", "UpdateVisuals", "ResetCloth" };
		Type type = target.GetType();
		string[] array2 = array;
		foreach (string text in array2)
		{
			MethodInfo methodInfo = AccessTools.Method(type, text, (Type[])null, (Type[])null);
			if (!(methodInfo == null) && methodInfo.GetParameters().Length == 0)
			{
				try
				{
					methodInfo.Invoke(target, null);
				}
				catch
				{
				}
			}
		}
	}

	private static List<string> BuildCandidates(string raw, GameObject prefab, ItemDrop itemDrop)
	{
		List<string> list = new List<string>();
		if (!string.IsNullOrEmpty(raw))
		{
			list.Add(raw);
		}
		if ((Object)(object)prefab != (Object)null)
		{
			list.Add(((Object)prefab).name);
		}
		if (itemDrop?.m_itemData?.m_shared != null && !string.IsNullOrEmpty(itemDrop.m_itemData.m_shared.m_name))
		{
			list.Add(itemDrop.m_itemData.m_shared.m_name);
		}
		return list.Where((string x) => !string.IsNullOrEmpty(x)).Distinct().ToList();
	}
}
public class LoanNpcPanel
{
	private readonly BoatLoanPlugin _plugin;

	private readonly ManualLogSource _logger;

	private GameObject _panelRoot;

	private LoanNpcBehaviour _currentNpc;

	public bool IsVisible
	{
		get
		{
			if ((Object)(object)_panelRoot != (Object)null)
			{
				return _panelRoot.activeSelf;
			}
			return false;
		}
	}

	public bool IsValid => (Object)(object)_panelRoot != (Object)null;

	public LoanNpcPanel(BoatLoanPlugin plugin, ManualLogSource logger)
	{
		_plugin = plugin;
		_logger = logger;
	}

	public void Build()
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Expected O, but got Unknown
		//IL_0074: 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_009e: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: 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_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0289: Unknown result type (might be due to invalid IL or missing references)
		//IL_0298: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: Unknown result type (might be due to invalid IL or missing references)
		//IL_031c: Unknown result type (might be due to invalid IL or missing references)
		//IL_032b: Unknown result type (might be due to invalid IL or missing references)
		//IL_036c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0385: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c7: Expected O, but got Unknown
		//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0440: Unknown result type (might be due to invalid IL or missing references)
		//IL_0459: Unknown result type (might be due to invalid IL or missing references)
		//IL_0465: Unknown result type (might be due to invalid IL or missing references)
		//IL_047d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0487: Expected O, but got Unknown
		if (GUIManager.Instance == null || (Object)(object)GUIManager.CustomGUIFront == (Object)null)
		{
			throw new Exception("GUIManager no disponible.");
		}
		_panelRoot = new GameObject("BoatLoanPanelRoot", new Type[1] { typeof(RectTransform) });
		_panelRoot.transform.SetParent(GUIManager.CustomGUIFront.transform, false);
		RectTransform component = _panelRoot.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0.5f, 0.5f);
		component.anchorMax = new Vector2(0.5f, 0.5f);
		component.pivot = new Vector2(0.5f, 0.5f);
		component.sizeDelta = new Vector2(760f, 580f);
		((Transform)component).localPosition = new Vector3(570f, 0f, 0f);
		GameObject val = GUIManager.Instance.CreateWoodpanel(_panelRoot.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 250f), 690f, 95f, false);
		((Object)val).name = "TopWoodPanel";
		SetWoodVisible(val);
		CreateOverlay(val.transform, "TopOverlay", new Color(0f, 0f, 0f, 0.85f));
		GUIManager.Instance.CreateText("Jarold El Mercante", val.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, GUIManager.Instance.NorseBold, 30, new Color(1f, 0.79f, 0.22f, 1f), true, Color.black, 560f, 42f, false).GetComponent<Text>().alignment = (TextAnchor)4;
		GameObject val2 = GUIManager.Instance.CreateWoodpanel(_panelRoot.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, -40f), 690f, 400f, false);
		((Object)val2).name = "BottomWoodPanel";
		SetWoodVisible(val2);
		CreateOverlay(val2.transform, "BottomOverlay", new Color(0f, 0f, 0f, 0.85f));
		Text component2 = GUIManager.Instance.CreateText("Hola ! Soy Jarold , ¿Cómo te puedo ayudar?", val2.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -60f), GUIManager.Instance.AveriaSerifBold, 22, new Color(0.96f, 0.93f, 0.86f, 1f), true, Color.black, 580f, 60f, false).GetComponent<Text>();
		component2.alignment = (TextAnchor)1;
		component2.horizontalOverflow = (HorizontalWrapMode)0;
		component2.verticalOverflow = (VerticalWrapMode)1;
		GameObject val3 = GUIManager.Instance.CreateButton("Necesito un Barco", val2.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 30f), 470f, 60f);
		((Object)val3).name = "RentButton";
		Button component3 = val3.GetComponent<Button>();
		ApplyColors(component3, new Color(0.35f, 1f, 0.35f, 1f), new Color(0.18f, 0.82f, 0.18f, 1f));
		StyleText(val3, new Color(1f, 0.9f, 0.45f, 1f));
		((UnityEvent)component3.onClick).AddListener((UnityAction)delegate
		{
			if ((Object)(object)_currentNpc != (Object)null)
			{
				_plugin.RequestBoat(_currentNpc);
			}
		});
		GameObject val4 = GUIManager.Instance.CreateButton("Nada, lo siento", val2.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, -40f), 470f, 56f);
		((Object)val4).name = "CloseButton";
		Button component4 = val4.GetComponent<Button>();
		ApplyColors(component4, new Color(1f, 0.3f, 0.3f, 1f), new Color(0.82f, 0.12f, 0.12f, 1f));
		StyleText(val4, Color.white);
		((UnityEvent)component4.onClick).AddListener(new UnityAction(HideAndResetCurrentNpc));
		_panelRoot.SetActive(false);
	}

	private static void SetWoodVisible(GameObject obj)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		Image component = obj.GetComponent<Image>();
		if ((Object)(object)component != (Object)null)
		{
			((Graphic)component).color = Color.white;
		}
	}

	private static void CreateOverlay(Transform parent, string name, Color color)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: 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_0083: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name, new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val.transform.SetParent(parent, false);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = Vector2.zero;
		component.anchorMax = Vector2.one;
		component.offsetMin = new Vector2(10f, 10f);
		component.offsetMax = new Vector2(-10f, -10f);
		Image component2 = val.GetComponent<Image>();
		((Graphic)component2).color = color;
		((Graphic)component2).raycastTarget = false;
		val.transform.SetAsFirstSibling();
	}

	private static void ApplyColors(Button btn, Color hover, Color pressed)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: 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)
		ColorBlock valheimButtonColorBlock = GUIManager.Instance.ValheimButtonColorBlock;
		((ColorBlock)(ref valheimButtonColorBlock)).normalColor = Color.white;
		((ColorBlock)(ref valheimButtonColorBlock)).highlightedColor = hover;
		((ColorBlock)(ref valheimButtonColorBlock)).pressedColor = pressed;
		((ColorBlock)(ref valheimButtonColorBlock)).selectedColor = hover;
		((ColorBlock)(ref valheimButtonColorBlock)).disabledColor = new Color(0.6f, 0.6f, 0.6f, 1f);
		((ColorBlock)(ref valheimButtonColorBlock)).colorMultiplier = 1f;
		((ColorBlock)(ref valheimButtonColorBlock)).fadeDuration = 0.08f;
		((Selectable)btn).colors = valheimButtonColorBlock;
	}

	private static void StyleText(GameObject btn, Color color)
	{
		//IL_0013: 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_0064: Unknown result type (might be due to invalid IL or missing references)
		Text componentInChildren = btn.GetComponentInChildren<Text>(true);
		if (!((Object)(object)componentInChildren == (Object)null))
		{
			((Graphic)componentInChildren).color = color;
			componentInChildren.font = GUIManager.Instance.AveriaSerifBold;
			componentInChildren.fontSize = 24;
			componentInChildren.alignment = (TextAnchor)4;
			Outline val = ((Component)componentInChildren).GetComponent<Outline>() ?? ((Component)componentInChildren).gameObject.AddComponent<Outline>();
			((Shadow)val).effectColor = Color.black;
			((Shadow)val).effectDistance = new Vector2(1f, -1f);
		}
	}

	public void Show(LoanNpcBehaviour npc)
	{
		if (!((Object)(object)_panelRoot == (Object)null))
		{
			_currentNpc = npc;
			_panelRoot.SetActive(true);
			GUIManager.BlockInput(true);
		}
	}

	public void Hide()
	{
		if (!((Object)(object)_panelRoot == (Object)null))
		{
			_panelRoot.SetActive(false);
			GUIManager.BlockInput(false);
			_currentNpc = null;
		}
	}

	public void HideAndResetCurrentNpc()
	{
		_currentNpc?.ResetInteraction();
		Hide();
	}

	public void Destroy()
	{
		if ((Object)(object)_panelRoot != (Object)null)
		{
			Object.Destroy((Object)(object)_panelRoot);
			_panelRoot = null;
		}
	}
}
public class TemporaryBoat : MonoBehaviour
{
	private float _lifetime;

	private float _elapsed;

	private ManualLogSource _logger;

	private bool _destroyed;

	public void Setup(float lifetime, ManualLogSource logger)
	{
		_lifetime = lifetime;
		_logger = logger;
		WearNTear component = ((Component)this).GetComponent<WearNTear>();
		if ((Object)(object)component != (Object)null)
		{
			component.m_health = 1E+09f;
			((Behaviour)component).enabled = false;
		}
	}

	private void Update()
	{
		if (_destroyed)
		{
			return;
		}
		_elapsed += Time.deltaTime;
		if (_elapsed >= _lifetime - 5f && _elapsed - Time.deltaTime < _lifetime - 5f)
		{
			Player localPlayer = Player.m_localPlayer;
			if (localPlayer != null)
			{
				((Character)localPlayer).Message((MessageType)2, "¡El barco desaparecerá en 5 segundos!", 0, (Sprite)null);
			}
		}
		if (_elapsed >= _lifetime)
		{
			_destroyed = true;
			DestroyBoatNoDrops();
		}
	}

	private void DestroyBoatNoDrops()
	{
		try
		{
			DropOnDestroyed[] componentsInChildren = ((Component)this).GetComponentsInChildren<DropOnDestroyed>(true);
			foreach (DropOnDestroyed val in componentsInChildren)
			{
				((Behaviour)val).enabled = false;
			}
			Container[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Container>(true);
			foreach (Container val2 in componentsInChildren2)
			{
				((Behaviour)val2).enabled = false;
			}
			Player localPlayer = Player.m_localPlayer;
			if (localPlayer != null)
			{
				((Character)localPlayer).Message((MessageType)2, "El barco prestado ha desaparecido.", 0, (Sprite)null);
			}
			ZNetView component = ((Component)this).GetComponent<ZNetView>();
			if ((Object)(object)component != (Object)null && component.IsValid())
			{
				ZNetScene.instance.Destroy(((Component)this).gameObject);
				return;
			}
			((Component)this).gameObject.SetActive(false);
			Object.Destroy((Object)(object)((Component)this).gameObject, 0.1f);
		}
		catch (Exception arg)
		{
			ManualLogSource logger = _logger;
			if (logger != null)
			{
				logger.LogError((object)$"TemporaryBoat: {arg}");
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}
public static class WaterSpawnHelper
{
	public static bool TryFindNearbyWaterPosition(Vector3 center, float minRadius, float maxRadius, out Vector3 result, Vector3 preferredDirection = default(Vector3))
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: 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_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_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: 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_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: 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)
		result = Vector3.zero;
		if ((Object)(object)ZoneSystem.instance == (Object)null)
		{
			return false;
		}
		if (preferredDirection != Vector3.zero)
		{
			preferredDirection.y = 0f;
			((Vector3)(ref preferredDirection)).Normalize();
			for (int i = 0; i < 20; i++)
			{
				float num = Mathf.Lerp(minRadius, maxRadius, (float)i / 19f);
				Vector3 val = center + preferredDirection * num;
				float groundHeight = ZoneSystem.instance.GetGroundHeight(val);
				float liquidLevel = Floating.GetLiquidLevel(val, 1f, (LiquidType)0);
				if (!(liquidLevel <= -9999f) && !(liquidLevel - groundHeight < 2.5f))
				{
					result = new Vector3(val.x, liquidLevel + 0.35f, val.z);
					return true;
				}
			}
			return false;
		}
		for (int j = 0; j < 10; j++)
		{
			float num2 = Mathf.Lerp(minRadius, maxRadius, (float)j / 9f);
			for (int k = 0; k < 36; k++)
			{
				Vector3 val2 = center + Quaternion.Euler(0f, 10f * (float)k, 0f) * Vector3.forward * num2;
				float groundHeight2 = ZoneSystem.instance.GetGroundHeight(val2);
				float liquidLevel2 = Floating.GetLiquidLevel(val2, 1f, (LiquidType)0);
				if (!(liquidLevel2 <= -9999f) && !(liquidLevel2 - groundHeight2 < 2.5f))
				{
					result = new Vector3(val2.x, liquidLevel2 + 0.35f, val2.z);
					return true;
				}
			}
		}
		return false;
	}
}
[HarmonyPatch(typeof(Humanoid), "Awake")]
public static class Humanoid_Awake_Patch
{
	[CompilerGenerated]
	private sealed class <InitJaroldDelayed>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Humanoid humanoid;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <InitJaroldDelayed>d__1(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = null;
				<>1__state = 1;
				return true;
			case 1:
			{
				<>1__state = -1;
				if ((Object)(object)humanoid == (Object)null)
				{
					return false;
				}
				ZNetView component = ((Component)humanoid).GetComponent<ZNetView>();
				if ((Object)(object)component == (Object)null || !component.IsValid())
				{
					return false;
				}
				if (component.GetZDO().GetPrefab() != StringExtensionMethods.GetStableHashCode("Jarold_BLM"))
				{
					return false;
				}
				GameObject gameObject = ((Component)humanoid).gameObject;
				LoanNpcBehaviour loanNpcBehaviour = gameObject.GetComponent<LoanNpcBehaviour>() ?? gameObject.AddComponent<LoanNpcBehaviour>();
				loanNpcBehaviour.Setup(BoatLoanPlugin.Instance);
				Character component2 = gameObject.GetComponent<Character>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.m_speed = 0f;
					component2.m_walkSpeed = 0f;
					component2.m_crouchSpeed = 0f;
					component2.m_runSpeed = 0f;
					component2.m_swimSpeed = 0f;
					component2.m_turnSpeed = 0f;
					component2.m_runTurnSpeed = 0f;
					component2.m_flySlowSpeed = 0f;
					component2.m_flyFastSpeed = 0f;
					component2.m_flyTurnSpeed = 0f;
					component2.m_acceleration = 0f;
					component2.m_jumpForce = 0f;
					component2.m_swimTurnSpeed = 0f;
				}
				BaseAI component3 = gameObject.GetComponent<BaseAI>();
				if ((Object)(object)component3 != (Object)null)
				{
					((Behaviour)component3).enabled = false;
				}
				MonsterAI component4 = gameObject.GetComponent<MonsterAI>();
				if ((Object)(object)component4 != (Object)null)
				{
					((Behaviour)component4).enabled = false;
				}
				NpcArmorApplier.ApplyArmor(gameObject, BoatLoanPlugin.Instance.Logger);
				BoatLoanPlugin.Instance.Logger.LogInfo((object)"Jarold inicializado en escena.");
				return false;
			}
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private static void Postfix(Humanoid __instance)
	{
		if (!((Object)(object)__instance == (Object)null) && !((Object)(object)BoatLoanPlugin.Instance == (Object)null))
		{
			((MonoBehaviour)BoatLoanPlugin.Instance).StartCoroutine(InitJaroldDelayed(__instance));
		}
	}

	[IteratorStateMachine(typeof(<InitJaroldDelayed>d__1))]
	private static IEnumerator InitJaroldDelayed(Humanoid humanoid)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <InitJaroldDelayed>d__1(0)
		{
			humanoid = humanoid
		};
	}
}

BepInEx/plugins/Eikthyr.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Utils;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("AichoGuardian")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AichoGuardian")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("D28110A9-E229-4700-AD4D-DCD37486A82B")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace EikthyrTracker;

[BepInPlugin("com.tumod.eikthyrtracker", "EikthyrTracker", "3.7.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class EikthyrTrackerPlugin : BaseUnityPlugin
{
	public const string PluginGUID = "com.tumod.eikthyrtracker";

	public const string PluginName = "EikthyrTracker";

	public const string PluginVersion = "3.7.0";

	internal static ManualLogSource Log;

	private Harmony _harmony;

	private void Awake()
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		Log.LogInfo((object)"[EikthyrTracker] cargando...");
		_harmony = new Harmony("com.tumod.eikthyrtracker");
		_harmony.PatchAll(Assembly.GetExecutingAssembly());
		Log.LogInfo((object)"[EikthyrTracker] Harmony cargado correctamente.");
	}

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

	internal static bool IsEikthyr(Character c)
	{
		if (!Object.op_Implicit((Object)(object)c))
		{
			return false;
		}
		return Utils.GetPrefabName(((Component)c).gameObject) == "Eikthyr";
	}
}
[HarmonyPatch(typeof(ZNet), "Start")]
public static class Patch_ZNet_Start_RPCInit
{
	private static void Postfix()
	{
		if (ZRoutedRpc.instance == null)
		{
			EikthyrTrackerPlugin.Log.LogWarning((object)"[EikthyrTracker] ZRoutedRpc no disponible en ZNet.Start.");
			return;
		}
		RPC.RegisterRPCs();
		PhaseSystem.StartMonitoring();
		ManualLogSource log = EikthyrTrackerPlugin.Log;
		ZNet instance = ZNet.instance;
		log.LogInfo((object)$"[EikthyrTracker] RPCs registrados | isServer={((instance != null) ? new bool?(instance.IsServer()) : null)}");
	}
}
public static class AttackClients
{
	[CompilerGenerated]
	private sealed class <CoLightningRays>d__7 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Vector3 bossPos;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <CoLightningRays>d__7(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			if (<>1__state != 0)
			{
				return false;
			}
			<>1__state = -1;
			ZNetScene instance = ZNetScene.instance;
			GameObject val = ((instance != null) ? instance.GetPrefab("lightningAOE") : null);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			GameObject val2 = Object.Instantiate<GameObject>(val, bossPos, Quaternion.identity);
			ParticleSystem[] componentsInChildren = val2.GetComponentsInChildren<ParticleSystem>();
			foreach (ParticleSystem val3 in componentsInChildren)
			{
				MainModule main = val3.main;
				((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Color.cyan);
			}
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <CoLightningRaysVisuals>d__8 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public List<Vector3> group1;

		public List<Vector3> group2;

		private List<GameObject> <circles1>5__2;

		private List<GameObject> <circles2>5__3;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <CoLightningRaysVisuals>d__8(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<circles1>5__2 = null;
			<circles2>5__3 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_00e3: 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_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: 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_0116: Expected O, but got Unknown
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Expected O, but got Unknown
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Expected O, but got Unknown
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Expected O, but got Unknown
			//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)
			//IL_007b: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
			{
				<>1__state = -1;
				ZNetScene instance = ZNetScene.instance;
				GameObject val = ((instance != null) ? instance.GetPrefab("lightningAOE") : null);
				if ((Object)(object)val == (Object)null)
				{
					return false;
				}
				<circles1>5__2 = new List<GameObject>();
				foreach (Vector3 item in group1)
				{
					<circles1>5__2.Add(SpawnWarningCircle(item, 1.5f, Color.cyan));
				}
				<>2__current = (object)new WaitForSeconds(1.2f);
				<>1__state = 1;
				return true;
			}
			case 1:
				<>1__state = -1;
				foreach (GameObject item2 in <circles1>5__2)
				{
					SetCircleColor(item2, Color.white);
				}
				<>2__current = (object)new WaitForSeconds(0.4f);
				<>1__state = 2;
				return true;
			case 2:
				<>1__state = -1;
				foreach (GameObject item3 in <circles1>5__2)
				{
					SetCircleColor(item3, Color.yellow);
				}
				<>2__current = (object)new WaitForSeconds(0.3f);
				<>1__state = 3;
				return true;
			case 3:
				<>1__state = -1;
				foreach (GameObject item4 in <circles1>5__2)
				{
					if (Object.op_Implicit((Object)(object)item4))
					{
						Object.Destroy((Object)(object)item4);
					}
				}
				foreach (Vector3 item5 in group1)
				{
					SpawnLocalFX("lightningAOE", item5, Color.cyan);
				}
				<circles2>5__3 = new List<GameObject>();
				foreach (Vector3 item6 in group2)
				{
					<circles2>5__3.Add(SpawnWarningCircle(item6, 1.5f, Color.cyan));
				}
				<>2__current = (object)new WaitForSeconds(1.2f);
				<>1__state = 4;
				return true;
			case 4:
				<>1__state = -1;
				foreach (GameObject item7 in <circles2>5__3)
				{
					SetCircleColor(item7, Color.white);
				}
				<>2__current = (object)new WaitForSeconds(0.4f);
				<>1__state = 5;
				return true;
			case 5:
				<>1__state = -1;
				foreach (GameObject item8 in <circles2>5__3)
				{
					SetCircleColor(item8, Color.yellow);
				}
				<>2__current = (object)new WaitForSeconds(0.3f);
				<>1__state = 6;
				return true;
			case 6:
				<>1__state = -1;
				foreach (GameObject item9 in <circles2>5__3)
				{
					if (Object.op_Implicit((Object)(object)item9))
					{
						Object.Destroy((Object)(object)item9);
					}
				}
				foreach (Vector3 item10 in group2)
				{
					SpawnLocalFX("lightningAOE", item10, Color.cyan);
				}
				EikthyrTrackerPlugin.Log.LogInfo((object)"[Rays] Visuales ejecutados.");
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <CoStompAOE>d__10 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Vector3 bossPos;

		private int <count>5__2;

		private float <radius>5__3;

		private List<GameObject> <circles>5__4;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <CoStompAOE>d__10(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<circles>5__4 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
			{
				<>1__state = -1;
				ZNetScene instance = ZNetScene.instance;
				GameObject val3 = ((instance != null) ? instance.GetPrefab("lightningAOE") : null);
				if ((Object)(object)val3 == (Object)null)
				{
					return false;
				}
				<count>5__2 = 8;
				<radius>5__3 = 4f;
				<circles>5__4 = new List<GameObject>();
				for (int j = 0; j < <count>5__2; j++)
				{
					float num2 = 360f / (float)<count>5__2 * (float)j * ((float)Math.PI / 180f);
					Vector3 center = bossPos + new Vector3(Mathf.Sin(num2) * <radius>5__3, 0f, Mathf.Cos(num2) * <radius>5__3);
					<circles>5__4.Add(SpawnWarningCircle(center, 1.5f, Color.yellow));
				}
				<>2__current = (object)new WaitForSeconds(1.5f);
				<>1__state = 1;
				return true;
			}
			case 1:
				<>1__state = -1;
				foreach (GameObject item in <circles>5__4)
				{
					SetCircleColor(item, Color.white);
				}
				<>2__current = (object)new WaitForSeconds(0.3f);
				<>1__state = 2;
				return true;
			case 2:
			{
				<>1__state = -1;
				foreach (GameObject item2 in <circles>5__4)
				{
					if (Object.op_Implicit((Object)(object)item2))
					{
						Object.Destroy((Object)(object)item2);
					}
				}
				RaycastHit val2 = default(RaycastHit);
				for (int i = 0; i < <count>5__2; i++)
				{
					float num = 360f / (float)<count>5__2 * (float)i * ((float)Math.PI / 180f);
					Vector3 val = bossPos + new Vector3(Mathf.Sin(num) * <radius>5__3, 0f, Mathf.Cos(num) * <radius>5__3);
					if (Physics.Raycast(val + Vector3.up * 50f, Vector3.down, ref val2, 100f))
					{
						val.y = ((RaycastHit)(ref val2)).point.y;
					}
					SpawnLocalFX("lightningAOE", val, Color.yellow);
				}
				EikthyrTrackerPlugin.Log.LogInfo((object)"[Stomp] Visuales ejecutados (local-only).");
				return false;
			}
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public static Vector3 ParseVec(string s, CultureInfo ci)
	{
		//IL_0039: 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)
		string[] array = s.Split(new char[1] { ',' });
		if (array.Length < 3)
		{
			return Vector3.zero;
		}
		return new Vector3(float.Parse(array[0], ci), float.Parse(array[1], ci), float.Parse(array[2], ci));
	}

	public static string VecToStr(Vector3 v, CultureInfo ci)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		return string.Format(ci, "{0},{1},{2}", v.x, v.y, v.z);
	}

	public static GameObject SpawnWarningCircle(Vector3 center, float radius, Color color)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Expected O, but got Unknown
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: 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)
		GameObject val = new GameObject("EK_WarningCircle");
		val.transform.position = center + Vector3.up * 0.1f;
		LineRenderer val2 = val.AddComponent<LineRenderer>();
		val2.useWorldSpace = false;
		val2.loop = true;
		val2.widthMultiplier = 0.12f;
		val2.positionCount = 32;
		((Renderer)val2).material = new Material(Shader.Find("Sprites/Default"));
		val2.startColor = color;
		val2.endColor = color;
		for (int i = 0; i < 32; i++)
		{
			float num = 11.25f * (float)i * ((float)Math.PI / 180f);
			val2.SetPosition(i, new Vector3(Mathf.Sin(num) * radius, 0f, Mathf.Cos(num) * radius));
		}
		return val;
	}

	public static void SetCircleColor(GameObject go, Color color)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)go))
		{
			LineRenderer component = go.GetComponent<LineRenderer>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.startColor = color;
				component.endColor = color;
			}
		}
	}

	public static void SpawnLocalFX(string prefabName, Vector3 pos, Color color, float lifetime = 3f)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Expected O, but got Unknown
		//IL_0039: 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_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Expected O, but got Unknown
		//IL_0141: 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_00d1: 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_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Expected O, but got Unknown
		//IL_0220: Unknown result type (might be due to invalid IL or missing references)
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		ZNetScene instance = ZNetScene.instance;
		GameObject val = ((instance != null) ? instance.GetPrefab(prefabName) : null);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		GameObject val2 = new GameObject("EK_FX_" + prefabName + "_Local");
		val2.transform.position = pos;
		ParticleSystem[] componentsInChildren = val.GetComponentsInChildren<ParticleSystem>(true);
		foreach (ParticleSystem val3 in componentsInChildren)
		{
			GameObject val4 = Object.Instantiate<GameObject>(((Component)val3).gameObject, pos, ((Component)val3).transform.rotation, val2.transform);
			ZNetView[] componentsInChildren2 = val4.GetComponentsInChildren<ZNetView>(true);
			foreach (ZNetView val5 in componentsInChildren2)
			{
				Object.Destroy((Object)(object)val5);
			}
			ZSyncTransform[] componentsInChildren3 = val4.GetComponentsInChildren<ZSyncTransform>(true);
			foreach (ZSyncTransform val6 in componentsInChildren3)
			{
				Object.Destroy((Object)(object)val6);
			}
			MainModule main = val4.GetComponent<ParticleSystem>().main;
			((MainModule)(ref main)).startColor = new MinMaxGradient(color);
		}
		AudioSource[] componentsInChildren4 = val.GetComponentsInChildren<AudioSource>(true);
		foreach (AudioSource val7 in componentsInChildren4)
		{
			if (!((Object)(object)val7.clip == (Object)null))
			{
				GameObject val8 = new GameObject("EK_Audio");
				val8.transform.SetParent(val2.transform);
				val8.transform.position = pos;
				AudioSource val9 = val8.AddComponent<AudioSource>();
				val9.clip = val7.clip;
				val9.volume = val7.volume;
				val9.pitch = val7.pitch;
				val9.spatialBlend = val7.spatialBlend;
				val9.minDistance = val7.minDistance;
				val9.maxDistance = val7.maxDistance;
				val9.rolloffMode = val7.rolloffMode;
				val9.Play();
			}
		}
		ZSFX[] componentsInChildren5 = val.GetComponentsInChildren<ZSFX>(true);
		foreach (ZSFX val10 in componentsInChildren5)
		{
			if (val10.m_audioClips != null && val10.m_audioClips.Length != 0)
			{
				GameObject val11 = new GameObject("EK_ZSFX_Audio");
				val11.transform.SetParent(val2.transform);
				val11.transform.position = pos;
				AudioSource component = ((Component)val10).GetComponent<AudioSource>();
				AudioSource val12 = val11.AddComponent<AudioSource>();
				if ((Object)(object)component != (Object)null)
				{
					val12.spatialBlend = component.spatialBlend;
					val12.minDistance = component.minDistance;
					val12.maxDistance = component.maxDistance;
					val12.rolloffMode = component.rolloffMode;
					val12.spread = component.spread;
				}
				val12.clip = val10.m_audioClips[Random.Range(0, val10.m_audioClips.Length)];
				val12.volume = Random.Range(val10.m_minVol, val10.m_maxVol) * 0.5f;
				val12.pitch = Random.Range(val10.m_minPitch, val10.m_maxPitch);
				val12.Play();
			}
		}
		Object.Destroy((Object)(object)val2, lifetime);
	}

	public static void ExecuteLightningRays(string payload, MonoBehaviour runner)
	{
		//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_000f: Unknown result type (might be due to invalid IL or missing references)
		CultureInfo invariantCulture = CultureInfo.InvariantCulture;
		Vector3 bossPos = ParseVec(payload, invariantCulture);
		runner.StartCoroutine(CoLightningRays(bossPos));
	}

	public static void ExecuteLightningRaysWithGroups(string payload, MonoBehaviour runner)
	{
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		CultureInfo invariantCulture = CultureInfo.InvariantCulture;
		string[] array = payload.Split(new char[1] { '|' });
		if (array.Length < 3)
		{
			EikthyrTrackerPlugin.Log.LogError((object)("[Rays] payload inválido: '" + payload + "'"));
			return;
		}
		List<Vector3> list = new List<Vector3>();
		List<Vector3> list2 = new List<Vector3>();
		string[] array2 = array[1].Split(new char[1] { ';' });
		foreach (string text in array2)
		{
			if (!string.IsNullOrEmpty(text))
			{
				list.Add(ParseVec(text, invariantCulture));
			}
		}
		string[] array3 = array[2].Split(new char[1] { ';' });
		foreach (string text2 in array3)
		{
			if (!string.IsNullOrEmpty(text2))
			{
				list2.Add(ParseVec(text2, invariantCulture));
			}
		}
		runner.StartCoroutine(CoLightningRaysVisuals(list, list2));
	}

	[IteratorStateMachine(typeof(<CoLightningRays>d__7))]
	private static IEnumerator CoLightningRays(Vector3 bossPos)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <CoLightningRays>d__7(0)
		{
			bossPos = bossPos
		};
	}

	[IteratorStateMachine(typeof(<CoLightningRaysVisuals>d__8))]
	private static IEnumerator CoLightningRaysVisuals(List<Vector3> group1, List<Vector3> group2)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <CoLightningRaysVisuals>d__8(0)
		{
			group1 = group1,
			group2 = group2
		};
	}

	public static void ExecuteStompAOE(string payload, MonoBehaviour runner)
	{
		//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_000f: Unknown result type (might be due to invalid IL or missing references)
		CultureInfo invariantCulture = CultureInfo.InvariantCulture;
		Vector3 bossPos = ParseVec(payload, invariantCulture);
		runner.StartCoroutine(CoStompAOE(bossPos));
	}

	[IteratorStateMachine(typeof(<CoStompAOE>d__10))]
	private static IEnumerator CoStompAOE(Vector3 bossPos)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <CoStompAOE>d__10(0)
		{
			bossPos = bossPos
		};
	}
}
public static class ServerCoroutineRunner
{
	private static ServerCoroutineRunnerMB _instance;

	private static ServerCoroutineRunnerMB Instance
	{
		get
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if ((Object)(object)_instance == (Object)null)
			{
				GameObject val = new GameObject("EikthyrServerRunner");
				Object.DontDestroyOnLoad((Object)(object)val);
				_instance = val.AddComponent<ServerCoroutineRunnerMB>();
			}
			return _instance;
		}
	}

	public static void Run(IEnumerator coroutine)
	{
		((MonoBehaviour)Instance).StartCoroutine(coroutine);
	}

	public static Coroutine RunAndWait(IEnumerator coroutine)
	{
		return ((MonoBehaviour)Instance).StartCoroutine(coroutine);
	}
}
public class ServerCoroutineRunnerMB : MonoBehaviour
{
}
public static class RPC
{
	[CompilerGenerated]
	private sealed class <ApplyDamageDelayed>d__34 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public float delay;

		public Player player;

		public bool checkProximity;

		public Vector3 impactPos;

		public float dmg;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <ApplyDamageDelayed>d__34(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				if (delay > 0f)
				{
					<>2__current = (object)new WaitForSeconds(delay);
					<>1__state = 1;
					return true;
				}
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if ((Object)(object)player == (Object)null || ((Character)player).IsDead())
			{
				return false;
			}
			if (checkProximity && Vector3.Distance(((Component)player).transform.position, impactPos) > 3f)
			{
				EikthyrTrackerPlugin.Log.LogInfo((object)$"[CLIENT Rays] Jugador fuera del rayo ({Vector3.Distance(((Component)player).transform.position, impactPos):F1}u) — daño cancelado.");
				return false;
			}
			HitData val = new HitData();
			val.m_point = ((Component)player).transform.position;
			val.m_damage.m_lightning = dmg;
			val.m_ranged = true;
			val.m_hitType = (HitType)16;
			((Character)player).Damage(val);
			EikthyrTrackerPlugin.Log.LogWarning((object)$"[CLIENT Rays] \ud83d\udca5 Daño: {dmg} lightning");
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <PhaseTransitionFX>d__25 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Vector3 bossPos;

		private float <duration>5__2;

		private float <elapsed>5__3;

		private int <count>5__4;

		private float <radius>5__5;

		private int <i>5__6;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <PhaseTransitionFX>d__25(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0094: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			int num = <>1__state;
			if (num != 0)
			{
				if (num != 1)
				{
					return false;
				}
				<>1__state = -1;
				<elapsed>5__3 += 0.1f;
				if (<elapsed>5__3 >= <duration>5__2)
				{
					return false;
				}
				<i>5__6++;
				goto IL_012a;
			}
			<>1__state = -1;
			<duration>5__2 = 4f;
			<elapsed>5__3 = 0f;
			goto IL_013b;
			IL_013b:
			if (<elapsed>5__3 < <duration>5__2)
			{
				AttackClients.SpawnLocalFX("fx_himminafl_hit", bossPos + Vector3.up, Color.yellow);
				<count>5__4 = 8;
				<radius>5__5 = 6f;
				<i>5__6 = 0;
				goto IL_012a;
			}
			return false;
			IL_012a:
			if (<i>5__6 < <count>5__4)
			{
				float num2 = 360f / (float)<count>5__4 * (float)<i>5__6 * ((float)Math.PI / 180f);
				Vector3 pos = bossPos + new Vector3(Mathf.Sin(num2) * <radius>5__5, 0f, Mathf.Cos(num2) * <radius>5__5);
				AttackClients.SpawnLocalFX("fx_himminafl_aoe", pos, Color.yellow);
				<>2__current = (object)new WaitForSeconds(0.1f);
				<>1__state = 1;
				return true;
			}
			goto IL_013b;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <StompDamageSequence>d__36 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Vector3 bossPos;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <StompDamageSequence>d__36(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(1.8f);
				<>1__state = 1;
				return true;
			case 1:
			{
				<>1__state = -1;
				int num = 8;
				float num2 = 4f;
				foreach (ZNetPeer connectedPeer in ZNet.instance.GetConnectedPeers())
				{
					if (connectedPeer.m_characterID == ZDOID.None)
					{
						continue;
					}
					ZDO zDO = ZDOMan.instance.GetZDO(connectedPeer.m_characterID);
					if (zDO == null)
					{
						continue;
					}
					Vector3 position = zDO.GetPosition();
					bool flag = false;
					for (int i = 0; i < num; i++)
					{
						float num3 = 360f / (float)num * (float)i * ((float)Math.PI / 180f);
						Vector3 val = bossPos + new Vector3(Mathf.Sin(num3) * num2, 0f, Mathf.Cos(num3) * num2);
						if (Vector3.Distance(position, val) <= 2.5f)
						{
							flag = true;
							break;
						}
					}
					if (flag)
					{
						ZRoutedRpc.instance.InvokeRoutedRPC(connectedPeer.m_uid, "EikthyrTracker_StompDamage", new object[1] { "15" });
						Log.LogWarning((object)("[SERVER Stomp] \ud83d\udca5 Daño → " + connectedPeer.m_playerName));
					}
				}
				_stompInProgress = false;
				EikthyrTrackerPlugin.Log.LogInfo((object)"[SERVER Stomp] Flag reseteado.");
				return false;
			}
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public const string EikthyrAttack = "EikthyrTracker_AttackDetected";

	public const string EikthyrSummoned = "EikthyrTracker_BossSummoned";

	public const string FreezeEikthyr = "EikthyrTracker_Freeze";

	public const string UnfreezeEikthyr = "EikthyrTracker_Unfreeze";

	public const string RaysRequest = "EikthyrTracker_RaysRequest";

	public const string RaysBroadcast = "EikthyrTracker_RaysBroadcast";

	public const string RaysDamage = "EikthyrTracker_RaysDamage";

	public const string StompRequest = "EikthyrTracker_StompRequest";

	public const string StompBroadcast = "EikthyrTracker_StompBroadcast";

	public const string StompDamage = "EikthyrTracker_StompDamage";

	public const string PhaseTransition = "EikthyrTracker_PhaseTransition";

	public const string PhaseImmunity = "EikthyrTracker_PhaseImmunity";

	public static int CurrentPhase = 0;

	public static bool IsPhaseImmune = false;

	public const string BossDefeated = "EikthyrTracker_BossDefeated";

	private static float _lastRaysTime = -99f;

	private static float _lastStompTime = -99f;

	private const float RaysCooldown = 4f;

	private const float StompCooldown = 3f;

	private static bool _stompInProgress = false;

	private static ManualLogSource Log => EikthyrTrackerPlugin.Log;

	public static void RegisterRPCs()
	{
		ZRoutedRpc.instance.Register<string, int>("EikthyrTracker_AttackDetected", (Action<long, string, int>)OnEikthyrAttack_Server);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_BossSummoned", (Action<long, string>)OnEikthyrSummoned_Server);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_Freeze", (Action<long, string>)OnFreezeEikthyr_Client);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_Unfreeze", (Action<long, string>)OnUnfreezeEikthyr_Client);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_RaysRequest", (Action<long, string>)OnRaysRequest_Server);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_RaysBroadcast", (Action<long, string>)OnRaysBroadcast_Client);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_RaysDamage", (Action<long, string>)OnRaysDamage_Client);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_StompRequest", (Action<long, string>)OnStompRequest_Server);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_StompBroadcast", (Action<long, string>)OnStompBroadcast_Client);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_StompDamage", (Action<long, string>)OnStompDamage_Client);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_PhaseTransition", (Action<long, string>)OnPhaseTransition_Client);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_PhaseImmunity", (Action<long, string>)OnPhaseImmunity_Client);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_BossDefeated", (Action<long, string>)OnBossDefeated_Server);
	}

	public static void OnBossDefeated_Server(long senderPeerID, string unused)
	{
		if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer())
		{
			PhaseSystem.Reset();
			PhaseSystem.StartMonitoring();
			Log.LogWarning((object)"[SERVER] \ud83d\udc80 Boss derrotado — fases reseteadas.");
		}
	}

	public static void OnPhaseTransition_Client(long senderPeerID, string payload)
	{
		//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_0068: Unknown result type (might be due to invalid IL or missing references)
		CultureInfo invariantCulture = CultureInfo.InvariantCulture;
		string[] array = payload.Split(new char[1] { '|' });
		if (array.Length >= 2)
		{
			int.TryParse(array[0], out var result);
			Vector3 bossPos = AttackClients.ParseVec(array[1], invariantCulture);
			CurrentPhase = result;
			Log.LogWarning((object)$"[CLIENT] ⚡ Fase {result} activada.");
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null))
			{
				((MonoBehaviour)localPlayer).StartCoroutine(PhaseTransitionFX(bossPos));
			}
		}
	}

	[IteratorStateMachine(typeof(<PhaseTransitionFX>d__25))]
	private static IEnumerator PhaseTransitionFX(Vector3 bossPos)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <PhaseTransitionFX>d__25(0)
		{
			bossPos = bossPos
		};
	}

	public static void OnPhaseImmunity_Client(long senderPeerID, string value)
	{
		IsPhaseImmune = value == "1";
		EikthyrTrackerPlugin.Log.LogInfo((object)$"[CLIENT] Inmunidad de faseo: {IsPhaseImmune}");
	}

	public static void OnEikthyrAttack_Server(long senderPeerID, string attackName, int attackId)
	{
		if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer())
		{
			string peerName = GetPeerName(senderPeerID);
			Log.LogWarning((object)"══════════════════════════════════════");
			Log.LogWarning((object)"[SERVER RPC] \ud83d\udde1\ufe0f EIKTHYR ATAQUE DETECTADO");
			Log.LogWarning((object)("[SERVER RPC] Ataque    : " + attackName));
			Log.LogWarning((object)$"[SERVER RPC] Attack ID : {attackId}");
			Log.LogWarning((object)$"[SERVER RPC] Peer      : {peerName} ({senderPeerID})");
			Log.LogWarning((object)"══════════════════════════════════════");
		}
	}

	public static void OnEikthyrSummoned_Server(long senderPeerID, string invokerName)
	{
		if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer())
		{
			string peerName = GetPeerName(senderPeerID);
			Log.LogWarning((object)"══════════════════════════════════════");
			Log.LogWarning((object)"[SERVER RPC] \ud83d\udd14 EIKTHYR INVOCADO");
			Log.LogWarning((object)("[SERVER RPC] Invocador : " + invokerName));
			Log.LogWarning((object)$"[SERVER RPC] Peer      : {peerName} ({senderPeerID})");
			Log.LogWarning((object)"══════════════════════════════════════");
		}
	}

	public static void OnFreezeEikthyr_Client(long senderPeerID, string unused)
	{
		foreach (Character allCharacter in Character.GetAllCharacters())
		{
			if (!EikthyrTrackerPlugin.IsEikthyr(allCharacter))
			{
				continue;
			}
			ZNetView component = ((Component)allCharacter).GetComponent<ZNetView>();
			if (!((Object)(object)component == (Object)null) && component.IsValid() && component.IsOwner())
			{
				MonsterAI component2 = ((Component)allCharacter).GetComponent<MonsterAI>();
				BaseAI component3 = ((Component)allCharacter).GetComponent<BaseAI>();
				if ((Object)(object)component2 != (Object)null)
				{
					((Behaviour)component2).enabled = false;
				}
				if (component3 != null)
				{
					component3.StopMoving();
				}
				allCharacter.m_speed = 0f;
				allCharacter.m_runSpeed = 0f;
				allCharacter.m_walkSpeed = 0f;
				EikthyrTrackerPlugin.Log.LogInfo((object)"[CLIENT] Eikthyr congelado (soy el owner).");
				break;
			}
		}
	}

	public static void OnUnfreezeEikthyr_Client(long senderPeerID, string unused)
	{
		foreach (Character allCharacter in Character.GetAllCharacters())
		{
			if (!EikthyrTrackerPlugin.IsEikthyr(allCharacter))
			{
				continue;
			}
			ZNetView component = ((Component)allCharacter).GetComponent<ZNetView>();
			if (!((Object)(object)component == (Object)null) && component.IsValid() && component.IsOwner())
			{
				MonsterAI component2 = ((Component)allCharacter).GetComponent<MonsterAI>();
				if ((Object)(object)component2 != (Object)null)
				{
					((Behaviour)component2).enabled = true;
				}
				allCharacter.m_speed = 3f;
				allCharacter.m_runSpeed = 6f;
				allCharacter.m_walkSpeed = 2f;
				EikthyrTrackerPlugin.Log.LogInfo((object)"[CLIENT] Eikthyr descongelado.");
				break;
			}
		}
	}

	public static void OnRaysRequest_Server(long senderPeerID, string posStr)
	{
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0310: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0404: Unknown result type (might be due to invalid IL or missing references)
		//IL_0409: Unknown result type (might be due to invalid IL or missing references)
		//IL_040e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0438: Unknown result type (might be due to invalid IL or missing references)
		//IL_0422: Unknown result type (might be due to invalid IL or missing references)
		//IL_035b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0375: Unknown result type (might be due to invalid IL or missing references)
		//IL_037a: Unknown result type (might be due to invalid IL or missing references)
		//IL_037f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0393: Unknown result type (might be due to invalid IL or missing references)
		//IL_04af: Unknown result type (might be due to invalid IL or missing references)
		//IL_049d: Unknown result type (might be due to invalid IL or missing references)
		//IL_054e: Unknown result type (might be due to invalid IL or missing references)
		//IL_053c: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0621: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
		{
			return;
		}
		float time = Time.time;
		if (time - _lastRaysTime < 4f)
		{
			Log.LogInfo((object)("[SERVER Rays] En cooldown — ignorando de " + GetPeerName(senderPeerID) + "."));
			return;
		}
		_lastRaysTime = time;
		CultureInfo invariantCulture = CultureInfo.InvariantCulture;
		Vector3 val = AttackClients.ParseVec(posStr, invariantCulture);
		Log.LogWarning((object)"══════════════════════════════════════");
		Log.LogWarning((object)"[SERVER Rays] ⚡ LIGHTNING RAYS");
		Log.LogWarning((object)$"[SERVER Rays] Boss pos : {val}");
		Log.LogWarning((object)("[SERVER Rays] Peer     : " + GetPeerName(senderPeerID)));
		Log.LogWarning((object)"══════════════════════════════════════");
		List<ZNetPeer> list = new List<ZNetPeer>();
		foreach (ZNetPeer connectedPeer in ZNet.instance.GetConnectedPeers())
		{
			if (!(connectedPeer.m_characterID == ZDOID.None))
			{
				ZDO zDO = ZDOMan.instance.GetZDO(connectedPeer.m_characterID);
				if (zDO != null && Vector3.Distance(zDO.GetPosition(), val) < 30f)
				{
					list.Add(connectedPeer);
				}
			}
		}
		if (list.Count == 0)
		{
			Log.LogInfo((object)"[SERVER Rays] Sin jugadores en rango.");
			return;
		}
		for (int num = list.Count - 1; num > 0; num--)
		{
			int index = Random.Range(0, num + 1);
			ZNetPeer value = list[num];
			list[num] = list[index];
			list[index] = value;
		}
		List<Vector3> list2 = new List<Vector3>();
		List<Vector3> list3 = new List<Vector3>();
		List<ZNetPeer> list4;
		List<ZNetPeer> list5;
		if (list.Count >= 5)
		{
			int num2 = list.Count / 2;
			list4 = list.GetRange(0, num2);
			list5 = list.GetRange(num2, list.Count - num2);
		}
		else
		{
			list4 = new List<ZNetPeer>(list);
			list5 = new List<ZNetPeer>();
		}
		foreach (ZNetPeer item in list4)
		{
			ZDO zDO2 = ZDOMan.instance.GetZDO(item.m_characterID);
			if (zDO2 != null)
			{
				list2.Add(zDO2.GetPosition());
			}
		}
		foreach (ZNetPeer item2 in list5)
		{
			ZDO zDO3 = ZDOMan.instance.GetZDO(item2.m_characterID);
			if (zDO3 != null)
			{
				list3.Add(zDO3.GetPosition());
			}
		}
		while (list2.Count < 5)
		{
			float num3 = Random.Range(0f, 360f) * ((float)Math.PI / 180f);
			float num4 = Random.Range(3f, 12f);
			Vector3 val2 = val + new Vector3(Mathf.Sin(num3) * num4, 0f, Mathf.Cos(num3) * num4);
			if ((Object)(object)ZoneSystem.instance != (Object)null)
			{
				ZoneSystem.instance.GetSolidHeight(val2, ref val2.y, 1000);
			}
			list2.Add(val2);
		}
		if (list5.Count > 0)
		{
			while (list3.Count < 5)
			{
				float num5 = Random.Range(0f, 360f) * ((float)Math.PI / 180f);
				float num6 = Random.Range(3f, 12f);
				Vector3 val3 = val + new Vector3(Mathf.Sin(num5) * num6, 0f, Mathf.Cos(num5) * num6);
				if ((Object)(object)ZoneSystem.instance != (Object)null)
				{
					ZoneSystem.instance.GetSolidHeight(val3, ref val3.y, 1000);
				}
				list3.Add(val3);
			}
		}
		else
		{
			while (list3.Count < 5)
			{
				float num7 = Random.Range(0f, 360f) * ((float)Math.PI / 180f);
				float num8 = Random.Range(3f, 12f);
				Vector3 val4 = val + new Vector3(Mathf.Sin(num7) * num8, 0f, Mathf.Cos(num7) * num8);
				if ((Object)(object)ZoneSystem.instance != (Object)null)
				{
					ZoneSystem.instance.GetSolidHeight(val4, ref val4.y, 1000);
				}
				list3.Add(val4);
			}
		}
		Log.LogWarning((object)$"[SERVER Rays] Oleada1={list2.Count} puntos | Oleada2={list3.Count} puntos");
		CultureInfo invariantCulture2 = CultureInfo.InvariantCulture;
		for (int i = 0; i < list4.Count; i++)
		{
			ZNetPeer val5 = list4[i];
			string text = ((i < list2.Count) ? AttackClients.VecToStr(list2[i], invariantCulture2) : AttackClients.VecToStr(Vector3.zero, invariantCulture2));
			ZRoutedRpc.instance.InvokeRoutedRPC(val5.m_uid, "EikthyrTracker_RaysDamage", new object[1] { "1.9|8|" + text });
			Log.LogWarning((object)("[SERVER Rays] \ud83d\udca5 Oleada 1 → " + val5.m_playerName + " @ " + text));
		}
		for (int j = 0; j < list5.Count; j++)
		{
			ZNetPeer val6 = list5[j];
			string text2 = ((j < list3.Count) ? AttackClients.VecToStr(list3[j], invariantCulture2) : AttackClients.VecToStr(Vector3.zero, invariantCulture2));
			ZRoutedRpc.instance.InvokeRoutedRPC(val6.m_uid, "EikthyrTracker_RaysDamage", new object[1] { "3.8|8|" + text2 });
			Log.LogWarning((object)("[SERVER Rays] \ud83d\udca5 Oleada 2 → " + val6.m_playerName + " @ " + text2));
		}
		StringBuilder stringBuilder = new StringBuilder();
		StringBuilder stringBuilder2 = new StringBuilder();
		for (int k = 0; k < list2.Count; k++)
		{
			if (k > 0)
			{
				stringBuilder.Append(';');
			}
			stringBuilder.Append(AttackClients.VecToStr(list2[k], invariantCulture));
		}
		for (int l = 0; l < list3.Count; l++)
		{
			if (l > 0)
			{
				stringBuilder2.Append(';');
			}
			stringBuilder2.Append(AttackClients.VecToStr(list3[l], invariantCulture));
		}
		string text3 = $"{posStr}|{stringBuilder}|{stringBuilder2}";
		ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "EikthyrTracker_RaysBroadcast", new object[1] { text3 });
	}

	public static void OnRaysBroadcast_Client(long senderPeerID, string payload)
	{
		if (!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsServer())
		{
			Log.LogInfo((object)"[CLIENT Rays] ⚡ Broadcast recibido — ejecutando visuales.");
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null))
			{
				AttackClients.ExecuteLightningRaysWithGroups(payload, (MonoBehaviour)(object)localPlayer);
			}
		}
	}

	public static void OnRaysDamage_Client(long senderPeerID, string dmgPayload)
	{
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: 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)
		if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer())
		{
			return;
		}
		Player localPlayer = Player.m_localPlayer;
		if (!((Object)(object)localPlayer == (Object)null) && !((Character)localPlayer).IsDead())
		{
			CultureInfo invariantCulture = CultureInfo.InvariantCulture;
			string[] array = dmgPayload.Split(new char[1] { '|' });
			float result = 0f;
			float result2 = 8f;
			Vector3 impactPos = Vector3.zero;
			bool checkProximity = false;
			if (array.Length >= 1)
			{
				float.TryParse(array[0], NumberStyles.Float, invariantCulture, out result);
			}
			if (array.Length >= 2)
			{
				float.TryParse(array[1], NumberStyles.Float, invariantCulture, out result2);
			}
			if (array.Length >= 3)
			{
				impactPos = AttackClients.ParseVec(array[2], invariantCulture);
				checkProximity = true;
			}
			((MonoBehaviour)localPlayer).StartCoroutine(ApplyDamageDelayed(localPlayer, result2, result, impactPos, checkProximity));
		}
	}

	[IteratorStateMachine(typeof(<ApplyDamageDelayed>d__34))]
	private static IEnumerator ApplyDamageDelayed(Player player, float dmg, float delay, Vector3 impactPos, bool checkProximity)
	{
		//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)
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <ApplyDamageDelayed>d__34(0)
		{
			player = player,
			dmg = dmg,
			delay = delay,
			impactPos = impactPos,
			checkProximity = checkProximity
		};
	}

	public static void OnStompRequest_Server(long senderPeerID, string posStr)
	{
		//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_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
		{
			return;
		}
		if (_stompInProgress)
		{
			Log.LogInfo((object)("[SERVER Stomp] Stomp ya en curso — ignorando RPC de " + GetPeerName(senderPeerID) + "."));
			return;
		}
		float time = Time.time;
		if (time - _lastStompTime < 3f)
		{
			Log.LogInfo((object)("[SERVER Stomp] En cooldown — ignorando de " + GetPeerName(senderPeerID) + "."));
			return;
		}
		_lastStompTime = time;
		_stompInProgress = true;
		CultureInfo invariantCulture = CultureInfo.InvariantCulture;
		Vector3 val = AttackClients.ParseVec(posStr, invariantCulture);
		Log.LogWarning((object)"══════════════════════════════════════");
		Log.LogWarning((object)"[SERVER Stomp] \ud83d\udd28 STOMP AOE");
		Log.LogWarning((object)$"[SERVER Stomp] Boss pos : {val}");
		Log.LogWarning((object)("[SERVER Stomp] Peer     : " + GetPeerName(senderPeerID)));
		Log.LogWarning((object)"══════════════════════════════════════");
		ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "EikthyrTracker_StompBroadcast", new object[1] { posStr });
		ServerCoroutineRunner.Run(StompDamageSequence(val));
	}

	[IteratorStateMachine(typeof(<StompDamageSequence>d__36))]
	private static IEnumerator StompDamageSequence(Vector3 bossPos)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <StompDamageSequence>d__36(0)
		{
			bossPos = bossPos
		};
	}

	public static void OnStompBroadcast_Client(long senderPeerID, string payload)
	{
		if (!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsServer())
		{
			Log.LogInfo((object)"[CLIENT Stomp] \ud83d\udd28 Broadcast recibido — ejecutando visuales.");
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null))
			{
				AttackClients.ExecuteStompAOE(payload, (MonoBehaviour)(object)localPlayer);
			}
		}
	}

	public static void OnStompDamage_Client(long senderPeerID, string dmgStr)
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Expected O, but got Unknown
		//IL_005a: 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_0079: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsServer())
		{
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && !((Character)localPlayer).IsDead())
			{
				CultureInfo invariantCulture = CultureInfo.InvariantCulture;
				float result = 15f;
				float.TryParse(dmgStr, NumberStyles.Float, invariantCulture, out result);
				HitData val = new HitData();
				val.m_point = ((Component)localPlayer).transform.position;
				val.m_damage.m_blunt = result;
				val.m_ranged = true;
				val.m_hitType = (HitType)6;
				((Character)localPlayer).Damage(val);
				EikthyrTrackerPlugin.Log.LogWarning((object)$"[CLIENT Stomp] \ud83d\udca5 Daño: {result} blunt");
			}
		}
	}

	public static void SendAttack(string attackName, int attackId)
	{
		if (ZRoutedRpc.instance != null && !((Object)(object)ZNet.instance == (Object)null))
		{
			long num = (ZNet.instance.IsServer() ? ZNet.GetUID() : ZRoutedRpc.instance.GetServerPeerID());
			ZRoutedRpc.instance.InvokeRoutedRPC(num, "EikthyrTracker_AttackDetected", new object[2] { attackName, attackId });
		}
	}

	public static void SendSummoned(string playerName)
	{
		if (ZRoutedRpc.instance != null && !((Object)(object)ZNet.instance == (Object)null))
		{
			long num = (ZNet.instance.IsServer() ? ZNet.GetUID() : ZRoutedRpc.instance.GetServerPeerID());
			ZRoutedRpc.instance.InvokeRoutedRPC(num, "EikthyrTracker_BossSummoned", new object[1] { playerName });
		}
	}

	public static void SendRaysRequest(Vector3 bossPos)
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		if (ZRoutedRpc.instance != null && !((Object)(object)ZNet.instance == (Object)null))
		{
			long num = (ZNet.instance.IsServer() ? ZNet.GetUID() : ZRoutedRpc.instance.GetServerPeerID());
			CultureInfo invariantCulture = CultureInfo.InvariantCulture;
			string text = AttackClients.VecToStr(bossPos, invariantCulture);
			ZRoutedRpc.instance.InvokeRoutedRPC(num, "EikthyrTracker_RaysRequest", new object[1] { text });
		}
	}

	public static void SendStompRequest(Vector3 bossPos)
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		if (ZRoutedRpc.instance != null && !((Object)(object)ZNet.instance == (Object)null))
		{
			long num = (ZNet.instance.IsServer() ? ZNet.GetUID() : ZRoutedRpc.instance.GetServerPeerID());
			CultureInfo invariantCulture = CultureInfo.InvariantCulture;
			string text = AttackClients.VecToStr(bossPos, invariantCulture);
			ZRoutedRpc.instance.InvokeRoutedRPC(num, "EikthyrTracker_StompRequest", new object[1] { text });
		}
	}

	private static string GetPeerName(long peerID)
	{
		if ((Object)(object)ZNet.instance == (Object)null)
		{
			return "desconocido";
		}
		foreach (ZNetPeer connectedPeer in ZNet.instance.GetConnectedPeers())
		{
			if (connectedPeer.m_uid == peerID)
			{
				return connectedPeer.m_playerName;
			}
		}
		if (peerID == ZNet.GetUID())
		{
			return "Host/Server";
		}
		return $"Peer-{peerID}";
	}
}
[HarmonyPatch(typeof(Character), "Damage")]
public static class Patch_Eikthyr_HPSync
{
	private static void Postfix(Character __instance)
	{
		if (!((Object)(object)__instance == (Object)null) && !__instance.IsDead() && EikthyrTrackerPlugin.IsEikthyr(__instance))
		{
			ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
			if (!((Object)(object)component == (Object)null) && component.IsValid() && component.IsOwner())
			{
				ZDO zDO = component.GetZDO();
				zDO.Set("eikthyr_hp", __instance.GetHealth());
				zDO.Set("eikthyr_max_hp", __instance.GetMaxHealth());
			}
		}
	}
}
[HarmonyPatch(typeof(Character), "Damage")]
public static class Patch_Eikthyr_Immunity
{
	private static void Prefix(Character __instance, ref HitData hit)
	{
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Invalid comparison between Unknown and I4
		if (!((Object)(object)__instance == (Object)null) && hit != null && EikthyrTrackerPlugin.IsEikthyr(__instance))
		{
			if (RPC.IsPhaseImmune)
			{
				hit.m_damage.m_blunt = 0f;
				hit.m_damage.m_slash = 0f;
				hit.m_damage.m_pierce = 0f;
				hit.m_damage.m_fire = 0f;
				hit.m_damage.m_frost = 0f;
				hit.m_damage.m_lightning = 0f;
				hit.m_damage.m_poison = 0f;
				hit.m_damage.m_spirit = 0f;
				EikthyrTrackerPlugin.Log.LogInfo((object)"[EikthyrTracker] \ud83d\udee1\ufe0f Daño bloqueado — faseo activo.");
			}
			else if ((int)hit.m_hitType == 16)
			{
				hit.m_damage.m_blunt = 0f;
				hit.m_damage.m_slash = 0f;
				hit.m_damage.m_pierce = 0f;
				hit.m_damage.m_fire = 0f;
				hit.m_damage.m_frost = 0f;
				hit.m_damage.m_lightning = 0f;
				hit.m_damage.m_poison = 0f;
				hit.m_damage.m_spirit = 0f;
			}
		}
	}
}
[HarmonyPatch(typeof(OfferingBowl), "Interact")]
public static class Patch_OfferingBowl_Interact
{
	private static void Postfix(OfferingBowl __instance, Humanoid user, bool hold)
	{
		if (!hold && !((Object)(object)__instance == (Object)null) && !((Object)(object)user == (Object)null))
		{
			GameObject bossPrefab = __instance.m_bossPrefab;
			if ((((bossPrefab != null) ? ((Object)bossPrefab).name : null) ?? "").Contains("Eikthyr"))
			{
				Player val = (Player)(object)((user is Player) ? user : null);
				string text = ((val != null) ? val.GetPlayerName() : "Desconocido");
				EikthyrTrackerPlugin.Log.LogInfo((object)("[CLIENT DETECT] Altar Eikthyr activado por " + text));
				RPC.SendSummoned(text);
			}
		}
	}
}
[HarmonyPatch(typeof(ZSyncAnimation))]
public static class Patch_ZSyncAnimation_SetTrigger
{
	[HarmonyPrefix]
	[HarmonyPatch("SetTrigger", new Type[] { typeof(string) })]
	private static void Prefix(ZSyncAnimation __instance, string name)
	{
		//IL_0083: 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)
		Character val = ((__instance != null) ? ((Component)__instance).GetComponentInParent<Character>() : null);
		if ((Object)(object)val == (Object)null || !EikthyrTrackerPlugin.IsEikthyr(val))
		{
			return;
		}
		ZNetView component = ((Component)val).GetComponent<ZNetView>();
		if (!((Object)(object)component == (Object)null) && component.IsValid() && component.IsOwner())
		{
			int hashCode = name.GetHashCode();
			EikthyrTrackerPlugin.Log.LogInfo((object)("[CLIENT DETECT] Trigger: " + name + " (soy el owner)"));
			if (name == "attack1")
			{
				EikthyrTrackerPlugin.Log.LogInfo((object)"[CLIENT DETECT] attack1 → enviando StompRequest al servidor.");
				RPC.SendStompRequest(((Component)val).transform.position);
			}
			else if (name == "attack2")
			{
				EikthyrTrackerPlugin.Log.LogInfo((object)"[CLIENT DETECT] attack2 → enviando RaysRequest al servidor.");
				RPC.SendRaysRequest(((Component)val).transform.position);
			}
			else
			{
				RPC.SendAttack(name, hashCode);
			}
			WriteAttackToZDO(val, name, hashCode);
		}
	}

	private static void WriteAttackToZDO(Character eikthyr, string attackName, int attackId)
	{
		ZNetView component = ((Component)eikthyr).GetComponent<ZNetView>();
		if (!((Object)(object)component == (Object)null) && component.IsValid() && component.IsOwner())
		{
			ZDO zDO = component.GetZDO();
			zDO.Set("eikthyr_last_attack", attackName);
			zDO.Set("eikthyr_attack_id", attackId);
			if ((Object)(object)ZNet.instance != (Object)null)
			{
				zDO.Set("eikthyr_attack_timestamp", (float)ZNet.instance.GetTimeSeconds());
			}
			zDO.Set("eikthyr_hp", eikthyr.GetHealth());
			zDO.Set("eikthyr_max_hp", eikthyr.GetMaxHealth());
		}
	}
}
[HarmonyPatch(typeof(ZSyncAnimation))]
public static class Patch_ZSyncAnimation_RPC_SetTrigger
{
	[HarmonyPrefix]
	[HarmonyPatch("RPC_SetTrigger", new Type[]
	{
		typeof(long),
		typeof(string)
	})]
	private static void Prefix(ZSyncAnimation __instance, long sender, string name)
	{
		Character val = ((__instance != null) ? ((Component)__instance).GetComponentInParent<Character>() : null);
		if (!((Object)(object)val == (Object)null) && EikthyrTrackerPlugin.IsEikthyr(val) && !(name == "attack1") && !(name == "attack2"))
		{
			RPC.SendAttack("RPC_" + name, name.GetHashCode());
		}
	}
}
[HarmonyPatch(typeof(Aoe), "OnHit")]
public static class Patch_Eikthyr_AoeOnHit
{
	private static void Prefix(Aoe __instance, Collider collider, Vector3 hitPoint)
	{
		if ((Object)(object)__instance == (Object)null)
		{
			return;
		}
		Transform root = ((Component)__instance).transform.root;
		if ((((root != null) ? ((Object)root).name : null) ?? "").Contains("Eikthyr"))
		{
			object obj;
			if (collider == null)
			{
				obj = null;
			}
			else
			{
				GameObject gameObject = ((Component)collider).gameObject;
				obj = ((gameObject != null) ? ((Object)gameObject).name : null);
			}
			if (obj == null)
			{
				obj = "desconocido";
			}
			string text = (string)obj;
			RPC.SendAttack("AOE_Hit_" + text, 900);
		}
	}
}
[HarmonyPatch(typeof(Character), "OnDeath")]
public static class Patch_Eikthyr_Death
{
	private static void Prefix(Character __instance)
	{
		if (!((Object)(object)__instance == (Object)null) && EikthyrTrackerPlugin.IsEikthyr(__instance))
		{
			PhaseSystem.Reset();
			if (ZRoutedRpc.instance != null && (Object)(object)ZNet.instance != (Object)null)
			{
				long num = (ZNet.instance.IsServer() ? ZNet.GetUID() : ZRoutedRpc.instance.GetServerPeerID());
				ZRoutedRpc.instance.InvokeRoutedRPC(num, "EikthyrTracker_BossDefeated", new object[1] { "1" });
			}
			RPC.SendAttack("BOSS_DEFEATED", -1);
		}
	}
}
public static class PhaseSystem
{
	[CompilerGenerated]
	private sealed class <MonitorLoop>d__6 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public int token;

		private List<ZDO> <zdoList>5__2;

		private int <idx>5__3;

		private float <hpPct>5__4;

		private Vector3 <bossPos>5__5;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <MonitorLoop>d__6(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<zdoList>5__2 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			ZDO val;
			float @float;
			float float2;
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				EikthyrTrackerPlugin.Log.LogInfo((object)$"[Phase] Monitor iniciado — sesión {token}.");
				goto IL_006f;
			case 1:
				<>1__state = -1;
				goto IL_006f;
			case 2:
				<>1__state = -1;
				if (_sessionToken != token)
				{
					return false;
				}
				if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
				{
					break;
				}
				<zdoList>5__2 = new List<ZDO>();
				<idx>5__3 = 0;
				goto IL_00f4;
			case 3:
				<>1__state = -1;
				goto IL_00f4;
			case 4:
				<>1__state = -1;
				goto IL_0255;
			case 5:
				{
					<>1__state = -1;
					goto IL_02b8;
				}
				IL_0255:
				if (!_phase2Done && <hpPct>5__4 < 0.45f && _sessionToken == token)
				{
					_phase2Done = true;
					RPC.CurrentPhase = 2;
					EikthyrTrackerPlugin.Log.LogWarning((object)"[Phase] ⚡ ENTRANDO FASE 2");
					<>2__current = ServerCoroutineRunner.RunAndWait(PhaseTransition(<bossPos>5__5, 2));
					<>1__state = 5;
					return true;
				}
				goto IL_02b8;
				IL_006f:
				if (ZDOMan.instance == null)
				{
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				}
				break;
				IL_00f4:
				if (!ZDOMan.instance.GetAllZDOsWithPrefabIterative("Eikthyr", <zdoList>5__2, ref <idx>5__3))
				{
					<>2__current = null;
					<>1__state = 3;
					return true;
				}
				if (_sessionToken != token)
				{
					return false;
				}
				val = null;
				using (List<ZDO>.Enumerator enumerator = <zdoList>5__2.GetEnumerator())
				{
					if (enumerator.MoveNext())
					{
						ZDO current = enumerator.Current;
						val = current;
					}
				}
				if (val == null)
				{
					break;
				}
				@float = val.GetFloat("eikthyr_hp", 0f);
				float2 = val.GetFloat("eikthyr_max_hp", 0f);
				if (float2 <= 0f || @float <= 0f)
				{
					break;
				}
				<hpPct>5__4 = @float / float2;
				<bossPos>5__5 = val.GetPosition();
				EikthyrTrackerPlugin.Log.LogInfo((object)$"[Phase] HP: {@float:F0}/{float2:F0} ({<hpPct>5__4:P0}) | Phase={RPC.CurrentPhase}");
				if (!_phase1Done && <hpPct>5__4 < 0.9f && _sessionToken == token)
				{
					_phase1Done = true;
					RPC.CurrentPhase = 1;
					EikthyrTrackerPlugin.Log.LogWarning((object)"[Phase] ⚡ ENTRANDO FASE 1");
					<>2__current = ServerCoroutineRunner.RunAndWait(PhaseTransition(<bossPos>5__5, 1));
					<>1__state = 4;
					return true;
				}
				goto IL_0255;
				IL_02b8:
				<zdoList>5__2 = null;
				break;
			}
			if (_sessionToken == token)
			{
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 2;
				return true;
			}
			_monitoring = false;
			EikthyrTrackerPlugin.Log.LogInfo((object)$"[Phase] Monitor sesión {token} terminado.");
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <PhaseTransition>d__7 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public int phase;

		public Vector3 bossPos;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <PhaseTransition>d__7(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
			{
				<>1__state = -1;
				CultureInfo invariantCulture = CultureInfo.InvariantCulture;
				ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "EikthyrTracker_Freeze", new object[1] { "1" });
				ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "EikthyrTracker_PhaseImmunity", new object[1] { "1" });
				string text = $"{phase}|{AttackClients.VecToStr(bossPos, invariantCulture)}";
				ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "EikthyrTracker_PhaseTransition", new object[1] { text });
				EikthyrTrackerPlugin.Log.LogWarning((object)$"[Phase] Freeze + FX fase {phase}.");
				<>2__current = (object)new WaitForSeconds(4f);
				<>1__state = 1;
				return true;
			}
			case 1:
				<>1__state = -1;
				ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "EikthyrTracker_Unfreeze", new object[1] { "1" });
				ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "EikthyrTracker_PhaseImmunity", new object[1] { "0" });
				EikthyrTrackerPlugin.Log.LogWarning((object)$"[Phase] Unfreeze — fase {phase} activa.");
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private static bool _phase1Done;

	private static bool _phase2Done;

	private static int _sessionToken;

	private static bool _monitoring;

	public static void Reset()
	{
		_sessionToken++;
		_phase1Done = false;
		_phase2Done = false;
		_monitoring = false;
		RPC.CurrentPhase = 0;
		EikthyrTrackerPlugin.Log.LogInfo((object)$"[Phase] Reset — sesión {_sessionToken}.");
	}

	public static void StartMonitoring()
	{
		if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer() && !_monitoring)
		{
			_monitoring = true;
			int sessionToken = _sessionToken;
			ServerCoroutineRunner.Run(MonitorLoop(sessionToken));
		}
	}

	[IteratorStateMachine(typeof(<MonitorLoop>d__6))]
	private static IEnumerator MonitorLoop(int token)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <MonitorLoop>d__6(0)
		{
			token = token
		};
	}

	[IteratorStateMachine(typeof(<PhaseTransition>d__7))]
	private static IEnumerator PhaseTransition(Vector3 bossPos, int phase)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <PhaseTransition>d__7(0)
		{
			bossPos = bossPos,
			phase = phase
		};
	}
}

BepInEx/plugins/EikthyrLogs.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Utils;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("AichoGuardian")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AichoGuardian")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("D28110A9-E229-4700-AD4D-DCD37486A82B")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace EikthyrTracker;

[BepInPlugin("com.tumod.eikthyrtracker", "EikthyrTracker", "3.7.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class EikthyrTrackerPlugin : BaseUnityPlugin
{
	public const string PluginGUID = "com.tumod.eikthyrtracker";

	public const string PluginName = "EikthyrTracker";

	public const string PluginVersion = "3.7.0";

	internal static ManualLogSource Log;

	private Harmony _harmony;

	internal static float ChargeWindupDelay = 0.5f;

	internal static float ChargeFireDelay = 2.5f;

	private void Awake()
	{
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		Log.LogInfo((object)"[EikthyrTracker] cargando...");
		ConfigEntry<float> cfgWindup = ((BaseUnityPlugin)this).Config.Bind<float>("LightningCharge", "ChargeWindupDelay", 0.5f, "Segundos que Eikthyr permanece quieto antes de que empiecen los orbes.");
		ConfigEntry<float> cfgFire = ((BaseUnityPlugin)this).Config.Bind<float>("LightningCharge", "ChargeFireDelay", 2.5f, "Segundos de wind-up después de los orbes antes de lanzar los proyectiles.");
		ChargeWindupDelay = cfgWindup.Value;
		ChargeFireDelay = cfgFire.Value;
		cfgWindup.SettingChanged += delegate
		{
			ChargeWindupDelay = cfgWindup.Value;
		};
		cfgFire.SettingChanged += delegate
		{
			ChargeFireDelay = cfgFire.Value;
		};
		_harmony = new Harmony("com.tumod.eikthyrtracker");
		_harmony.PatchAll(Assembly.GetExecutingAssembly());
		Log.LogInfo((object)"[EikthyrTracker] Harmony cargado correctamente.");
	}

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

	internal static bool IsEikthyr(Character c)
	{
		if (!Object.op_Implicit((Object)(object)c))
		{
			return false;
		}
		return Utils.GetPrefabName(((Component)c).gameObject) == "Eikthyr";
	}
}
[HarmonyPatch(typeof(ZNet), "Start")]
public static class Patch_ZNet_Start_RPCInit
{
	private static void Postfix()
	{
		if (ZRoutedRpc.instance == null)
		{
			EikthyrTrackerPlugin.Log.LogWarning((object)"[EikthyrTracker] ZRoutedRpc no disponible en ZNet.Start.");
			return;
		}
		RPC.RegisterRPCs();
		ManualLogSource log = EikthyrTrackerPlugin.Log;
		ZNet instance = ZNet.instance;
		log.LogInfo((object)$"[EikthyrTracker] RPCs registrados | isServer={((instance != null) ? new bool?(instance.IsServer()) : null)}");
	}
}
public static class MinionSpawner
{
	private const string BoarPrefab = "Boar";

	private const string MinionName = "Ciervo de Eikthyr";

	private const int MinionCount = 4;

	private const float SpawnRadius = 6f;

	public static void SpawnBoars(Vector3 center)
	{
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: 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_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		ZNetScene instance = ZNetScene.instance;
		GameObject val = ((instance != null) ? instance.GetPrefab("Boar") : null);
		if ((Object)(object)val == (Object)null)
		{
			EikthyrTrackerPlugin.Log.LogError((object)"[EikthyrTracker] Prefab 'Boar' no encontrado en ZNetScene.");
			return;
		}
		Vector3 val2 = default(Vector3);
		for (int i = 0; i < 4; i++)
		{
			float num = (float)i * 90f * ((float)Math.PI / 180f);
			((Vector3)(ref val2))..ctor(Mathf.Cos(num) * 6f, 0f, Mathf.Sin(num) * 6f);
			Vector3 val3 = center + val2;
			if ((Object)(object)ZoneSystem.instance != (Object)null)
			{
				ZoneSystem.instance.GetSolidHeight(val3, ref val3.y, 1000);
			}
			GameObject val4 = Object.Instantiate<GameObject>(val, val3, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f));
			Character component = val4.GetComponent<Character>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_name = "Ciervo de Eikthyr";
			}
			ZNetView component2 = val4.GetComponent<ZNetView>();
			if ((Object)(object)component2 != (Object)null && component2.IsValid())
			{
				component2.GetZDO().Set("override_name", "Ciervo de Eikthyr");
			}
			EikthyrTrackerPlugin.Log.LogInfo((object)string.Format("[EikthyrTracker] \ud83d\udc17 Spawneado '{0}' en {1}", "Ciervo de Eikthyr", val3));
		}
	}
}
public static class AttackClients
{
	[CompilerGenerated]
	private sealed class <>c__DisplayClass9_0
	{
		public Vector3 bossPos;

		internal int <FireLCProjectiles>b__0(Vector3 a, Vector3 b)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			return Vector3.Distance(b, bossPos).CompareTo(Vector3.Distance(a, bossPos));
		}
	}

	[CompilerGenerated]
	private sealed class <CoLightningCharge>d__8 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public float windupDelay;

		public Vector3 bossPos;

		public MonoBehaviour runner;

		public float fireDelay;

		private GameObject <lightningVFXInstance>5__2;

		private GameObject <chargePrefab>5__3;

		private int <chargeCount>5__4;

		private int <tandas>5__5;

		private float <delayEntreTandas>5__6;

		private int <t>5__7;

		private int <i>5__8;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <CoLightningCharge>d__8(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<lightningVFXInstance>5__2 = null;
			<chargePrefab>5__3 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Expected O, but got Unknown
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Expected O, but got Unknown
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Expected O, but got Unknown
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Expected O, but got Unknown
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(windupDelay);
				<>1__state = 1;
				return true;
			case 1:
			{
				<>1__state = -1;
				ZNetScene instance2 = ZNetScene.instance;
				GameObject val7 = ((instance2 != null) ? instance2.GetPrefab("fx_lightning") : null);
				<lightningVFXInstance>5__2 = null;
				if ((Object)(object)val7 != (Object)null)
				{
					<lightningVFXInstance>5__2 = Object.Instantiate<GameObject>(val7, bossPos + Vector3.up * 1f, Quaternion.identity);
					ParticleSystem[] componentsInChildren5 = <lightningVFXInstance>5__2.GetComponentsInChildren<ParticleSystem>();
					foreach (ParticleSystem val8 in componentsInChildren5)
					{
						MainModule main2 = val8.main;
						((MainModule)(ref main2)).maxParticles = 500;
						MinMaxCurve val9 = ((MainModule)(ref main2)).startSize;
						((MainModule)(ref main2)).startSize = new MinMaxCurve(((MinMaxCurve)(ref val9)).constant * 2f);
						EmissionModule emission = val8.emission;
						val9 = ((EmissionModule)(ref emission)).rateOverTime;
						((EmissionModule)(ref emission)).rateOverTime = new MinMaxCurve(((MinMaxCurve)(ref val9)).constant * 3f);
					}
				}
				<>2__current = (object)new WaitForSeconds(0.5f);
				<>1__state = 2;
				return true;
			}
			case 2:
			{
				<>1__state = -1;
				ZNetScene instance = ZNetScene.instance;
				<chargePrefab>5__3 = ((instance != null) ? instance.GetPrefab("projectile_stormcaller_staff_sphere_DO") : null);
				if ((Object)(object)<chargePrefab>5__3 != (Object)null)
				{
					<chargeCount>5__4 = 10;
					<tandas>5__5 = 5;
					<delayEntreTandas>5__6 = 0.02f;
					<t>5__7 = 0;
					goto IL_0415;
				}
				goto IL_0426;
			}
			case 3:
				<>1__state = -1;
				<i>5__8++;
				goto IL_03d2;
			case 4:
				<>1__state = -1;
				<t>5__7++;
				goto IL_0415;
			case 5:
				<>1__state = -1;
				if (Object.op_Implicit((Object)(object)<lightningVFXInstance>5__2))
				{
					Object.Destroy((Object)(object)<lightningVFXInstance>5__2);
				}
				<>2__current = (object)new WaitForSeconds(fireDelay);
				<>1__state = 6;
				return true;
			case 6:
				{
					<>1__state = -1;
					EikthyrTrackerPlugin.Log.LogInfo((object)"[LC] Visuales charge ejecutados — esperando FireBroadcast.");
					return false;
				}
				IL_0426:
				<>2__current = (object)new WaitForSeconds(0.1f);
				<>1__state = 5;
				return true;
				IL_0415:
				if (<t>5__7 < <tandas>5__5)
				{
					<i>5__8 = 0;
					goto IL_03d2;
				}
				goto IL_0426;
				IL_03d2:
				if (<i>5__8 < <chargeCount>5__4)
				{
					float num = 360f / (float)<chargeCount>5__4 * (float)<i>5__8 + (float)<t>5__7 * 12f;
					float num2 = 3f;
					float num3 = 3f + Random.Range(0f, 2f);
					Vector3 val = default(Vector3);
					((Vector3)(ref val))..ctor(bossPos.x + Mathf.Sin(num * ((float)Math.PI / 180f)) * num2, bossPos.y + num3, bossPos.z + Mathf.Cos(num * ((float)Math.PI / 180f)) * num2);
					GameObject val2 = Object.Instantiate<GameObject>(<chargePrefab>5__3, val, Quaternion.identity);
					Projectile component = val2.GetComponent<Projectile>();
					if (Object.op_Implicit((Object)(object)component))
					{
						((Behaviour)component).enabled = false;
					}
					Rigidbody component2 = val2.GetComponent<Rigidbody>();
					if (Object.op_Implicit((Object)(object)component2))
					{
						component2.useGravity = false;
						component2.velocity = Vector3.zero;
					}
					ZNetView[] componentsInChildren = val2.GetComponentsInChildren<ZNetView>(true);
					foreach (ZNetView val3 in componentsInChildren)
					{
						Object.Destroy((Object)(object)val3);
					}
					ZSyncTransform[] componentsInChildren2 = val2.GetComponentsInChildren<ZSyncTransform>(true);
					foreach (ZSyncTransform val4 in componentsInChildren2)
					{
						Object.Destroy((Object)(object)val4);
					}
					ParticleSystem[] componentsInChildren3 = val2.GetComponentsInChildren<ParticleSystem>();
					foreach (ParticleSystem val5 in componentsInChildren3)
					{
						MainModule main = val5.main;
						((MainModule)(ref main)).startColor = new MinMaxGradient(Color.yellow);
					}
					Renderer[] componentsInChildren4 = val2.GetComponentsInChildren<Renderer>();
					foreach (Renderer val6 in componentsInChildren4)
					{
						val6.material.color = Color.yellow;
						if (val6.material.HasProperty("_EmissionColor"))
						{
							val6.material.SetColor("_EmissionColor", Color.yellow * 2f);
						}
					}
					runner.StartCoroutine(MoveOrbeToBossPos(val2, bossPos));
					<>2__current = (object)new WaitForSeconds(<delayEntreTandas>5__6);
					<>1__state = 3;
					return true;
				}
				<>2__current = (object)new WaitForSeconds(0.1f);
				<>1__state = 4;
				return true;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <CoLightningRays>d__14 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Vector3 bossPos;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <CoLightningRays>d__14(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			if (<>1__state != 0)
			{
				return false;
			}
			<>1__state = -1;
			ZNetScene instance = ZNetScene.instance;
			GameObject val = ((instance != null) ? instance.GetPrefab("lightningAOE") : null);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			GameObject val2 = Object.Instantiate<GameObject>(val, bossPos, Quaternion.identity);
			ParticleSystem[] componentsInChildren = val2.GetComponentsInChildren<ParticleSystem>();
			foreach (ParticleSystem val3 in componentsInChildren)
			{
				MainModule main = val3.main;
				((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Color.cyan);
			}
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <CoLightningRaysVisuals>d__15 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public List<Vector3> group1;

		public List<Vector3> group2;

		private List<GameObject> <circles1>5__2;

		private List<GameObject> <circles2>5__3;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <CoLightningRaysVisuals>d__15(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<circles1>5__2 = null;
			<circles2>5__3 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_00e3: 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_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: 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_0116: Expected O, but got Unknown
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Expected O, but got Unknown
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Expected O, but got Unknown
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Expected O, but got Unknown
			//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)
			//IL_007b: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
			{
				<>1__state = -1;
				ZNetScene instance = ZNetScene.instance;
				GameObject val = ((instance != null) ? instance.GetPrefab("lightningAOE") : null);
				if ((Object)(object)val == (Object)null)
				{
					return false;
				}
				<circles1>5__2 = new List<GameObject>();
				foreach (Vector3 item in group1)
				{
					<circles1>5__2.Add(SpawnWarningCircle(item, 1.5f, Color.cyan));
				}
				<>2__current = (object)new WaitForSeconds(1.2f);
				<>1__state = 1;
				return true;
			}
			case 1:
				<>1__state = -1;
				foreach (GameObject item2 in <circles1>5__2)
				{
					SetCircleColor(item2, Color.white);
				}
				<>2__current = (object)new WaitForSeconds(0.4f);
				<>1__state = 2;
				return true;
			case 2:
				<>1__state = -1;
				foreach (GameObject item3 in <circles1>5__2)
				{
					SetCircleColor(item3, Color.yellow);
				}
				<>2__current = (object)new WaitForSeconds(0.3f);
				<>1__state = 3;
				return true;
			case 3:
				<>1__state = -1;
				foreach (GameObject item4 in <circles1>5__2)
				{
					if (Object.op_Implicit((Object)(object)item4))
					{
						Object.Destroy((Object)(object)item4);
					}
				}
				foreach (Vector3 item5 in group1)
				{
					SpawnLocalFX("lightningAOE", item5, Color.cyan);
				}
				<circles2>5__3 = new List<GameObject>();
				foreach (Vector3 item6 in group2)
				{
					<circles2>5__3.Add(SpawnWarningCircle(item6, 1.5f, Color.cyan));
				}
				<>2__current = (object)new WaitForSeconds(1.2f);
				<>1__state = 4;
				return true;
			case 4:
				<>1__state = -1;
				foreach (GameObject item7 in <circles2>5__3)
				{
					SetCircleColor(item7, Color.white);
				}
				<>2__current = (object)new WaitForSeconds(0.4f);
				<>1__state = 5;
				return true;
			case 5:
				<>1__state = -1;
				foreach (GameObject item8 in <circles2>5__3)
				{
					SetCircleColor(item8, Color.yellow);
				}
				<>2__current = (object)new WaitForSeconds(0.3f);
				<>1__state = 6;
				return true;
			case 6:
				<>1__state = -1;
				foreach (GameObject item9 in <circles2>5__3)
				{
					if (Object.op_Implicit((Object)(object)item9))
					{
						Object.Destroy((Object)(object)item9);
					}
				}
				foreach (Vector3 item10 in group2)
				{
					SpawnLocalFX("lightningAOE", item10, Color.cyan);
				}
				EikthyrTrackerPlugin.Log.LogInfo((object)"[Rays] Visuales ejecutados.");
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <CoStompAOE>d__17 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Vector3 bossPos;

		private int <count>5__2;

		private float <radius>5__3;

		private List<GameObject> <circles>5__4;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <CoStompAOE>d__17(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<circles>5__4 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
			{
				<>1__state = -1;
				ZNetScene instance = ZNetScene.instance;
				GameObject val3 = ((instance != null) ? instance.GetPrefab("lightningAOE") : null);
				if ((Object)(object)val3 == (Object)null)
				{
					return false;
				}
				<count>5__2 = 8;
				<radius>5__3 = 4f;
				<circles>5__4 = new List<GameObject>();
				for (int j = 0; j < <count>5__2; j++)
				{
					float num2 = 360f / (float)<count>5__2 * (float)j * ((float)Math.PI / 180f);
					Vector3 center = bossPos + new Vector3(Mathf.Sin(num2) * <radius>5__3, 0f, Mathf.Cos(num2) * <radius>5__3);
					<circles>5__4.Add(SpawnWarningCircle(center, 1.5f, Color.yellow));
				}
				<>2__current = (object)new WaitForSeconds(1.5f);
				<>1__state = 1;
				return true;
			}
			case 1:
				<>1__state = -1;
				foreach (GameObject item in <circles>5__4)
				{
					SetCircleColor(item, Color.white);
				}
				<>2__current = (object)new WaitForSeconds(0.3f);
				<>1__state = 2;
				return true;
			case 2:
			{
				<>1__state = -1;
				foreach (GameObject item2 in <circles>5__4)
				{
					if (Object.op_Implicit((Object)(object)item2))
					{
						Object.Destroy((Object)(object)item2);
					}
				}
				RaycastHit val2 = default(RaycastHit);
				for (int i = 0; i < <count>5__2; i++)
				{
					float num = 360f / (float)<count>5__2 * (float)i * ((float)Math.PI / 180f);
					Vector3 val = bossPos + new Vector3(Mathf.Sin(num) * <radius>5__3, 0f, Mathf.Cos(num) * <radius>5__3);
					if (Physics.Raycast(val + Vector3.up * 50f, Vector3.down, ref val2, 100f))
					{
						val.y = ((RaycastHit)(ref val2)).point.y;
					}
					SpawnLocalFX("lightningAOE", val, Color.yellow);
				}
				EikthyrTrackerPlugin.Log.LogInfo((object)"[Stomp] Visuales ejecutados (local-only).");
				return false;
			}
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <FireLCProjectiles>d__9 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Vector3 bossPos;

		public List<Vector3> targets;

		private <>c__DisplayClass9_0 <>8__1;

		public MonoBehaviour runner;

		private GameObject <projectilePrefab>5__2;

		private int <fanCount>5__3;

		private float <projSpeed>5__4;

		private Vector3 <origin>5__5;

		private int <i>5__6;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <FireLCProjectiles>d__9(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>8__1 = null;
			<projectilePrefab>5__2 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: 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_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: 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_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
			{
				<>1__state = -1;
				<>8__1 = new <>c__DisplayClass9_0();
				<>8__1.bossPos = bossPos;
				ZNetScene instance = ZNetScene.instance;
				<projectilePrefab>5__2 = ((instance != null) ? instance.GetPrefab("projectile_stormcaller_staff_sphere_DO") : null);
				if ((Object)(object)<projectilePrefab>5__2 == (Object)null)
				{
					return false;
				}
				<fanCount>5__3 = 6;
				<projSpeed>5__4 = 14f;
				<origin>5__5 = <>8__1.bossPos + Vector3.up * 2f;
				targets.Sort((Vector3 a, Vector3 b) => Vector3.Distance(b, <>8__1.bossPos).CompareTo(Vector3.Distance(a, <>8__1.bossPos)));
				<i>5__6 = 0;
				break;
			}
			case 1:
				<>1__state = -1;
				<i>5__6++;
				break;
			}
			if (<i>5__6 < <fanCount>5__3)
			{
				Vector3 val;
				Vector3 val2;
				if (<i>5__6 < targets.Count)
				{
					val = targets[<i>5__6] + Vector3.up - <origin>5__5;
					val2 = ((Vector3)(ref val)).normalized;
					float num = Random.Range(-5f, 5f);
					val2 = Quaternion.Euler(0f, num, 0f) * val2;
				}
				else if (targets.Count > 0)
				{
					Vector3 val3 = targets[Random.Range(0, targets.Count)];
					val = val3 + Vector3.up - <origin>5__5;
					val2 = ((Vector3)(ref val)).normalized;
					float num2 = Random.Range(-15f, 15f);
					val2 = Quaternion.Euler(0f, num2, 0f) * val2;
				}
				else
				{
					float num3 = Random.Range(0f, 360f);
					float num4 = Random.Range(5f, 20f);
					Vector3 val4 = default(Vector3);
					((Vector3)(ref val4))..ctor(<>8__1.bossPos.x + Mathf.Sin(num3 * ((float)Math.PI / 180f)) * num4, <>8__1.bossPos.y, <>8__1.bossPos.z + Mathf.Cos(num3 * ((float)Math.PI / 180f)) * num4);
					val = val4 + Vector3.up - <origin>5__5;
					val2 = ((Vector3)(ref val)).normalized;
				}
				((Vector3)(ref val2)).Normalize();
				GameObject val5 = Object.Instantiate<GameObject>(<projectilePrefab>5__2, <origin>5__5, Quaternion.LookRotation(val2));
				Projectile component = val5.GetComponent<Projectile>();
				if (Object.op_Implicit((Object)(object)component))
				{
					((Behaviour)component).enabled = false;
				}
				Rigidbody component2 = val5.GetComponent<Rigidbody>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					component2.isKinematic = true;
					component2.useGravity = false;
				}
				ZNetView[] componentsInChildren = val5.GetComponentsInChildren<ZNetView>(true);
				foreach (ZNetView val6 in componentsInChildren)
				{
					Object.Destroy((Object)(object)val6);
				}
				ZSyncTransform[] componentsInChildren2 = val5.GetComponentsInChildren<ZSyncTransform>(true);
				foreach (ZSyncTransform val7 in componentsInChildren2)
				{
					Object.Destroy((Object)(object)val7);
				}
				ParticleSystem[] componentsInChildren3 = val5.GetComponentsInChildren<ParticleSystem>();
				foreach (ParticleSystem val8 in componentsInChildren3)
				{
					MainModule main = val8.main;
					((MainModule)(ref main)).startColor = new MinMaxGradient(Color.yellow);
				}
				Renderer[] componentsInChildren4 = val5.GetComponentsInChildren<Renderer>();
				foreach (Renderer val9 in componentsInChildren4)
				{
					val9.material.color = Color.yellow;
					if (val9.material.HasProperty("_EmissionColor"))
					{
						val9.material.SetColor("_EmissionColor", Color.yellow * 2f);
					}
				}
				runner.StartCoroutine(MoveProjInDirection(val5, val2, <projSpeed>5__4, 3f, 10f, 0.8f));
				<>2__current = null;
				<>1__state = 1;
				return true;
			}
			EikthyrTrackerPlugin.Log.LogInfo((object)"[LC] Proyectiles disparados hacia jugadores.");
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <MoveOrbeToBossPos>d__11 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Vector3 bossPos;

		public GameObject proj;

		private float <speed>5__2;

		private Vector3 <target>5__3;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <MoveOrbeToBossPos>d__11(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_00ab: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<speed>5__2 = 6f;
				<target>5__3 = bossPos + Vector3.up * 1.5f;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if ((Object)(object)proj != (Object)null)
			{
				float num = Vector3.Distance(proj.transform.position, <target>5__3);
				if (num <= 0.5f)
				{
					Object.Destroy((Object)(object)proj);
					return false;
				}
				Vector3 val = <target>5__3 - proj.transform.position;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				Transform transform = proj.transform;
				transform.position += normalized * <speed>5__2 * Time.deltaTime;
				proj.transform.rotation = Quaternion.LookRotation(normalized);
				<>2__current = null;
				<>1__state = 1;
				return true;
			}
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <MoveProjInDirection>d__10 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public GameObject proj;

		public Vector3 dir;

		public float speed;

		public float hitDamage;

		public float hitRadius;

		public float maxTime;

		private float <elapsed>5__2;

		private bool <hasHit>5__3;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <MoveProjInDirection>d__10(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_0114: 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_0139: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<elapsed>5__2 = 0f;
				<hasHit>5__3 = false;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if ((Object)(object)proj != (Object)null && <elapsed>5__2 < maxTime && !<hasHit>5__3)
			{
				Transform transform = proj.transform;
				transform.position += dir * speed * Time.deltaTime;
				proj.transform.rotation = Quaternion.LookRotation(dir);
				<elapsed>5__2 += Time.deltaTime;
				if (hitDamage > 0f && (Object)(object)Player.m_localPlayer != (Object)null && !((Character)Player.m_localPlayer).IsDead())
				{
					float num = Vector3.Distance(proj.transform.position, ((Component)Player.m_localPlayer).transform.position + Vector3.up);
					if (num <= hitRadius)
					{
						<hasHit>5__3 = true;
						HitData val = new HitData();
						val.m_point = proj.transform.position;
						val.m_damage.m_lightning = hitDamage;
						val.m_ranged = true;
						val.m_hitType = (HitType)16;
						((Character)Player.m_localPlayer).Damage(val);
						EikthyrTrackerPlugin.Log.LogWarning((object)$"[LC Proj] \ud83d\udca5 Impacto — {hitDamage} lightning");
					}
				}
				<>2__current = null;
				<>1__state = 1;
				return true;
			}
			if ((Object)(object)proj != (Object)null)
			{
				Object.Destroy((Object)(object)proj);
			}
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public const float ChargeSpawnRadius = 3f;

	public const float ChargeSpawnHeight = 3f;

	public static Vector3 ParseVec(string s, CultureInfo ci)
	{
		//IL_0039: 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)
		string[] array = s.Split(new char[1] { ',' });
		if (array.Length < 3)
		{
			return Vector3.zero;
		}
		return new Vector3(float.Parse(array[0], ci), float.Parse(array[1], ci), float.Parse(array[2], ci));
	}

	public static string VecToStr(Vector3 v, CultureInfo ci)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		return string.Format(ci, "{0},{1},{2}", v.x, v.y, v.z);
	}

	public static GameObject SpawnWarningCircle(Vector3 center, float radius, Color color)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Expected O, but got Unknown
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: 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)
		GameObject val = new GameObject("EK_WarningCircle");
		val.transform.position = center + Vector3.up * 0.1f;
		LineRenderer val2 = val.AddComponent<LineRenderer>();
		val2.useWorldSpace = false;
		val2.loop = true;
		val2.widthMultiplier = 0.12f;
		val2.positionCount = 32;
		((Renderer)val2).material = new Material(Shader.Find("Sprites/Default"));
		val2.startColor = color;
		val2.endColor = color;
		for (int i = 0; i < 32; i++)
		{
			float num = 11.25f * (float)i * ((float)Math.PI / 180f);
			val2.SetPosition(i, new Vector3(Mathf.Sin(num) * radius, 0f, Mathf.Cos(num) * radius));
		}
		return val;
	}

	public static void SetCircleColor(GameObject go, Color color)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)go))
		{
			LineRenderer component = go.GetComponent<LineRenderer>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.startColor = color;
				component.endColor = color;
			}
		}
	}

	public static void SpawnLocalFX(string prefabName, Vector3 pos, Color color, float lifetime = 3f)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Expected O, but got Unknown
		//IL_0039: 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_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Expected O, but got Unknown
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: 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_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		ZNetScene instance = ZNetScene.instance;
		GameObject val = ((instance != null) ? instance.GetPrefab(prefabName) : null);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		GameObject val2 = new GameObject("EK_FX_" + prefabName + "_Local");
		val2.transform.position = pos;
		ParticleSystem[] componentsInChildren = val.GetComponentsInChildren<ParticleSystem>(true);
		foreach (ParticleSystem val3 in componentsInChildren)
		{
			GameObject val4 = Object.Instantiate<GameObject>(((Component)val3).gameObject, pos, ((Component)val3).transform.rotation, val2.transform);
			ZNetView[] componentsInChildren2 = val4.GetComponentsInChildren<ZNetView>(true);
			foreach (ZNetView val5 in componentsInChildren2)
			{
				Object.Destroy((Object)(object)val5);
			}
			ZSyncTransform[] componentsInChildren3 = val4.GetComponentsInChildren<ZSyncTransform>(true);
			foreach (ZSyncTransform val6 in componentsInChildren3)
			{
				Object.Destroy((Object)(object)val6);
			}
			MainModule main = val4.GetComponent<ParticleSystem>().main;
			((MainModule)(ref main)).startColor = new MinMaxGradient(color);
		}
		AudioSource[] componentsInChildren4 = val.GetComponentsInChildren<AudioSource>(true);
		foreach (AudioSource val7 in componentsInChildren4)
		{
			GameObject val8 = new GameObject("EK_Audio");
			val8.transform.SetParent(val2.transform);
			val8.transform.position = pos;
			AudioSource val9 = val8.AddComponent<AudioSource>();
			val9.clip = val7.clip;
			val9.volume = val7.volume;
			val9.pitch = val7.pitch;
			val9.spatialBlend = val7.spatialBlend;
			val9.minDistance = val7.minDistance;
			val9.maxDistance = val7.maxDistance;
			val9.rolloffMode = val7.rolloffMode;
			val9.Play();
		}
		Object.Destroy((Object)(object)val2, lifetime);
	}

	public static void ExecuteLightningCharge(string payload, MonoBehaviour runner)
	{
		//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_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		CultureInfo invariantCulture = CultureInfo.InvariantCulture;
		string[] array = payload.Split(new char[1] { '|' });
		if (array.Length < 2)
		{
			EikthyrTrackerPlugin.Log.LogError((object)("[LC] payload inválido: '" + payload + "'"));
			return;
		}
		Vector3 bossPos = ParseVec(array[0], invariantCulture);
		Vector3 bossForward = ParseVec(array[1], invariantCulture);
		float result = EikthyrTrackerPlugin.ChargeWindupDelay;
		float result2 = EikthyrTrackerPlugin.ChargeFireDelay;
		if (array.Length >= 3)
		{
			float.TryParse(array[2], NumberStyles.Float, invariantCulture, out result);
		}
		if (array.Length >= 4)
		{
			float.TryParse(array[3], NumberStyles.Float, invariantCulture, out result2);
		}
		runner.StartCoroutine(CoLightningCharge(runner, bossPos, bossForward, result, result2));
	}

	[IteratorStateMachine(typeof(<CoLightningCharge>d__8))]
	private static IEnumerator CoLightningCharge(MonoBehaviour runner, Vector3 bossPos, Vector3 bossForward, float windupDelay, float fireDelay)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <CoLightningCharge>d__8(0)
		{
			runner = runner,
			bossPos = bossPos,
			windupDelay = windupDelay,
			fireDelay = fireDelay
		};
	}

	[IteratorStateMachine(typeof(<FireLCProjectiles>d__9))]
	public static IEnumerator FireLCProjectiles(Vector3 bossPos, List<Vector3> targets, MonoBehaviour runner)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <FireLCProjectiles>d__9(0)
		{
			bossPos = bossPos,
			targets = targets,
			runner = runner
		};
	}

	[IteratorStateMachine(typeof(<MoveProjInDirection>d__10))]
	private static IEnumerator MoveProjInDirection(GameObject proj, Vector3 dir, float speed, float maxTime, float hitDamage = 0f, float hitRadius = 0.6f)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <MoveProjInDirection>d__10(0)
		{
			proj = proj,
			dir = dir,
			speed = speed,
			maxTime = maxTime,
			hitDamage = hitDamage,
			hitRadius = hitRadius
		};
	}

	[IteratorStateMachine(typeof(<MoveOrbeToBossPos>d__11))]
	private static IEnumerator MoveOrbeToBossPos(GameObject proj, Vector3 bossPos)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <MoveOrbeToBossPos>d__11(0)
		{
			proj = proj,
			bossPos = bossPos
		};
	}

	public static void ExecuteLightningRays(string payload, MonoBehaviour runner)
	{
		//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_000f: Unknown result type (might be due to invalid IL or missing references)
		CultureInfo invariantCulture = CultureInfo.InvariantCulture;
		Vector3 bossPos = ParseVec(payload, invariantCulture);
		runner.StartCoroutine(CoLightningRays(bossPos));
	}

	public static void ExecuteLightningRaysWithGroups(string payload, MonoBehaviour runner)
	{
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		CultureInfo invariantCulture = CultureInfo.InvariantCulture;
		string[] array = payload.Split(new char[1] { '|' });
		if (array.Length < 3)
		{
			EikthyrTrackerPlugin.Log.LogError((object)("[Rays] payload inválido: '" + payload + "'"));
			return;
		}
		List<Vector3> list = new List<Vector3>();
		List<Vector3> list2 = new List<Vector3>();
		string[] array2 = array[1].Split(new char[1] { ';' });
		foreach (string text in array2)
		{
			if (!string.IsNullOrEmpty(text))
			{
				list.Add(ParseVec(text, invariantCulture));
			}
		}
		string[] array3 = array[2].Split(new char[1] { ';' });
		foreach (string text2 in array3)
		{
			if (!string.IsNullOrEmpty(text2))
			{
				list2.Add(ParseVec(text2, invariantCulture));
			}
		}
		runner.StartCoroutine(CoLightningRaysVisuals(list, list2));
	}

	[IteratorStateMachine(typeof(<CoLightningRays>d__14))]
	private static IEnumerator CoLightningRays(Vector3 bossPos)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <CoLightningRays>d__14(0)
		{
			bossPos = bossPos
		};
	}

	[IteratorStateMachine(typeof(<CoLightningRaysVisuals>d__15))]
	private static IEnumerator CoLightningRaysVisuals(List<Vector3> group1, List<Vector3> group2)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <CoLightningRaysVisuals>d__15(0)
		{
			group1 = group1,
			group2 = group2
		};
	}

	public static void ExecuteStompAOE(string payload, MonoBehaviour runner)
	{
		//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_000f: Unknown result type (might be due to invalid IL or missing references)
		CultureInfo invariantCulture = CultureInfo.InvariantCulture;
		Vector3 bossPos = ParseVec(payload, invariantCulture);
		runner.StartCoroutine(CoStompAOE(bossPos));
	}

	[IteratorStateMachine(typeof(<CoStompAOE>d__17))]
	private static IEnumerator CoStompAOE(Vector3 bossPos)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <CoStompAOE>d__17(0)
		{
			bossPos = bossPos
		};
	}
}
public static class ServerCoroutineRunner
{
	private static ServerCoroutineRunnerMB _instance;

	public static void Run(IEnumerator coroutine)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Expected O, but got Unknown
		if ((Object)(object)_instance == (Object)null)
		{
			GameObject val = new GameObject("EikthyrServerRunner");
			Object.DontDestroyOnLoad((Object)(object)val);
			_instance = val.AddComponent<ServerCoroutineRunnerMB>();
		}
		((MonoBehaviour)_instance).StartCoroutine(coroutine);
	}
}
public class ServerCoroutineRunnerMB : MonoBehaviour
{
}
public static class RPC
{
	[CompilerGenerated]
	private sealed class <ApplyDamageDelayed>d__41 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public float delay;

		public Player player;

		public bool checkProximity;

		public Vector3 impactPos;

		public float dmg;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <ApplyDamageDelayed>d__41(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				if (delay > 0f)
				{
					<>2__current = (object)new WaitForSeconds(delay);
					<>1__state = 1;
					return true;
				}
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if ((Object)(object)player == (Object)null || ((Character)player).IsDead())
			{
				return false;
			}
			if (checkProximity && Vector3.Distance(((Component)player).transform.position, impactPos) > 3f)
			{
				EikthyrTrackerPlugin.Log.LogInfo((object)$"[CLIENT Rays] Jugador fuera del rayo ({Vector3.Distance(((Component)player).transform.position, impactPos):F1}u) — daño cancelado.");
				return false;
			}
			HitData val = new HitData();
			val.m_point = ((Component)player).transform.position;
			val.m_damage.m_lightning = dmg;
			val.m_ranged = true;
			val.m_hitType = (HitType)16;
			((Character)player).Damage(val);
			EikthyrTrackerPlugin.Log.LogWarning((object)$"[CLIENT Rays] \ud83d\udca5 Daño: {dmg} lightning");
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <LCSequence_Server>d__31 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public string payload;

		public Vector3 bossForward;

		public Vector3 bossPos;

		private float <fireDelay>5__2;

		private CultureInfo <ci>5__3;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <LCSequence_Server>d__31(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<ci>5__3 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Expected O, but got Unknown
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
			{
				<>1__state = -1;
				float chargeWindupDelay = EikthyrTrackerPlugin.ChargeWindupDelay;
				<fireDelay>5__2 = EikthyrTrackerPlugin.ChargeFireDelay;
				float num = chargeWindupDelay + 0.5f + 1.6f + 0.1f + <fireDelay>5__2;
				float num2 = num - <fireDelay>5__2;
				<ci>5__3 = CultureInfo.InvariantCulture;
				ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "EikthyrTracker_Freeze", new object[1] { "1" });
				EikthyrTrackerPlugin.Log.LogInfo((object)"[SERVER LC] Broadcast FreezeEikthyr enviado.");
				string text2 = payload + "|" + chargeWindupDelay.ToString(<ci>5__3) + "|" + <fireDelay>5__2.ToString(<ci>5__3);
				ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "EikthyrTracker_LCBroadcast", new object[1] { text2 });
				<>2__current = (object)new WaitForSeconds(num2);
				<>1__state = 1;
				return true;
			}
			case 1:
				<>1__state = -1;
				ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "EikthyrTracker_Unfreeze", new object[1] { "1" });
				EikthyrTrackerPlugin.Log.LogInfo((object)"[SERVER LC] UnfreezeEikthyr — boss libre para lanzar.");
				<>2__current = (object)new WaitForSeconds(<fireDelay>5__2);
				<>1__state = 2;
				return true;
			case 2:
			{
				<>1__state = -1;
				Vector3 forward = bossForward;
				forward.y = 0f;
				if (forward == Vector3.zero)
				{
					forward = Vector3.forward;
				}
				((Vector3)(ref forward)).Normalize();
				List<Vector3> list = new List<Vector3>();
				foreach (ZNetPeer connectedPeer in ZNet.instance.GetConnectedPeers())
				{
					if (connectedPeer.m_characterID == ZDOID.None)
					{
						continue;
					}
					ZDO zDO = ZDOMan.instance.GetZDO(connectedPeer.m_characterID);
					if (zDO != null)
					{
						Vector3 position = zDO.GetPosition();
						if (!(Vector3.Distance(position, bossPos) > 30f))
						{
							list.Add(position);
							Log.LogInfo((object)("[SERVER LC] Target añadido: " + connectedPeer.m_playerName));
						}
					}
				}
				if (list.Count > 0)
				{
					StringBuilder stringBuilder = new StringBuilder();
					for (int i = 0; i < list.Count; i++)
					{
						if (i > 0)
						{
							stringBuilder.Append(';');
						}
						stringBuilder.Append(AttackClients.VecToStr(list[i], <ci>5__3));
					}
					string text = $"{AttackClients.VecToStr(bossPos, <ci>5__3)}|{stringBuilder}";
					ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "EikthyrTracker_LCFire", new object[1] { text });
				}
				_lcInProgress = false;
				EikthyrTrackerPlugin.Log.LogInfo((object)"[SERVER LC] LC completado — flag reseteado.");
				return false;
			}
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <ReenableAI>d__32 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public float delay;

		public MonsterAI ai;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <ReenableAI>d__32(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(delay);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				if ((Object)(object)ai != (Object)null)
				{
					((Behaviour)ai).enabled = true;
					EikthyrTrackerPlugin.Log.LogInfo((object)"[SERVER LC] MonsterAI reactivado.");
				}
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <StompDamageSequence>d__43 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Vector3 bossPos;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <StompDamageSequence>d__43(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(1.8f);
				<>1__state = 1;
				return true;
			case 1:
			{
				<>1__state = -1;
				int num = 8;
				float num2 = 4f;
				foreach (ZNetPeer connectedPeer in ZNet.instance.GetConnectedPeers())
				{
					if (connectedPeer.m_characterID == ZDOID.None)
					{
						continue;
					}
					ZDO zDO = ZDOMan.instance.GetZDO(connectedPeer.m_characterID);
					if (zDO == null)
					{
						continue;
					}
					Vector3 position = zDO.GetPosition();
					bool flag = false;
					for (int i = 0; i < num; i++)
					{
						float num3 = 360f / (float)num * (float)i * ((float)Math.PI / 180f);
						Vector3 val = bossPos + new Vector3(Mathf.Sin(num3) * num2, 0f, Mathf.Cos(num3) * num2);
						if (Vector3.Distance(position, val) <= 2.5f)
						{
							flag = true;
							break;
						}
					}
					if (flag)
					{
						ZRoutedRpc.instance.InvokeRoutedRPC(connectedPeer.m_uid, "EikthyrTracker_StompDamage", new object[1] { "15" });
						Log.LogWarning((object)("[SERVER Stomp] \ud83d\udca5 Daño → " + connectedPeer.m_playerName));
					}
				}
				_stompInProgress = false;
				EikthyrTrackerPlugin.Log.LogInfo((object)"[SERVER Stomp] Flag reseteado.");
				return false;
			}
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public const string EikthyrAttack = "EikthyrTracker_AttackDetected";

	public const string EikthyrSummoned = "EikthyrTracker_BossSummoned";

	public const string EikthyrSpawnMinions = "EikthyrTracker_SpawnMinions";

	public const string LCRequest = "EikthyrTracker_LCRequest";

	public const string LCBroadcast = "EikthyrTracker_LCBroadcast";

	public const string LCDamage = "EikthyrTracker_LCDamage";

	public const string FreezeEikthyr = "EikthyrTracker_Freeze";

	public const string UnfreezeEikthyr = "EikthyrTracker_Unfreeze";

	public const string LCFireBroadcast = "EikthyrTracker_LCFire";

	public const string RaysRequest = "EikthyrTracker_RaysRequest";

	public const string RaysBroadcast = "EikthyrTracker_RaysBroadcast";

	public const string RaysDamage = "EikthyrTracker_RaysDamage";

	public const string StompRequest = "EikthyrTracker_StompRequest";

	public const string StompBroadcast = "EikthyrTracker_StompBroadcast";

	public const string StompDamage = "EikthyrTracker_StompDamage";

	private static float _lastLCTime = -99f;

	private static float _lastRaysTime = -99f;

	private static float _lastStompTime = -99f;

	private const float LCCooldown = 3f;

	private const float RaysCooldown = 4f;

	private const float StompCooldown = 3f;

	private static bool _minionsAlreadySpawned = false;

	private static bool _lcInProgress = false;

	private static bool _stompInProgress = false;

	private static ManualLogSource Log => EikthyrTrackerPlugin.Log;

	public static void RegisterRPCs()
	{
		ZRoutedRpc.instance.Register<string, int>("EikthyrTracker_AttackDetected", (Action<long, string, int>)OnEikthyrAttack_Server);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_BossSummoned", (Action<long, string>)OnEikthyrSummoned_Server);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_SpawnMinions", (Action<long, string>)OnEikthyrSpawnMinions_Server);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_LCRequest", (Action<long, string>)OnLCRequest_Server);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_LCBroadcast", (Action<long, string>)OnLCBroadcast_Client);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_LCDamage", (Action<long, string>)OnLCDamage_Client);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_Freeze", (Action<long, string>)OnFreezeEikthyr_Client);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_Unfreeze", (Action<long, string>)OnUnfreezeEikthyr_Client);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_LCFire", (Action<long, string>)OnLCFireBroadcast_Client);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_RaysRequest", (Action<long, string>)OnRaysRequest_Server);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_RaysBroadcast", (Action<long, string>)OnRaysBroadcast_Client);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_RaysDamage", (Action<long, string>)OnRaysDamage_Client);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_StompRequest", (Action<long, string>)OnStompRequest_Server);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_StompBroadcast", (Action<long, string>)OnStompBroadcast_Client);
		ZRoutedRpc.instance.Register<string>("EikthyrTracker_StompDamage", (Action<long, string>)OnStompDamage_Client);
	}

	public static void OnEikthyrAttack_Server(long senderPeerID, string attackName, int attackId)
	{
		if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer())
		{
			string peerName = GetPeerName(senderPeerID);
			Log.LogWarning((object)"══════════════════════════════════════");
			Log.LogWarning((object)"[SERVER RPC] \ud83d\udde1\ufe0f EIKTHYR ATAQUE DETECTADO");
			Log.LogWarning((object)("[SERVER RPC] Ataque    : " + attackName));
			Log.LogWarning((object)$"[SERVER RPC] Attack ID : {attackId}");
			Log.LogWarning((object)$"[SERVER RPC] Peer      : {peerName} ({senderPeerID})");
			Log.LogWarning((object)"══════════════════════════════════════");
		}
	}

	public static void OnEikthyrSummoned_Server(long senderPeerID, string invokerName)
	{
		if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer())
		{
			string peerName = GetPeerName(senderPeerID);
			Log.LogWarning((object)"══════════════════════════════════════");
			Log.LogWarning((object)"[SERVER RPC] \ud83d\udd14 EIKTHYR INVOCADO");
			Log.LogWarning((object)("[SERVER RPC] Invocador : " + invokerName));
			Log.LogWarning((object)$"[SERVER RPC] Peer      : {peerName} ({senderPeerID})");
			Log.LogWarning((object)"══════════════════════════════════════");
		}
	}

	public static void OnEikthyrSpawnMinions_Server(long senderPeerID, string eikthyrPosStr)
	{
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
		{
			return;
		}
		if (_minionsAlreadySpawned)
		{
			Log.LogInfo((object)("[SERVER RPC] Minions ya spawneados — ignorando RPC de " + GetPeerName(senderPeerID) + "."));
			return;
		}
		_minionsAlreadySpawned = true;
		string[] array = eikthyrPosStr.Split(new char[1] { ',' });
		if (array.Length != 3)
		{
			Log.LogError((object)("[SERVER RPC] Posición inválida: '" + eikthyrPosStr + "'"));
			_minionsAlreadySpawned = false;
			return;
		}
		CultureInfo invariantCulture = CultureInfo.InvariantCulture;
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(float.Parse(array[0], invariantCulture), float.Parse(array[1], invariantCulture), float.Parse(array[2], invariantCulture));
		Log.LogWarning((object)"══════════════════════════════════════");
		Log.LogWarning((object)"[SERVER RPC] \ud83d\udc17 SPAWN MINIONS EIKTHYR");
		Log.LogWarning((object)$"[SERVER RPC] Posición  : {val}");
		Log.LogWarning((object)("[SERVER RPC] Peer      : " + GetPeerName(senderPeerID)));
		Log.LogWarning((object)"══════════════════════════════════════");
		MinionSpawner.SpawnBoars(val);
	}

	public static void OnLCRequest_Server(long senderPeerID, string payload)
	{
		//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_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: 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_0153: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
		{
			return;
		}
		if (_lcInProgress)
		{
			Log.LogInfo((object)("[SERVER LC] LC ya en curso — ignorando RPC de " + GetPeerName(senderPeerID) + "."));
			return;
		}
		float time = Time.time;
		if (time - _lastLCTime < 3f)
		{
			Log.LogInfo((object)("[SERVER LC] En cooldown — ignorando de " + GetPeerName(senderPeerID) + "."));
			return;
		}
		_lastLCTime = time;
		_lcInProgress = true;
		CultureInfo invariantCulture = CultureInfo.InvariantCulture;
		string[] array = payload.Split(new char[1] { '|' });
		if (array.Length < 2)
		{
			Log.LogError((object)("[SERVER LC] payload inválido: '" + payload + "'"));
			_lcInProgress = false;
			return;
		}
		Vector3 val = AttackClients.ParseVec(array[0], invariantCulture);
		Vector3 val2 = AttackClients.ParseVec(array[1], invariantCulture);
		Log.LogWarning((object)"══════════════════════════════════════");
		Log.LogWarning((object)"[SERVER LC] ⚡ LIGHTNING CHARGE");
		Log.LogWarning((object)$"[SERVER LC] Boss pos : {val}");
		Log.LogWarning((object)$"[SERVER LC] Forward  : {val2}");
		Log.LogWarning((object)("[SERVER LC] Peer     : " + GetPeerName(senderPeerID)));
		Log.LogWarning((object)"══════════════════════════════════════");
		ServerCoroutineRunner.Run(LCSequence_Server(payload, val, val2));
	}

	[IteratorStateMachine(typeof(<LCSequence_Server>d__31))]
	private static IEnumerator LCSequence_Server(string payload, Vector3 bossPos, Vector3 bossForward)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <LCSequence_Server>d__31(0)
		{
			payload = payload,
			bossPos = bossPos,
			bossForward = bossForward
		};
	}

	[IteratorStateMachine(typeof(<ReenableAI>d__32))]
	private static IEnumerator ReenableAI(MonsterAI ai, float delay)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <ReenableAI>d__32(0)
		{
			ai = ai,
			delay = delay
		};
	}

	public static void OnLCBroadcast_Client(long senderPeerID, string payload)
	{
		if (!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsServer())
		{
			Log.LogInfo((object)"[CLIENT LC] ⚡ Broadcast recibido — ejecutando visuales.");
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null))
			{
				AttackClients.ExecuteLightningCharge(payload, (MonoBehaviour)(object)localPlayer);
			}
		}
	}

	public static void OnLCFireBroadcast_Client(long senderPeerID, string payload)
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: 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)
		if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer())
		{
			return;
		}
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null)
		{
			return;
		}
		CultureInfo invariantCulture = CultureInfo.InvariantCulture;
		string[] array = payload.Split(new char[1] { '|' });
		if (array.Length < 2)
		{
			return;
		}
		Vector3 bossPos = AttackClients.ParseVec(array[0], invariantCulture);
		List<Vector3> list = new List<Vector3>();
		string[] array2 = array[1].Split(new char[1] { ';' });
		foreach (string text in array2)
		{
			if (!string.IsNullOrEmpty(text))
			{
				list.Add(AttackClients.ParseVec(text, invariantCulture));
			}
		}
		((MonoBehaviour)localPlayer).StartCoroutine(AttackClients.FireLCProjectiles(bossPos, list, (MonoBehaviour)(object)localPlayer));
	}

	public static void OnFreezeEikthyr_Client(long senderPeerID, string unused)
	{
		foreach (Character allCharacter in Character.GetAllCharacters())
		{
			if (!EikthyrTrackerPlugin.IsEikthyr(allCharacter))
			{
				continue;
			}
			ZNetView component = ((Component)allCharacter).GetComponent<ZNetView>();
			if (!((Object)(object)component == (Object)null) && component.IsValid() && component.IsOwner())
			{
				MonsterAI component2 = ((Component)allCharacter).GetComponent<MonsterAI>();
				BaseAI component3 = ((Component)allCharacter).GetComponent<BaseAI>();
				if ((Object)(object)component2 != (Object)null)
				{
					((Behaviour)component2).enabled = false;
				}
				if (component3 != null)
				{
					component3.StopMoving();
				}
				allCharacter.m_speed = 0f;
				allCharacter.m_runSpeed = 0f;
				allCharacter.m_walkSpeed = 0f;
				EikthyrTrackerPlugin.Log.LogInfo((object)"[CLIENT] Eikthyr congelado (soy el owner).");
				break;
			}
		}
	}

	public static void OnUnfreezeEikthyr_Client(long senderPeerID, string unused)
	{
		foreach (Character allCharacter in Character.GetAllCharacters())
		{
			if (!EikthyrTrackerPlugin.IsEikthyr(allCharacter))
			{
				continue;
			}
			ZNetView component = ((Component)allCharacter).GetComponent<ZNetView>();
			if (!((Object)(object)component == (Object)null) && component.IsValid() && component.IsOwner())
			{
				MonsterAI component2 = ((Component)allCharacter).GetComponent<MonsterAI>();
				if ((Object)(object)component2 != (Object)null)
				{
					((Behaviour)component2).enabled = true;
				}
				allCharacter.m_speed = 3f;
				allCharacter.m_runSpeed = 6f;
				allCharacter.m_walkSpeed = 2f;
				Patch_Attack_Start_Stomp.IgnoreNext = true;
				allCharacter.StartAttack((Character)null, false);
				Patch_Attack_Start_Stomp.IgnoreNext = false;
				EikthyrTrackerPlugin.Log.LogInfo((object)"[CLIENT] Eikthyr descongelado — StartAttack stomp ejecutado.");
				break;
			}
		}
	}

	public static void OnLCDamage_Client(long senderPeerID, string dmgStr)
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Expected O, but got Unknown
		//IL_005a: 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_007a: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsServer())
		{
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && !((Character)localPlayer).IsDead())
			{
				CultureInfo invariantCulture = CultureInfo.InvariantCulture;
				float result = 10f;
				float.TryParse(dmgStr, NumberStyles.Float, invariantCulture, out result);
				HitData val = new HitData();
				val.m_point = ((Component)localPlayer).transform.position;
				val.m_damage.m_lightning = result;
				val.m_ranged = true;
				val.m_hitType = (HitType)16;
				((Character)localPlayer).Damage(val);
				Log.LogWarning((object)$"[CLIENT LC] \ud83d\udca5 Daño recibido: {result} lightning");
			}
		}
	}

	public static void OnRaysRequest_Server(long senderPeerID, string posStr)
	{
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0310: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0404: Unknown result type (might be due to invalid IL or missing references)
		//IL_0409: Unknown result type (might be due to invalid IL or missing references)
		//IL_040e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0438: Unknown result type (might be due to invalid IL or missing references)
		//IL_0422: Unknown result type (might be due to invalid IL or missing references)
		//IL_035b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0375: Unknown result type (might be due to invalid IL or missing references)
		//IL_037a: Unknown result type (might be due to invalid IL or missing references)
		//IL_037f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0393: Unknown result type (might be due to invalid IL or missing references)
		//IL_04af: Unknown result type (might be due to invalid IL or missing references)
		//IL_049d: Unknown result type (might be due to invalid IL or missing references)
		//IL_054e: Unknown result type (might be due to invalid IL or missing references)
		//IL_053c: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0621: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
		{
			return;
		}
		float time = Time.time;
		if (time - _lastRaysTime < 4f)
		{
			Log.LogInfo((object)("[SERVER Rays] En cooldown — ignorando de " + GetPeerName(senderPeerID) + "."));
			return;
		}
		_lastRaysTime = time;
		CultureInfo invariantCulture = CultureInfo.InvariantCulture;
		Vector3 val = AttackClients.ParseVec(posStr, invariantCulture);
		Log.LogWarning((object)"══════════════════════════════════════");
		Log.LogWarning((object)"[SERVER Rays] ⚡ LIGHTNING RAYS");
		Log.LogWarning((object)$"[SERVER Rays] Boss pos : {val}");
		Log.LogWarning((object)("[SERVER Rays] Peer     : " + GetPeerName(senderPeerID)));
		Log.LogWarning((object)"══════════════════════════════════════");
		List<ZNetPeer> list = new List<ZNetPeer>();
		foreach (ZNetPeer connectedPeer in ZNet.instance.GetConnectedPeers())
		{
			if (!(connectedPeer.m_characterID == ZDOID.None))
			{
				ZDO zDO = ZDOMan.instance.GetZDO(connectedPeer.m_characterID);
				if (zDO != null && Vector3.Distance(zDO.GetPosition(), val) < 30f)
				{
					list.Add(connectedPeer);
				}
			}
		}
		if (list.Count == 0)
		{
			Log.LogInfo((object)"[SERVER Rays] Sin jugadores en rango.");
			return;
		}
		for (int num = list.Count - 1; num > 0; num--)
		{
			int index = Random.Range(0, num + 1);
			ZNetPeer value = list[num];
			list[num] = list[index];
			list[index] = value;
		}
		List<Vector3> list2 = new List<Vector3>();
		List<Vector3> list3 = new List<Vector3>();
		List<ZNetPeer> list4;
		List<ZNetPeer> list5;
		if (list.Count >= 5)
		{
			int num2 = list.Count / 2;
			list4 = list.GetRange(0, num2);
			list5 = list.GetRange(num2, list.Count - num2);
		}
		else
		{
			list4 = new List<ZNetPeer>(list);
			list5 = new List<ZNetPeer>();
		}
		foreach (ZNetPeer item in list4)
		{
			ZDO zDO2 = ZDOMan.instance.GetZDO(item.m_characterID);
			if (zDO2 != null)
			{
				list2.Add(zDO2.GetPosition());
			}
		}
		foreach (ZNetPeer item2 in list5)
		{
			ZDO zDO3 = ZDOMan.instance.GetZDO(item2.m_characterID);
			if (zDO3 != null)
			{
				list3.Add(zDO3.GetPosition());
			}
		}
		while (list2.Count < 5)
		{
			float num3 = Random.Range(0f, 360f) * ((float)Math.PI / 180f);
			float num4 = Random.Range(3f, 12f);
			Vector3 val2 = val + new Vector3(Mathf.Sin(num3) * num4, 0f, Mathf.Cos(num3) * num4);
			if ((Object)(object)ZoneSystem.instance != (Object)null)
			{
				ZoneSystem.instance.GetSolidHeight(val2, ref val2.y, 1000);
			}
			list2.Add(val2);
		}
		if (list5.Count > 0)
		{
			while (list3.Count < 5)
			{
				float num5 = Random.Range(0f, 360f) * ((float)Math.PI / 180f);
				float num6 = Random.Range(3f, 12f);
				Vector3 val3 = val + new Vector3(Mathf.Sin(num5) * num6, 0f, Mathf.Cos(num5) * num6);
				if ((Object)(object)ZoneSystem.instance != (Object)null)
				{
					ZoneSystem.instance.GetSolidHeight(val3, ref val3.y, 1000);
				}
				list3.Add(val3);
			}
		}
		else
		{
			while (list3.Count < 5)
			{
				float num7 = Random.Range(0f, 360f) * ((float)Math.PI / 180f);
				float num8 = Random.Range(3f, 12f);
				Vector3 val4 = val + new Vector3(Mathf.Sin(num7) * num8, 0f, Mathf.Cos(num7) * num8);
				if ((Object)(object)ZoneSystem.instance != (Object)null)
				{
					ZoneSystem.instance.GetSolidHeight(val4, ref val4.y, 1000);
				}
				list3.Add(val4);
			}
		}
		Log.LogWarning((object)$"[SERVER Rays] Oleada1={list2.Count} puntos | Oleada2={list3.Count} puntos");
		CultureInfo invariantCulture2 = CultureInfo.InvariantCulture;
		for (int i = 0; i < list4.Count; i++)
		{
			ZNetPeer val5 = list4[i];
			string text = ((i < list2.Count) ? AttackClients.VecToStr(list2[i], invariantCulture2) : AttackClients.VecToStr(Vector3.zero, invariantCulture2));
			ZRoutedRpc.instance.InvokeRoutedRPC(val5.m_uid, "EikthyrTracker_RaysDamage", new object[1] { "1.9|8|" + text });
			Log.LogWarning((object)("[SERVER Rays] \ud83d\udca5 Oleada 1 → " + val5.m_playerName + " @ " + text));
		}
		for (int j = 0; j < list5.Count; j++)
		{
			ZNetPeer val6 = list5[j];
			string text2 = ((j < list3.Count) ? AttackClients.VecToStr(list3[j], invariantCulture2) : AttackClients.VecToStr(Vector3.zero, invariantCulture2));
			ZRoutedRpc.instance.InvokeRoutedRPC(val6.m_uid, "EikthyrTracker_RaysDamage", new object[1] { "3.8|8|" + text2 });
			Log.LogWarning((object)("[SERVER Rays] \ud83d\udca5 Oleada 2 → " + val6.m_playerName + " @ " + text2));
		}
		StringBuilder stringBuilder = new StringBuilder();
		StringBuilder stringBuilder2 = new StringBuilder();
		for (int k = 0; k < list2.Count; k++)
		{
			if (k > 0)
			{
				stringBuilder.Append(';');
			}
			stringBuilder.Append(AttackClients.VecToStr(list2[k], invariantCulture));
		}
		for (int l = 0; l < list3.Count; l++)
		{
			if (l > 0)
			{
				stringBuilder2.Append(';');
			}
			stringBuilder2.Append(AttackClients.VecToStr(list3[l], invariantCulture));
		}
		string text3 = $"{posStr}|{stringBuilder}|{stringBuilder2}";
		ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "EikthyrTracker_RaysBroadcast", new object[1] { text3 });
	}

	public static void OnRaysBroadcast_Client(long senderPeerID, string payload)
	{
		if (!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsServer())
		{
			Log.LogInfo((object)"[CLIENT Rays] ⚡ Broadcast recibido — ejecutando visuales.");
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null))
			{
				AttackClients.ExecuteLightningRaysWithGroups(payload, (MonoBehaviour)(object)localPlayer);
			}
		}
	}

	public static void OnRaysDamage_Client(long senderPeerID, string dmgPayload)
	{
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: 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)
		if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer())
		{
			return;
		}
		Player localPlayer = Player.m_localPlayer;
		if (!((Object)(object)localPlayer == (Object)null) && !((Character)localPlayer).IsDead())
		{
			CultureInfo invariantCulture = CultureInfo.InvariantCulture;
			string[] array = dmgPayload.Split(new char[1] { '|' });
			float result = 0f;
			float result2 = 8f;
			Vector3 impactPos = Vector3.zero;
			bool checkProximity = false;
			if (array.Length >= 1)
			{
				float.TryParse(array[0], NumberStyles.Float, invariantCulture, out result);
			}
			if (array.Length >= 2)
			{
				float.TryParse(array[1], NumberStyles.Float, invariantCulture, out result2);
			}
			if (array.Length >= 3)
			{
				impactPos = AttackClients.ParseVec(array[2], invariantCulture);
				checkProximity = true;
			}
			((MonoBehaviour)localPlayer).StartCoroutine(ApplyDamageDelayed(localPlayer, result2, result, impactPos, checkProximity));
		}
	}

	[IteratorStateMachine(typeof(<ApplyDamageDelayed>d__41))]
	private static IEnumerator ApplyDamageDelayed(Player player, float dmg, float delay, Vector3 impactPos, bool checkProximity)
	{
		//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)
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <ApplyDamageDelayed>d__41(0)
		{
			player = player,
			dmg = dmg,
			delay = delay,
			impactPos = impactPos,
			checkProximity = checkProximity
		};
	}

	public static void OnStompRequest_Server(long senderPeerID, string posStr)
	{
		//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_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
		{
			return;
		}
		if (_stompInProgress)
		{
			Log.LogInfo((object)("[SERVER Stomp] Stomp ya en curso — ignorando RPC de " + GetPeerName(senderPeerID) + "."));
			return;
		}
		float time = Time.time;
		if (time - _lastStompTime < 3f)
		{
			Log.LogInfo((object)("[SERVER Stomp] En cooldown — ignorando de " + GetPeerName(senderPeerID) + "."));
			return;
		}
		_lastStompTime = time;
		_stompInProgress = true;
		CultureInfo invariantCulture = CultureInfo.InvariantCulture;
		Vector3 val = AttackClients.ParseVec(posStr, invariantCulture);
		Log.LogWarning((object)"══════════════════════════════════════");
		Log.LogWarning((object)"[SERVER Stomp] \ud83d\udd28 STOMP AOE");
		Log.LogWarning((object)$"[SERVER Stomp] Boss pos : {val}");
		Log.LogWarning((object)("[SERVER Stomp] Peer     : " + GetPeerName(senderPeerID)));
		Log.LogWarning((object)"══════════════════════════════════════");
		ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "EikthyrTracker_StompBroadcast", new object[1] { posStr });
		ServerCoroutineRunner.Run(StompDamageSequence(val));
	}

	[IteratorStateMachine(typeof(<StompDamageSequence>d__43))]
	private static IEnumerator StompDamageSequence(Vector3 bossPos)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <StompDamageSequence>d__43(0)
		{
			bossPos = bossPos
		};
	}

	public static void OnStompBroadcast_Client(long senderPeerID, string payload)
	{
		if (!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsServer())
		{
			Log.LogInfo((object)"[CLIENT Stomp] \ud83d\udd28 Broadcast recibido — ejecutando visuales.");
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null))
			{
				AttackClients.ExecuteStompAOE(payload, (MonoBehaviour)(object)localPlayer);
			}
		}
	}

	public static void OnStompDamage_Client(long senderPeerID, string dmgStr)
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Expected O, but got Unknown
		//IL_005a: 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_0079: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsServer())
		{
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && !((Character)localPlayer).IsDead())
			{
				CultureInfo invariantCulture = CultureInfo.InvariantCulture;
				float result = 15f;
				float.TryParse(dmgStr, NumberStyles.Float, invariantCulture, out result);
				HitData val = new HitData();
				val.m_point = ((Component)localPlayer).transform.position;
				val.m_damage.m_blunt = result;
				val.m_ranged = true;
				val.m_hitType = (HitType)6;
				((Character)localPlayer).Damage(val);
				EikthyrTrackerPlugin.Log.LogWarning((object)$"[CLIENT Stomp] \ud83d\udca5 Daño: {result} blunt");
			}
		}
	}

	public static void SendAttack(string attackName, int attackId)
	{
		if (ZRoutedRpc.instance != null && !((Object)(object)ZNet.instance == (Object)null))
		{
			long num = (ZNet.instance.IsServer() ? ZNet.GetUID() : ZRoutedRpc.instance.GetServerPeerID());
			ZRoutedRpc.instance.InvokeRoutedRPC(num, "EikthyrTracker_AttackDetected", new object[2] { attackName, attackId });
		}
	}

	public static void SendSummoned(string playerName)
	{
		if (ZRoutedRpc.instance != null && !((Object)(object)ZNet.instance == (Object)null))
		{
			long num = (ZNet.instance.IsServer() ? ZNet.GetUID() : ZRoutedRpc.instance.GetServerPeerID());
			ZRoutedRpc.instance.InvokeRoutedRPC(num, "EikthyrTracker_BossSummoned", new object[1] { playerName });
		}
	}

	public static void SendSpawnMinions(Vector3 eikthyrPos)
	{
		//IL_003f: 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_0055: Unknown result type (might be due to invalid IL or missing references)
		if (ZRoutedRpc.instance != null && !((Object)(object)ZNet.instance == (Object)null))
		{
			long num = (ZNet.instance.IsServer() ? ZNet.GetUID() : ZRoutedRpc.instance.GetServerPeerID());
			CultureInfo invariantCulture = CultureInfo.InvariantCulture;
			string text = string.Format(invariantCulture, "{0},{1},{2}", eikthyrPos.x, eikthyrPos.y, eikthyrPos.z);
			ZRoutedRpc.instance.InvokeRoutedRPC(num, "EikthyrTracker_SpawnMinions", new object[1] { text });
		}
	}

	public static void ResetMinionFlag()
	{
		_minionsAlreadySpawned = false;
	}

	public static void SendLCRequest(Vector3 bossPos, Vector3 bossForward)
	{
		//IL_0039: 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)
		if (ZRoutedRpc.instance != null && !((Object)(object)ZNet.instan

BepInEx/plugins/Ghosts.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Entities;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Knuckles")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Knuckles")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("97A069E8-5AAB-4E2A-BAE4-B6E2E251C03E")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace Knuckles.GhostShip
{
	public class SkellyEventCommand : ConsoleCommand
	{
		public override string Name => "skellyevent";

		public override string Help => "skellyevent <playerName> — inicia el evento de invasión";

		public override void Run(string[] args)
		{
			if (args.Length < 1)
			{
				Console instance = Console.instance;
				if (instance != null)
				{
					instance.Print("Uso: skellyevent <playerName>");
				}
				return;
			}
			string name = args[0];
			Player val = ((IEnumerable<Player>)Player.GetAllPlayers()).FirstOrDefault((Func<Player, bool>)((Player p) => p.GetPlayerName().Equals(name, StringComparison.OrdinalIgnoreCase)));
			if ((Object)(object)val == (Object)null)
			{
				Console instance2 = Console.instance;
				if (instance2 != null)
				{
					instance2.Print("Jugador '" + name + "' no encontrado.");
				}
				ManualLogSource log = SpawnGhostLongshipAndSkels.Log;
				if (log != null)
				{
					log.LogWarning((object)("skellyevent: '" + name + "' no encontrado."));
				}
			}
			else
			{
				Console instance3 = Console.instance;
				if (instance3 != null)
				{
					instance3.Print("Iniciando invasión en " + val.GetPlayerName() + "...");
				}
				SpawnGhostLongshipAndSkels.StartEventForTarget(val);
			}
		}
	}
	[BepInPlugin("nazhi.spawnlongshipghostandskels", "Spawn Ghost Longship + Waves", "2.6.0")]
	public class SpawnGhostLongshipAndSkels : BaseUnityPlugin
	{
		private class BoatGodMode : MonoBehaviour
		{
			private WearNTear _wt;

			private void Awake()
			{
				_wt = ((Component)this).GetComponentInChildren<WearNTear>();
				if ((Object)(object)_wt == (Object)null)
				{
					ManualLogSource log = Log;
					if (log != null)
					{
						log.LogWarning((object)"BoatGodMode: WearNTear no encontrado en el Longship.");
					}
				}
			}

			private void LateUpdate()
			{
				if ((Object)(object)_wt == (Object)null)
				{
					return;
				}
				try
				{
					_wt.Repair();
				}
				catch (Exception arg)
				{
					ManualLogSource log = Log;
					if (log != null)
					{
						log.LogError((object)$"BoatGodMode: error en Repair(): {arg}");
					}
				}
			}
		}

		[HarmonyPatch(typeof(ZNet), "Awake")]
		private static class ZNetPatch
		{
			[HarmonyPostfix]
			private static void Postfix()
			{
				if ((Object)(object)Instance != (Object)null)
				{
					((MonoBehaviour)Instance).StartCoroutine(WaitAndRegister());
				}
			}

			private static IEnumerator WaitAndRegister()
			{
				float t = 0f;
				while (ZRoutedRpc.instance == null && t < 10f)
				{
					yield return (object)new WaitForSeconds(0.1f);
					t += 0.1f;
				}
				if (ZRoutedRpc.instance != null)
				{
					Log.LogInfo((object)$"ZRoutedRpc encontrado tras {t:F1}s — registrando RPCs.");
					RegisterAllRpcs();
				}
				else
				{
					Log.LogError((object)"ZRoutedRpc nunca se inicializó tras 10s.");
				}
			}
		}

		internal struct InvasionContext
		{
			public Vector3 ShorePoint;

			public Vector3 WaterPoint;

			public Vector3 ShoreDir;

			public float WaterLevel;

			public Vector3 BoatPos;

			public Quaternion BoatRot;
		}

		private class WaveSkeleton : MonoBehaviour
		{
			private void OnDestroy()
			{
				if (_currentWaveAlive > 0)
				{
					_currentWaveAlive--;
					ManualLogSource log = Log;
					if (log != null)
					{
						log.LogInfo((object)$"WaveSkeleton destruido. Restantes en wave: {_currentWaveAlive}");
					}
				}
			}
		}

		private class GhostEnforcer : MonoBehaviour
		{
			private float _nextTime;

			private const float Interval = 0.5f;

			private void Update()
			{
				if ((Object)(object)this == (Object)null || (Object)(object)((Component)this).gameObject == (Object)null || Time.time < _nextTime)
				{
					return;
				}
				_nextTime = Time.time + 0.5f;
				try
				{
					ApplyGhostMaterial(((Component)this).gameObject);
				}
				catch (Exception arg)
				{
					ManualLogSource log = Log;
					if (log != null)
					{
						log.LogError((object)$"GhostEnforcer error en {((Object)((Component)this).gameObject).name}: {arg}");
					}
				}
			}
		}

		internal const string BoatPrefab = "VikingShip";

		internal const string SkelPrefab = "Skeleton";

		internal const string RancidPrefab = "Skeleton_Poison";

		internal const int TotalWaves = 5;

		internal const int FirstWaveSkels = 3;

		internal const int SkelsPerWaveIncrement = 2;

		internal const float TotalEventDurationSeconds = 150f;

		internal const float BreakBetweenWaves = 3f;

		private bool _eventRunning = false;

		internal static int _currentWaveAlive;

		internal float _eventTimeRemaining = 0f;

		internal bool _showTimer = false;

		internal GameObject _currentBoat;

		internal const string RpcStartRetreat = "Nazhi_RPC_StartRetreat";

		internal static Material GhostMaterial;

		internal static bool _hudShowTimer;

		internal static float _hudTimeRemaining;

		internal static bool _hudShowTitle;

		private static GUIStyle _timerStyle;

		private static GUIStyle _titleStyle;

		private static GUIStyle _titleShadow;

		internal const string RpcEventHud = "Nazhi_RPC_EventHud";

		internal const float HudBroadcastRange = 100f;

		internal static ManualLogSource Log;

		internal static SpawnGhostLongshipAndSkels Instance;

		internal const string RpcApplyGhost = "Nazhi_RPC_ApplyGhost";

		internal const string ZdoGhostKey = "nazhi_ghost";

		private Harmony _harmony;

		public static void StartEventForTarget(Player target)
		{
			if ((Object)(object)target == (Object)null)
			{
				ManualLogSource log = Log;
				if (log != null)
				{
					log.LogWarning((object)"StartEventForTarget: target es null.");
				}
			}
			else if ((Object)(object)Instance == (Object)null)
			{
				ManualLogSource log2 = Log;
				if (log2 != null)
				{
					log2.LogError((object)"StartEventForTarget: Instance es null (plugin no inicializado).");
				}
			}
			else
			{
				Instance.StartEventForTargetInternal(target);
			}
		}

		private void StartEventForTargetInternal(Player target)
		{
			if ((Object)(object)target == (Object)null)
			{
				ManualLogSource log = Log;
				if (log != null)
				{
					log.LogWarning((object)"StartEventForTargetInternal: target es null.");
				}
				return;
			}
			if (_eventRunning)
			{
				MessageHud instance = MessageHud.instance;
				if (instance != null)
				{
					instance.ShowMessage((MessageType)2, "La invasión ya está en curso...", 0, (Sprite)null, false);
				}
				return;
			}
			ManualLogSource log2 = Log;
			if (log2 != null)
			{
				log2.LogInfo((object)("Iniciando evento de invasión para: " + target.GetPlayerName()));
			}
			((MonoBehaviour)this).StartCoroutine(TriggerEventFlow(target));
		}

		private IEnumerator TriggerEventFlow(Player targetPlayer)
		{
			_eventRunning = true;
			Vector3 targetPos = (((Object)(object)targetPlayer != (Object)null) ? ((Component)targetPlayer).transform.position : Vector3.zero);
			BroadcastHud(showTimer: false, 0f, showTitle: true, targetPos, "El enemigo ha encontrado tu base");
			yield return (object)new WaitForSeconds(10f);
			BroadcastHud(showTimer: false, 0f, showTitle: true, targetPos, "Los enemigos desembarcan cerca tuyo");
			yield return (object)new WaitForSeconds(1.5f);
			if (!PrepareInvasionContext(targetPlayer, out var ctx))
			{
				BroadcastHud(showTimer: false, 0f, showTitle: false, targetPos, "No se pudo encontrar una orilla cercana.");
				_eventRunning = false;
				yield break;
			}
			if ((Object)(object)(_currentBoat = SpawnBoat(ctx)) == (Object)null)
			{
				BroadcastHud(showTimer: false, 0f, showTitle: false, targetPos, "Falló el spawn del Longship.");
				_eventRunning = false;
				yield break;
			}
			_eventTimeRemaining = 150f;
			_showTimer = true;
			BroadcastHud(showTimer: true, _eventTimeRemaining, showTitle: true, targetPos);
			yield return RunWaves(ctx);
			_showTimer = false;
			BroadcastHud(showTimer: false, 0f, showTitle: true, targetPos);
			ZRoutedRpc instance = ZRoutedRpc.instance;
			if (instance != null)
			{
				instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "Nazhi_RPC_StartRetreat", new object[1] { ctx.ShoreDir });
			}
			yield return (object)new WaitForSeconds(14f);
			BroadcastHud(showTimer: false, 0f, showTitle: false, targetPos);
			_eventRunning = false;
			_currentBoat = null;
			ManualLogSource log = Log;
			if (log != null)
			{
				log.LogInfo((object)"Evento finalizado.");
			}
		}

		internal static void OnRpcStartRetreat(long sender, Vector3 shoreDir)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Instance == (Object)null))
			{
				ManualLogSource log = Log;
				if (log != null)
				{
					log.LogInfo((object)"OnRpcStartRetreat: iniciando retirada local.");
				}
				((MonoBehaviour)Instance).StartCoroutine(Instance.RetreatCoroutine(shoreDir));
			}
		}

		private IEnumerator RetreatCoroutine(Vector3 shoreDir)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			GameObject boatGO = FindBoatInScene();
			if ((Object)(object)boatGO == (Object)null)
			{
				yield return (object)new WaitForSeconds(0.5f);
				boatGO = FindBoatInScene();
			}
			if ((Object)(object)boatGO == (Object)null)
			{
				ManualLogSource log = Log;
				if (log != null)
				{
					log.LogWarning((object)"RetreatCoroutine: barco no encontrado.");
				}
				yield break;
			}
			ManualLogSource log2 = Log;
			if (log2 != null)
			{
				log2.LogInfo((object)("RetreatCoroutine: moviendo '" + ((Object)boatGO).name + "'."));
			}
			Vector3 val = new Vector3(shoreDir.x, 0f, shoreDir.z);
			Vector3 seaDirFlat = -((Vector3)(ref val)).normalized;
			if (((Vector3)(ref seaDirFlat)).sqrMagnitude < 0.001f)
			{
				seaDirFlat = -boatGO.transform.forward;
			}
			Quaternion startRot = boatGO.transform.rotation;
			Quaternion targetRot = Quaternion.LookRotation(seaDirFlat, Vector3.up);
			float t = 0f;
			while (t < 5f && (Object)(object)boatGO != (Object)null)
			{
				t += Time.deltaTime;
				boatGO.transform.rotation = Quaternion.Slerp(startRot, targetRot, Mathf.Clamp01(t / 5f));
				yield return null;
			}
			if ((Object)(object)boatGO == (Object)null)
			{
				yield break;
			}
			t = 0f;
			while (t < 8f && (Object)(object)boatGO != (Object)null)
			{
				t += Time.deltaTime;
				Transform transform = boatGO.transform;
				transform.position += boatGO.transform.forward * 3f * Time.deltaTime;
				yield return null;
			}
			if ((Object)(object)boatGO == (Object)null)
			{
				yield break;
			}
			ZNetView nv = boatGO.GetComponent<ZNetView>();
			if ((Object)(object)nv != (Object)null && nv.IsOwner())
			{
				ZDO zdo = nv.GetZDO();
				if (zdo != null && ZDOMan.instance != null)
				{
					ZDOMan.instance.DestroyZDO(zdo);
				}
			}
			else if ((Object)(object)nv != (Object)null)
			{
				nv.ClaimOwnership();
				ZDO zdo2 = nv.GetZDO();
				if (zdo2 != null && ZDOMan.instance != null)
				{
					ZDOMan.instance.DestroyZDO(zdo2);
				}
			}
			else
			{
				Object.Destroy((Object)(object)boatGO);
			}
			ManualLogSource log3 = Log;
			if (log3 != null)
			{
				log3.LogInfo((object)"RetreatCoroutine: barco destruido.");
			}
		}

		private static GameObject FindBoatInScene()
		{
			if ((Object)(object)Instance?._currentBoat != (Object)null)
			{
				return Instance._currentBoat;
			}
			GameObject[] array = Object.FindObjectsOfType<GameObject>();
			ZNetView val2 = default(ZNetView);
			foreach (GameObject val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				string name = ((Object)val).name;
				if ((name.IndexOf("VikingShip", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Longship", StringComparison.OrdinalIgnoreCase) >= 0) && val.TryGetComponent<ZNetView>(ref val2))
				{
					ZDO zDO = val2.GetZDO();
					if (zDO != null && zDO.GetBool("nazhi_ghost", false))
					{
						return val;
					}
				}
			}
			return null;
		}

		private IEnumerator RunWaves(InvasionContext ctx)
		{
			yield return RunSingleWave(ctx, 1, 2, 1, includeRancid: false);
			if (_eventTimeRemaining <= 0f)
			{
				yield break;
			}
			yield return WaveBreak(ctx);
			yield return RunSingleWave(ctx, 2, 4, 0, includeRancid: false);
			if (_eventTimeRemaining <= 0f)
			{
				yield break;
			}
			yield return WaveBreak(ctx);
			yield return RunSingleWave(ctx, 3, 5, 2, includeRancid: false);
			if (!(_eventTimeRemaining <= 0f))
			{
				yield return WaveBreak(ctx);
				yield return RunSingleWave(ctx, 4, 6, 0, includeRancid: false);
				if (!(_eventTimeRemaining <= 0f))
				{
					yield return WaveBreak(ctx);
					yield return RunSingleWave(ctx, 5, 6, 2, includeRancid: true);
				}
			}
		}

		private IEnumerator WaveBreak(InvasionContext ctx)
		{
			float breakRemaining = 3f;
			while (breakRemaining > 0f && _eventTimeRemaining > 0f)
			{
				yield return (object)new WaitForSeconds(1f);
				breakRemaining -= 1f;
				_eventTimeRemaining -= 1f;
				BroadcastHud(showTimer: true, _eventTimeRemaining, showTitle: true, ctx.ShorePoint);
			}
		}

		private IEnumerator RunSingleWave(InvasionContext ctx, int waveIndex, int skeletonCount, int ghostCount, bool includeRancid)
		{
			_currentWaveAlive = 0;
			BroadcastHud(showTimer: true, _eventTimeRemaining, showTitle: true, ctx.ShorePoint, (waveIndex == 1) ? "Los enemigos desembarcan cerca..." : "Más enemigos se acercan");
			SpawnSkeletonWave(ctx, skeletonCount, ghostCount, includeRancid, waveIndex);
			if (_currentWaveAlive <= 0)
			{
				ManualLogSource log = Log;
				if (log != null)
				{
					log.LogWarning((object)$"Wave {waveIndex}: no se spawneó ningún enemigo.");
				}
				yield break;
			}
			while (_eventTimeRemaining > 0f && _currentWaveAlive > 0)
			{
				yield return (object)new WaitForSeconds(1f);
				_eventTimeRemaining -= 1f;
				BroadcastHud(_eventTimeRemaining > 0f, _eventTimeRemaining, showTitle: true, ctx.ShorePoint);
			}
			ManualLogSource log2 = Log;
			if (log2 != null)
			{
				log2.LogInfo((object)$"Wave {waveIndex}: finalizada.");
			}
		}

		internal static void TryCacheGhostMaterial()
		{
			if ((Object)(object)GhostMaterial != (Object)null)
			{
				return;
			}
			ZNetScene instance = ZNetScene.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			GameObject prefab = instance.GetPrefab("Ghost");
			if (!Object.op_Implicit((Object)(object)prefab))
			{
				return;
			}
			SkinnedMeshRenderer componentInChildren = prefab.GetComponentInChildren<SkinnedMeshRenderer>();
			if (Object.op_Implicit((Object)(object)componentInChildren))
			{
				GhostMaterial = ((Renderer)componentInChildren).material;
				ManualLogSource log = Log;
				if (log != null)
				{
					log.LogInfo((object)"GhostMaterial cacheado.");
				}
			}
		}

		private void OnGUI()
		{
			if (_hudShowTitle)
			{
				DrawEventTitle();
			}
			if (_hudShowTimer && _hudTimeRemaining > 0f)
			{
				DrawTimer();
			}
		}

		private static void DrawEventTitle()
		{
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0057: 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_0071: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			if (_titleStyle == null)
			{
				_titleStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 20,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)1
				};
				_titleStyle.normal.textColor = new Color(0.55f, 0.85f, 1f);
				_titleShadow = new GUIStyle(_titleStyle);
				_titleShadow.normal.textColor = new Color(0f, 0f, 0f, 0.55f);
			}
			float num = ((float)Screen.width - 340f) * 0.5f;
			GUI.Label(new Rect(num + 2f, 22f, 340f, 32f), "Invasión Espectral", _titleShadow);
			GUI.Label(new Rect(num, 20f, 340f, 32f), "Invasión Espectral", _titleStyle);
		}

		private static void DrawTimer()
		{
			//IL_0018: 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_0026: 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_003b: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			if (_timerStyle == null)
			{
				_timerStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 24,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)1
				};
				_timerStyle.normal.textColor = new Color(1f, 0.84f, 0f);
			}
			float num = ((float)Screen.width - 200f) * 0.5f;
			float num2 = (_hudShowTitle ? 54f : 20f);
			GUI.Label(new Rect(num, num2, 200f, 40f), FormatTime(_hudTimeRemaining), _timerStyle);
		}

		private static string FormatTime(float seconds)
		{
			if (seconds < 0f)
			{
				seconds = 0f;
			}
			int num = Mathf.RoundToInt(seconds);
			return $"{num / 60:00}:{num % 60:00}";
		}

		internal static void BroadcastHud(bool showTimer, float timeRemaining, bool showTitle, string centerMsg = "")
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			BroadcastHudInRange(showTimer, timeRemaining, showTitle, Vector3.zero, useRange: false, centerMsg);
		}

		internal static void BroadcastHud(bool showTimer, float timeRemaining, bool showTitle, Vector3 origin, string centerMsg = "")
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			BroadcastHudInRange(showTimer, timeRemaining, showTitle, origin, useRange: true, centerMsg);
		}

		private static void BroadcastHudInRange(bool showTimer, float timeRemaining, bool showTitle, Vector3 origin, bool useRange, string centerMsg)
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			if (ZRoutedRpc.instance == null)
			{
				return;
			}
			int num = (showTimer ? 1 : 0);
			int num2 = (showTitle ? 1 : 0);
			string text = centerMsg ?? "";
			if (!useRange)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "Nazhi_RPC_EventHud", new object[4] { num, timeRemaining, num2, text });
				return;
			}
			foreach (ZNetPeer peer in ZNet.instance.GetPeers())
			{
				if (peer == null)
				{
					continue;
				}
				ZDOMan instance = ZDOMan.instance;
				ZDO val = ((instance != null) ? instance.GetZDO(peer.m_characterID) : null);
				if (val != null)
				{
					float num3 = Vector3.Distance(origin, val.GetPosition());
					if (!(num3 > 100f))
					{
						ZRoutedRpc.instance.InvokeRoutedRPC(peer.m_uid, "Nazhi_RPC_EventHud", new object[4] { num, timeRemaining, num2, text });
					}
				}
			}
			if ((Object)(object)Player.m_localPlayer != (Object)null && Vector3.Distance(origin, ((Component)Player.m_localPlayer).transform.position) <= 100f)
			{
				OnRpcEventHud(0L, num, timeRemaining, num2, text);
			}
		}

		internal static void OnRpcEventHud(long sender, int showTimerI, float timeRemaining, int showTitleI, string centerMsg)
		{
			_hudShowTimer = showTimerI != 0;
			_hudTimeRemaining = timeRemaining;
			_hudShowTitle = showTitleI != 0;
			if (!string.IsNullOrEmpty(centerMsg))
			{
				MessageHud instance = MessageHud.instance;
				if (instance != null)
				{
					instance.ShowMessage((MessageType)2, centerMsg, 0, (Sprite)null, false);
				}
			}
		}

		private void Awake()
		{
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			((Component)this).gameObject.AddComponent<GhostSyncMonitor>();
			Log.LogInfo((object)"Knuckles GhostShip cargado (Main.cs)");
		}

		private static void OnRpcApplyGhost(long sender, ZDOID zdoid)
		{
			//IL_0023: 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_0085: 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)
			if ((Object)(object)ZNetScene.instance == (Object)null)
			{
				return;
			}
			ZDOMan instance = ZDOMan.instance;
			ZDO val = ((instance != null) ? instance.GetZDO(zdoid) : null);
			if (val == null)
			{
				ManualLogSource log = Log;
				if (log != null)
				{
					log.LogWarning((object)$"RPC_ApplyGhost: no se encontró ZDO para ZDOID={zdoid}");
				}
				return;
			}
			ZNetView val2 = ZNetScene.instance.FindInstance(val);
			if ((Object)(object)val2 == (Object)null)
			{
				ManualLogSource log2 = Log;
				if (log2 != null)
				{
					log2.LogWarning((object)$"RPC_ApplyGhost: no se encontró ZNetView para ZDOID={zdoid}");
				}
				return;
			}
			GameObject gameObject = ((Component)val2).gameObject;
			if (!((Object)(object)gameObject == (Object)null))
			{
				TryCacheGhostMaterial();
				if (((Object)gameObject).name.IndexOf("VikingShip", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)gameObject).name.IndexOf("Longship", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					DisableWaterEffects(gameObject);
					ApplyGhostMaterial_Filtered(gameObject);
				}
				else
				{
					ApplyGhostMaterial(gameObject);
				}
				ManualLogSource log3 = Log;
				if (log3 != null)
				{
					log3.LogInfo((object)$"RPC_ApplyGhost: ghost aplicado a {((Object)gameObject).name} (ZDOID={zdoid})");
				}
			}
		}

		internal static void SendGhostRpc(GameObject go)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			ZNetView val = default(ZNetView);
			if ((Object)(object)go == (Object)null || !go.TryGetComponent<ZNetView>(ref val))
			{
				return;
			}
			ZDO zDO = val.GetZDO();
			if (zDO != null)
			{
				ZDOID uid = zDO.m_uid;
				ZRoutedRpc instance = ZRoutedRpc.instance;
				if (instance != null)
				{
					instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "Nazhi_RPC_ApplyGhost", new object[1] { uid });
				}
				ManualLogSource log = Log;
				if (log != null)
				{
					log.LogInfo((object)$"SendGhostRpc enviado para {((Object)go).name} (ZDOID={uid})");
				}
			}
		}

		internal static GameObject InstantiateNet(string prefabName, Vector3 pos, Quaternion rot, bool markAsGhost = false)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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)
			ZNetScene instance = ZNetScene.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return null;
			}
			GameObject prefab = instance.GetPrefab(prefabName);
			if ((Object)(object)prefab == (Object)null)
			{
				return null;
			}
			GameObject val = Object.Instantiate<GameObject>(prefab, pos, rot);
			ZNetView val2 = default(ZNetView);
			if (val.TryGetComponent<ZNetView>(ref val2))
			{
				ZDO zDO = val2.GetZDO();
				if (zDO != null)
				{
					zDO.SetPosition(pos);
					zDO.SetRotation(rot);
					if (markAsGhost)
					{
						zDO.Set("nazhi_ghost", true);
					}
				}
			}
			return val;
		}

		private void Start()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			RegisterConsoleCommand();
			CacheGhostMaterialStartup();
			_harmony = new Harmony("nazhi.ghostship");
			_harmony.PatchAll(typeof(ZNetPatch));
			Log.LogInfo((object)"Harmony patch aplicado.");
		}

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

		private void RegisterConsoleCommand()
		{
			try
			{
				CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new SkellyEventCommand());
				Log.LogInfo((object)"Comando 'skellyevent' registrado.");
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"Error registrando comando 'skellyevent': {arg}");
			}
		}

		private void CacheGhostMaterialStartup()
		{
			try
			{
				TryCacheGhostMaterial();
				Log.LogInfo((object)"GhostMaterial cacheado en Startup.");
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"Error cacheando GhostMaterial: {arg}");
			}
		}

		internal static void RegisterAllRpcs()
		{
			if (ZRoutedRpc.instance == null)
			{
				Log.LogWarning((object)"RegisterAllRpcs: ZRoutedRpc.instance sigue null.");
				return;
			}
			try
			{
				ZRoutedRpc.instance.Register<ZDOID>("Nazhi_RPC_ApplyGhost", (Action<long, ZDOID>)OnRpcApplyGhost);
			}
			catch
			{
			}
			try
			{
				ZRoutedRpc.instance.Register<int, float, int, string>("Nazhi_RPC_EventHud", (Method<int, float, int, string>)OnRpcEventHud);
			}
			catch
			{
			}
			try
			{
				ZRoutedRpc.instance.Register<Vector3>("Nazhi_RPC_StartRetreat", (Action<long, Vector3>)OnRpcStartRetreat);
			}
			catch
			{
			}
			Log.LogInfo((object)"RPCs registrados correctamente.");
		}

		private bool PrepareInvasionContext(Player target, out InvasionContext ctx)
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: 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_0130: 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_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: 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_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: 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_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: 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_01e1: 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_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			ctx = default(InvasionContext);
			ZNetScene instance = ZNetScene.instance;
			if ((Object)(object)instance == (Object)null)
			{
				ManualLogSource log = Log;
				if (log != null)
				{
					log.LogError((object)"PrepareInvasionContext: ZNetScene.instance es null.");
				}
				return false;
			}
			if ((Object)(object)instance.GetPrefab("VikingShip") == (Object)null || (Object)(object)instance.GetPrefab("Skeleton") == (Object)null)
			{
				ManualLogSource log2 = Log;
				if (log2 != null)
				{
					log2.LogError((object)"PrepareInvasionContext: prefabs no encontrados Boat=VikingShip, Skel=Skeleton");
				}
				return false;
			}
			if ((Object)(object)target == (Object)null)
			{
				ManualLogSource log3 = Log;
				if (log3 != null)
				{
					log3.LogError((object)"PrepareInvasionContext: target es null.");
				}
				return false;
			}
			Vector3 position = ((Component)target).transform.position;
			if (!FindNearestShore(position, 80f, out var shorePoint, out var waterPoint, out var shoreDir))
			{
				ManualLogSource log4 = Log;
				if (log4 != null)
				{
					log4.LogWarning((object)("PrepareInvasionContext: no se encontró orilla (<= 80m) para " + target.GetPlayerName() + "."));
				}
				return false;
			}
			float waterLevel = GetWaterLevel();
			Vector3 val = -((Vector3)(ref shoreDir)).normalized;
			Vector3 start = waterPoint + val * 8f;
			Vector3 val2 = PushToDeeperWater(start, shoreDir, 3f, 15f, 1.5f);
			Vector3 boatPos = val2;
			boatPos.y = waterLevel + 0.25f;
			Vector3 val3 = new Vector3(shoreDir.x, 0f, shoreDir.z);
			Vector3 val4 = ((Vector3)(ref val3)).normalized;
			if (((Vector3)(ref val4)).sqrMagnitude < 0.001f)
			{
				val4 = Vector3.forward;
			}
			Quaternion boatRot = Quaternion.LookRotation(val4, Vector3.up);
			ctx = new InvasionContext
			{
				ShorePoint = shorePoint,
				WaterPoint = waterPoint,
				ShoreDir = shoreDir,
				WaterLevel = waterLevel,
				BoatPos = boatPos,
				BoatRot = boatRot
			};
			ManualLogSource log5 = Log;
			if (log5 != null)
			{
				log5.LogInfo((object)$"PrepareInvasionContext OK para {target.GetPlayerName()} en {position}.");
			}
			return true;
		}

		private GameObject SpawnBoat(InvasionContext ctx)
		{
			//IL_0007: 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)
			GameObject val = InstantiateNet("VikingShip", ctx.BoatPos, ctx.BoatRot, markAsGhost: true);
			if ((Object)(object)val == (Object)null)
			{
				ManualLogSource log = Log;
				if (log != null)
				{
					log.LogError((object)"SpawnBoat: falló InstantiateNet del Longship.");
				}
				return null;
			}
			val.AddComponent<BoatGodMode>();
			DisableWaterEffects(val);
			ApplyGhostMaterial_Filtered(val);
			SendGhostRpc(val);
			ManualLogSource log2 = Log;
			if (log2 != null)
			{
				log2.LogInfo((object)"SpawnBoat: Longship ghost inmortal spawneado correctamente.");
			}
			return val;
		}

		private void SpawnSkeletonWave(InvasionContext ctx, int skeletonCount, int ghostCount, bool includeRancid, int waveIndex)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			ZNetScene instance = ZNetScene.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			Vector3 normalized = ((Vector3)(ref ctx.ShoreDir)).normalized;
			Vector3 val = Vector3.Cross(Vector3.up, normalized);
			Vector3 normalized2 = ((Vector3)(ref val)).normalized;
			Vector3 val2 = ctx.ShorePoint + normalized * 2.5f;
			int num = 0;
			for (int i = 0; i < skeletonCount; i++)
			{
				float num2 = (float)i - (float)(skeletonCount - 1) * 0.5f;
				Vector3 xz = val2 + normalized2 * (num2 * 3f);
				if (!PlaceOnGround(xz, out var placed))
				{
					ManualLogSource log = Log;
					if (log != null)
					{
						log.LogWarning((object)$"Wave {waveIndex}: no se encontró suelo para un skeleton.");
					}
					continue;
				}
				Quaternion rot = Quaternion.LookRotation(-ctx.ShoreDir, Vector3.up);
				GameObject val3 = InstantiateNet("Skeleton", placed, rot, markAsGhost: true);
				if ((Object)(object)val3 != (Object)null)
				{
					Character component = val3.GetComponent<Character>();
					if (component != null)
					{
						component.m_level = Mathf.Max(1, waveIndex);
					}
					ApplyGhostMaterial(val3);
					val3.AddComponent<GhostEnforcer>();
					AggroNearestPlayer(val3);
					val3.AddComponent<WaveSkeleton>();
					SendGhostRpc(val3);
					_currentWaveAlive++;
					num++;
				}
			}
			for (int j = 0; j < ghostCount; j++)
			{
				float num3 = (float)j - (float)(ghostCount - 1) * 0.5f;
				Vector3 xz2 = val2 + normalized2 * (num3 * 3f * 0.7f);
				if (!PlaceOnGround(xz2, out var placed2))
				{
					ManualLogSource log2 = Log;
					if (log2 != null)
					{
						log2.LogWarning((object)$"Wave {waveIndex}: no se encontró suelo para un Ghost.");
					}
					continue;
				}
				Quaternion rot2 = Quaternion.LookRotation(-ctx.ShoreDir, Vector3.up);
				GameObject val4 = InstantiateNet("Ghost", placed2, rot2);
				if ((Object)(object)val4 != (Object)null)
				{
					Character component2 = val4.GetComponent<Character>();
					if (component2 != null)
					{
						component2.m_level = Mathf.Max(1, waveIndex);
					}
					AggroNearestPlayer(val4);
					val4.AddComponent<WaveSkeleton>();
					_currentWaveAlive++;
					num++;
				}
			}
			if (includeRancid)
			{
				GameObject prefab = instance.GetPrefab("Skeleton_Poison");
				if ((Object)(object)prefab != (Object)null)
				{
					Vector3 xz3 = val2;
					if (PlaceOnGround(xz3, out var placed3))
					{
						Quaternion rot3 = Quaternion.LookRotation(-ctx.ShoreDir, Vector3.up);
						GameObject val5 = InstantiateNet("Skeleton_Poison", placed3, rot3, markAsGhost: true);
						if ((Object)(object)val5 != (Object)null)
						{
							Character component3 = val5.GetComponent<Character>();
							if (component3 != null)
							{
								component3.m_level = Mathf.Max(1, waveIndex + 1);
							}
							ApplyGhostMaterial(val5);
							val5.AddComponent<GhostEnforcer>();
							AggroNearestPlayer(val5);
							val5.AddComponent<WaveSkeleton>();
							SendGhostRpc(val5);
							_currentWaveAlive++;
							num++;
							ManualLogSource log3 = Log;
							if (log3 != null)
							{
								log3.LogInfo((object)"Wave final: Rancid Remains añadido.");
							}
						}
					}
				}
				else
				{
					ManualLogSource log4 = Log;
					if (log4 != null)
					{
						log4.LogWarning((object)"SpawnSkeletonWave: prefab RancidPrefab no encontrado.");
					}
				}
			}
			ManualLogSource log5 = Log;
			if (log5 != null)
			{
				log5.LogInfo((object)$"Wave {waveIndex}: {num} enemigos generados.");
			}
			((MonoBehaviour)this).StartCoroutine(VerifyWaveGhostMaterials());
		}

		private IEnumerator VerifyWaveGhostMaterials()
		{
			yield return (object)new WaitForSeconds(0.2f);
			CheckAllWaveSkeletonGhosts("[GhostFix-0.2]");
			yield return (object)new WaitForSeconds(0.8f);
			CheckAllWaveSkeletonGhosts("[GhostFix-1.0]");
		}

		private void CheckAllWaveSkeletonGhosts(string tag)
		{
			WaveSkeleton[] array = Object.FindObjectsOfType<WaveSkeleton>();
			WaveSkeleton[] array2 = array;
			foreach (WaveSkeleton waveSkeleton in array2)
			{
				GameObject gameObject = ((Component)waveSkeleton).gameObject;
				if (!((Object)(object)gameObject == (Object)null) && ((Object)gameObject).name.IndexOf("Ghost", StringComparison.OrdinalIgnoreCase) < 0)
				{
					ApplyGhostMaterial(gameObject);
					ManualLogSource log = Log;
					if (log != null)
					{
						log.LogWarning((object)(tag + " Enemy forzado a ghost. Obj=" + ((Object)gameObject).name));
					}
				}
			}
		}

		private static bool FindNearestShore(Vector3 origin, float maxRadius, out Vector3 shorePoint, out Vector3 waterPoint, out Vector3 shoreDir)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: 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_015d: 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_0178: 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_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: 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_0199: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = (shoreDir = Vector3.zero);
			val = (shorePoint = (waterPoint = val));
			float waterLevel = GetWaterLevel();
			float num = waterLevel - 0.3f;
			float num2 = float.MaxValue;
			bool result = false;
			Vector3 val2 = default(Vector3);
			for (int i = 0; i < 36; i++)
			{
				float num3 = (float)Math.PI * 2f * ((float)i / 36f);
				((Vector3)(ref val2))..ctor(Mathf.Cos(num3), 0f, Mathf.Sin(num3));
				bool flag = false;
				bool flag2 = false;
				Vector3 val3 = origin;
				for (float num4 = 1f; num4 <= maxRadius; num4 += 1f)
				{
					Vector3 val4 = origin + val2 * num4;
					if (!TryGetGroundHeight(val4, out var height))
					{
						continue;
					}
					bool flag3 = height >= num;
					if (!flag2)
					{
						flag2 = true;
						flag = flag3;
						val3 = val4;
						continue;
					}
					if (flag3 != flag)
					{
						Vector3 val5 = val3;
						Vector3 val6 = val4;
						for (int j = 0; j < 10; j++)
						{
							Vector3 val7 = (val5 + val6) * 0.5f;
							TryGetGroundHeight(val7, out var height2);
							bool flag4 = height2 >= num;
							if (flag4 == flag)
							{
								val5 = val7;
							}
							else
							{
								val6 = val7;
							}
						}
						Vector3 val8 = (flag ? val5 : val6);
						Vector3 val9 = (flag ? val6 : val5);
						float num5 = Vector3.Distance(origin, val8);
						if (num5 < num2)
						{
							num2 = num5;
							shorePoint = val8;
							waterPoint = val9;
							val = val8 - val9;
							shoreDir = ((Vector3)(ref val)).normalized;
							result = true;
						}
						break;
					}
					flag = flag3;
					val3 = val4;
				}
			}
			return result;
		}

		private static bool TryGetGroundHeight(Vector3 pos, out float height)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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)
			height = 0f;
			if ((Object)(object)ZoneSystem.instance != (Object)null)
			{
				try
				{
					float num = default(float);
					if (ZoneSystem.instance.GetSolidHeight(pos, ref num, 1000))
					{
						height = num;
						return true;
					}
				}
				catch
				{
				}
			}
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(pos.x, 2000f, pos.z);
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val, Vector3.down, ref val2, 5000f, -1, (QueryTriggerInteraction)1))
			{
				height = ((RaycastHit)(ref val2)).point.y;
				return true;
			}
			return false;
		}

		private static float GetHeightSafe(Vector3 pos)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			float height;
			return TryGetGroundHeight(pos, out height) ? height : GetWaterLevel();
		}

		private static float GetWaterLevel()
		{
			return ((Object)(object)ZoneSystem.instance != (Object)null) ? ZoneSystem.instance.m_waterLevel : 30f;
		}

		private static float GetDepthAt(Vector3 pos)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			float waterLevel = GetWaterLevel();
			float heightSafe = GetHeightSafe(pos);
			return waterLevel - heightSafe;
		}

		private static Vector3 PushToDeeperWater(Vector3 start, Vector3 shoreDir, float minDepth, float maxPush, float step)
		{
			//IL_0003: 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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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)
			Vector3 val = -((Vector3)(ref shoreDir)).normalized;
			Vector3 val2 = start;
			for (float num = 0f; num <= maxPush; num += step)
			{
				if (GetDepthAt(val2) >= minDepth)
				{
					return val2;
				}
				val2 += val * step;
			}
			return start;
		}

		private static bool PlaceOnGround(Vector3 xz, out Vector3 placed)
		{
			//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_0008: Unknown result type (might be due to invalid IL or missing references)
			placed = xz;
			if (TryGetGroundHeight(xz, out var height))
			{
				placed.y = height;
				return true;
			}
			return false;
		}

		internal static void ApplyGhostMaterial(GameObject go)
		{
			if ((Object)(object)GhostMaterial == (Object)null)
			{
				TryCacheGhostMaterial();
				if ((Object)(object)GhostMaterial == (Object)null)
				{
					return;
				}
			}
			Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				val.material = GhostMaterial;
			}
		}

		internal static void ApplyGhostOverlay(GameObject go)
		{
			if ((Object)(object)GhostMaterial == (Object)null)
			{
				TryCacheGhostMaterial();
				if ((Object)(object)GhostMaterial == (Object)null)
				{
					return;
				}
			}
			Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				Material[] materials = val.materials;
				Material[] array = (Material[])(object)new Material[materials.Length + 1];
				for (int j = 0; j < materials.Length; j++)
				{
					array[j] = materials[j];
				}
				array[materials.Length] = GhostMaterial;
				val.materials = array;
			}
		}

		internal static void ApplyGhostMaterial_Filtered(GameObject go)
		{
			if ((Object)(object)GhostMaterial == (Object)null)
			{
				TryCacheGhostMaterial();
				if ((Object)(object)GhostMaterial == (Object)null)
				{
					return;
				}
			}
			Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				string text = ((Object)((Component)val).gameObject).name.ToLowerInvariant();
				if (!text.Contains("watereffects") && !text.Contains("watermask"))
				{
					val.material = GhostMaterial;
				}
			}
			ManualLogSource log = Log;
			if (log != null)
			{
				log.LogInfo((object)"Ghost aplicado al Longship (filtrado).");
			}
		}

		internal static void DisableWaterEffects(GameObject boat)
		{
			try
			{
				Transform val = FindChildRecursiveByNameContains(boat.transform, "watereffects");
				if ((Object)(object)val != (Object)null)
				{
					((Component)val).gameObject.SetActive(false);
					ManualLogSource log = Log;
					if (log != null)
					{
						log.LogInfo((object)"watereffects desactivados en el Longship.");
					}
				}
				else
				{
					ManualLogSource log2 = Log;
					if (log2 != null)
					{
						log2.LogWarning((object)"watereffects no encontrados en el Longship.");
					}
				}
			}
			catch (Exception arg)
			{
				ManualLogSource log3 = Log;
				if (log3 != null)
				{
					log3.LogError((object)$"DisableWaterEffects error: {arg}");
				}
			}
		}

		private static Transform FindChildRecursiveByNameContains(Transform root, string substring)
		{
			if ((Object)(object)root == (Object)null || substring == null)
			{
				return null;
			}
			string value = substring.ToLowerInvariant();
			if (((Object)root).name != null && ((Object)root).name.ToLowerInvariant().Contains(value))
			{
				return root;
			}
			for (int i = 0; i < root.childCount; i++)
			{
				Transform val = FindChildRecursiveByNameContains(root.GetChild(i), substring);
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			return null;
		}

		internal static void AggroNearestPlayer(GameObject skel)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Character component = skel.GetComponent<Character>();
				if ((Object)(object)component == (Object)null)
				{
					return;
				}
				Player closestPlayer = Player.GetClosestPlayer(skel.transform.position, 60f);
				if ((Object)(object)closestPlayer == (Object)null)
				{
					return;
				}
				MonsterAI component2 = skel.GetComponent<MonsterAI>();
				if ((Object)(object)component2 != (Object)null)
				{
					((BaseAI)component2).m_alerted = true;
					((BaseAI)component2).SetHuntPlayer(true);
					component2.SetTarget((Character)(object)closestPlayer);
					((BaseAI)component2).SetAggravated(true, (AggravatedReason)0);
					ManualLogSource log = Log;
					if (log != null)
					{
						log.LogInfo((object)("Aggro → " + closestPlayer.GetPlayerName() + " (MonsterAI)"));
					}
					return;
				}
				BaseAI component3 = skel.GetComponent<BaseAI>();
				if ((Object)(object)component3 != (Object)null)
				{
					component3.m_alerted = true;
					component3.SetHuntPlayer(true);
					component3.SetAggravated(true, (AggravatedReason)0);
					component3.Alert();
					ManualLogSource log2 = Log;
					if (log2 != null)
					{
						log2.LogInfo((object)("Aggro → " + closestPlayer.GetPlayerName() + " (BaseAI fallback)"));
					}
				}
			}
			catch (Exception arg)
			{
				ManualLogSource log3 = Log;
				if (log3 != null)
				{
					log3.LogError((object)$"AggroNearestPlayer error: {arg}");
				}
			}
		}
	}
	public class GhostSyncMonitor : MonoBehaviour
	{
		private const float ScanInterval = 1.5f;

		private readonly HashSet<ZDOID> _processed = new HashSet<ZDOID>();

		private void Start()
		{
			((MonoBehaviour)this).StartCoroutine(ScanLoop());
		}

		private IEnumerator ScanLoop()
		{
			while (true)
			{
				yield return (object)new WaitForSeconds(1.5f);
				if (!((Object)(object)ZNetScene.instance == (Object)null))
				{
					SpawnGhostLongshipAndSkels.TryCacheGhostMaterial();
					if (!((Object)(object)SpawnGhostLongshipAndSkels.GhostMaterial == (Object)null))
					{
						ScanAllNetViews();
					}
				}
			}
		}

		private void ScanAllNetViews()
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			ZNetView[] array = Object.FindObjectsOfType<ZNetView>();
			foreach (ZNetView val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				ZDO zDO = val.GetZDO();
				if (zDO == null || !zDO.GetBool("nazhi_ghost", false))
				{
					continue;
				}
				GameObject gameObject = ((Component)val).gameObject;
				if ((Object)(object)gameObject == (Object)null)
				{
					continue;
				}
				if (((Object)gameObject).name.IndexOf("VikingShip", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)gameObject).name.IndexOf("Longship", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					SpawnGhostLongshipAndSkels.DisableWaterEffects(gameObject);
					SpawnGhostLongshipAndSkels.ApplyGhostMaterial_Filtered(gameObject);
				}
				else
				{
					SpawnGhostLongshipAndSkels.ApplyGhostMaterial(gameObject);
				}
				ZDOID uid = zDO.m_uid;
				if (_processed.Add(uid))
				{
					ManualLogSource log = SpawnGhostLongshipAndSkels.Log;
					if (log != null)
					{
						log.LogInfo((object)$"GhostSyncMonitor: ghost aplicado a {((Object)gameObject).name} (ZDOID={uid})");
					}
				}
			}
		}
	}
}

BepInEx/plugins/HideTempleITems.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("AichoGuardian")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AichoGuardian")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("D28110A9-E229-4700-AD4D-DCD37486A82B")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace HideTMPieces;

[BepInPlugin("com.yourname.hidetmpieces", "HideTMPieces", "1.0.0")]
public class HideTMPiecesPlugin : BaseUnityPlugin
{
	public const string PluginGUID = "com.yourname.hidetmpieces";

	public const string PluginName = "HideTMPieces";

	public const string PluginVersion = "1.0.0";

	internal static ManualLogSource Log;

	private readonly Harmony _harmony = new Harmony("com.yourname.hidetmpieces");

	private void Awake()
	{
		Log = ((BaseUnityPlugin)this).Logger;
		_harmony.PatchAll();
		Log.LogInfo((object)"HideTMPieces v1.0.0 cargado — ocultando piezas _TM del martillo.");
	}

	private void OnDestroy()
	{
		_harmony.UnpatchSelf();
	}
}
[HarmonyPatch(typeof(PieceTable), "UpdateAvailable")]
public static class PieceTable_UpdateAvailable_Patch
{
	private static void Postfix(PieceTable __instance)
	{
		if (__instance.m_availablePieces == null)
		{
			return;
		}
		int num = 0;
		foreach (List<Piece> availablePiece in __instance.m_availablePieces)
		{
			int count = availablePiece.Count;
			availablePiece.RemoveAll((Piece p) => (Object)(object)p != (Object)null && IsTMPiece(p));
			num += count - availablePiece.Count;
		}
		if (num > 0)
		{
			HideTMPiecesPlugin.Log.LogDebug((object)$"[UpdateAvailable] Ocultadas {num} pieza(s) _TM.");
		}
	}

	private static bool IsTMPiece(Piece piece)
	{
		if ((Object)(object)((Component)piece).gameObject == (Object)null)
		{
			return false;
		}
		string prefabName = Utils.GetPrefabName(((Component)piece).gameObject);
		return prefabName.EndsWith("_TM", StringComparison.OrdinalIgnoreCase);
	}
}

BepInEx/plugins/NazhikaCore.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using NazhikaCore.Commands;
using NazhikaCore.Features.Classes;
using NazhikaCore.Features.DeathMessages;
using NazhikaCore.Features.GlobalChat;
using NazhikaCore.Features.Party;
using NazhikaCore.Features.Signs;
using NazhikaCore.Features.Teleport;
using NazhikaCore.Features.Terrain;
using NazhikaCore.Features.Weapons;
using NazhikaCore.Patches;
using NazhikaCore.RPC;
using NazhikaCore.StatusEffects;
using NazhikaCore.UI;
using NazhikaCore.Utils;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("NazhikaCore")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NazhikaCore")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("11D23B88-B6B8-482B-9F58-4694D6AD10FC")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace NazhikaCore
{
	[BepInPlugin("com.dreams.nazhikacore", "Nazhika Core", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class MainPlugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		internal static ConfigEntry<KeyboardShortcut> ClassSkillKey;

		public static string ModPath { get; private set; }

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			_harmony = new Harmony("com.dreams.nazhikacore");
			Log.Init(((BaseUnityPlugin)this).Logger);
			ModPath = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			((BaseUnityPlugin)this).Logger.LogInfo((object)("[NazhikaCore] ModPath = " + ModPath));
			ClassSkillKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keybinds", "ClassSkillKey", new KeyboardShortcut((KeyCode)57, Array.Empty<KeyCode>()), "Tecla para activar la habilidad de clase.");
			WeaponsLoader.Init();
			SkillsUI.Init(_harmony);
			AdrenalinePatch.Init(_harmony);
			LoginClasses.Init(_harmony);
			OrbsUI.Init(_harmony);
			TankAi.Init(_harmony);
			FistBjornClawRecipePatch.Init(_harmony);
			ItemPatches.Init(_harmony);
			BoarContainerFoodPatch.Init(_harmony, ((BaseUnityPlugin)this).Config);
			SE_BleedingSetup.Init();
			SE_CurseSetup.Init();
			SE_BlindnessSetup.Init();
			SE_OrbGaugeSetup.Init();
			SE_ParryRegenSetup.Init();
			SE_PassiveAtkSpeedSetup.Init();
			SE_WitheredSetup.Init();
			SE_WarcrySetup.Init();
			SE_TankPassiveSetup.Init();
			SE_SwordLightningSetup.Init();
			SE_SwordPoisonSetup.Init();
			SE_SwordWitherSetup.Init();
			SE_SpearStacksSetup.Init();
			SE_BloodBurstSetup.Init();
			SE_BerserkfurySetup.Init();
			SE_BerserkBurstSetup.Init();
			SE_BerserkerGodSetup.Init();
			SE_BerserkerGodCooldownSetup.Init();
			SE_FocusShotSetup.Init();
			SE_LightningStormSetup.Init();
			SE_MagicRootsSetup.Init();
			SE_ToxicCloudSetup.Init();
			SE_LavaRocksSetup.Init();
			BerserkerPatches.Init(_harmony);
			Patch_BerserkBurstStamina.Init(_harmony);
			BalanceConfig.Init(((BaseUnityPlugin)this).Config);
			ClassSkillsPatches.Init(_harmony);
			LightningStorm_BlockAttackPatch.Init(_harmony);
			Monk_KiPatches.Init(_harmony);
			ArcherCritPatches.Init(_harmony);
			GlobalChatConfig.Init(((BaseUnityPlugin)this).Config);
			GlobalChatModule.Init(_harmony);
			SignAwakePatch.Init(_harmony);
			TmpTextSetterPatch.Init(_harmony);
			TerrainHeightUnlocked.Init(_harmony);
			PartyRPC.Init(_harmony);
			PartyCommands.Init(_harmony);
			PartyHUD.Init(_harmony);
			UnstuckCommand.Init(_harmony);
			SwordLightningRPC.Init(_harmony);
			SwordPoisonRPC.Init(_harmony);
			SwordWitherRPC.Init(_harmony);
			WarcryRPC.Init(_harmony);
			BerserkBurstRPC.Init(_harmony);
			MonkLeapSkill.Init(_harmony);
			MonkChiReleaseSkill.Init(_harmony);
			MonkLeapPatches.Init(_harmony);
			BleedingPopupRPC.Init(_harmony);
			MagicRootGlow.Init(_harmony);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[NazhikaCore] ANTES de BloodBurstNet.Init");
			BloodBurstNet.Init(_harmony);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[NazhikaCore] DESPUES de BloodBurstNet.Init");
			ClearStatusEffectsRPC.Init(_harmony);
			Player_CheerEmoteRPC.Init(_harmony);
			Player_ToxicCloudRPC.Init(_harmony);
			SelectorClass.Init();
			ClearEffects.Init();
			TeleportDown.Init();
			ShoutDeath.Init(((BaseUnityPlugin)this).Config, _harmony, ((BaseUnityPlugin)this).Logger);
			ClassSpriteLoader.ImageFolder = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Images");
			GUIManager.OnCustomGUIAvailable += ClassSelectionUI.Instance.OnGUIAvailable;
			PrefabManager.OnVanillaPrefabsAvailable += delegate
			{
				GameObject prefab = PrefabManager.Instance.GetPrefab("Custom_Magetable_Ext_1");
				if ((Object)(object)prefab != (Object)null && (Object)(object)prefab.GetComponent<MageTableInteract>() == (Object)null)
				{
					prefab.AddComponent<MageTableInteract>();
				}
			};
			((BaseUnityPlugin)this).Logger.LogInfo((object)"✅ NazhikaCore inicializado correctamente.");
		}

		private void Update()
		{
			ClassManager.Update();
			MonkLeapSkill.EnsureRpcRegistered();
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"\ud83d\uded1 NazhikaCore descargado y parches removidos.");
		}
	}
}
namespace NazhikaCore.Utils
{
	public static class EmotesNet
	{
		public static void PlayCheer(Player player)
		{
			if (!((Object)(object)((Character)(player?)).m_nview == (Object)null) && ((Character)player).m_nview.IsValid())
			{
				((Character)player).m_nview.InvokeRPC(ZNetView.Everybody, "RPC_Nazhika_PlayCheer", Array.Empty<object>());
			}
		}
	}
	public static class IconHelper
	{
		public static Sprite Load(string fileName)
		{
			string text = Path.Combine(MainPlugin.ModPath, "NazhikaCore", "Assets", "Icons");
			string text2 = Path.Combine(text, fileName);
			Debug.Log((object)("[NazhikaCore.IconHelper] Buscando ícono en: " + text));
			if (!File.Exists(text2))
			{
				return null;
			}
			Sprite val = AssetUtils.LoadSpriteFromFile(text2);
			if ((Object)(object)val != (Object)null)
			{
				Debug.Log((object)("[NazhikaCore.IconHelper] ✅ Ícono cargado: " + fileName));
			}
			else
			{
				Debug.LogWarning((object)("[NazhikaCore.IconHelper] ⚠\ufe0f Error al cargar sprite desde: " + text2));
			}
			return val;
		}
	}
	public static class Log
	{
		private static ManualLogSource _logger;

		public static void Init(ManualLogSource logger)
		{
			_logger = logger;
		}

		public static void Info(string message)
		{
			_logger.LogInfo((object)message);
		}

		public static void Warning(string message)
		{
			_logger.LogWarning((object)message);
		}

		public static void Error(string message)
		{
			_logger.LogError((object)message);
		}
	}
}
namespace NazhikaCore.StatusEffects
{
	public class SE_BerserkBurst : StatusEffect
	{
		public static readonly int NameHash = StringExtensionMethods.GetStableHashCode("SE_BerserkBurst");

		public static float BurstDuration = 5f;

		private Character m_char;

		private const string FuryKey = "naz_fury";

		private const string BurstCooldownUntilKey = "naz_berserkburst_cd_until";

		private bool _fxApplied;

		private bool _fxTried;

		private float _waitTimeout = 3f;

		private readonly List<GameObject> _spawnedRight = new List<GameObject>();

		private readonly List<GameObject> _spawnedLeft = new List<GameObject>();

		private bool _stopping;

		private float _savedStamina;

		private float _savedMaxStamina;

		private const float BurstStaminaBonus = 40f;

		private const string RightHandPath = "Visual/Armature/Hips/Spine/Spine1/Spine2/RightShoulder/RightArm/RightForeArm/RightHand/RightHand_Attach/attach(Clone)";

		private const string LeftHandPath = "Visual/Armature/Hips/Spine/Spine1/Spine2/LeftShoulder/LeftArm/LeftForeArm/LeftHand/LeftHand_Attach/attach(Clone)";

		public static float DamageMult => BalanceConfig.BerserkDamageMult;

		public static bool IsStopping { get; private set; } = false;

		public SE_BerserkBurst()
		{
			((Object)this).name = "SE_BerserkBurst";
			base.m_name = "Berserker Burst";
			base.m_icon = IconHelper.Load("BerserkerBurst.png");
			base.m_tooltip = $"Aumento de daño temporal (x{DamageMult:0.00}).";
			base.m_ttl = BurstDuration;
		}

		public override void Setup(Character character)
		{
			_stopping = false;
			IsStopping = false;
			((StatusEffect)this).Setup(character);
			m_char = character;
			_fxApplied = false;
			_fxTried = false;
			_waitTimeout = 3f;
			_spawnedRight.Clear();
			_spawnedLeft.Clear();
			Player val = (Player)(object)((character is Player) ? character : null);
			if (val != null && (Object)(object)((Character)val).m_nview != (Object)null && ((Character)val).m_nview.IsValid())
			{
				ZDO zDO = ((Character)val).m_nview.GetZDO();
				if (zDO != null)
				{
					zDO.Set("naz_fury", 0f);
				}
			}
			Player val2 = (Player)(object)((character is Player) ? character : null);
			if (val2 != null && (Object)(object)val2 == (Object)(object)Player.m_localPlayer)
			{
				_savedStamina = val2.GetStamina();
				_savedMaxStamina = ((Character)val2).GetMaxStamina();
				((Character)val2).AddStamina(40f);
				Debug.Log((object)$"[BerserkBurst] Stamina guardada={_savedStamina:F1} max={_savedMaxStamina:F1} | +{40f} aplicado");
			}
			Player val3 = (Player)(object)((character is Player) ? character : null);
			if (val3 != null)
			{
				BerserkBurstRPC.ApplyFromStatus(val3, active: true);
				BerserkBurstRPC.BroadcastActivated(val3);
			}
		}

		public override void UpdateStatusEffect(float dt)
		{
			((StatusEffect)this).UpdateStatusEffect(dt);
			if (_stopping)
			{
				return;
			}
			Character obj = m_char;
			Player val = (Player)(object)((obj is Player) ? obj : null);
			if ((Object)(object)val != (Object)null && (Object)(object)((Character)val).m_nview != (Object)null && ((Character)val).m_nview.IsValid())
			{
				ZDO zDO = ((Character)val).m_nview.GetZDO();
				if (zDO != null && zDO.GetFloat("naz_fury", 0f) > 0f)
				{
					zDO.Set("naz_fury", 0f);
				}
			}
			Character obj2 = m_char;
			Player val2 = (Player)(object)((obj2 is Player) ? obj2 : null);
			if ((Object)(object)val2 == (Object)null || (Object)(object)Player.m_localPlayer != (Object)(object)val2 || _fxApplied || (_fxTried && _waitTimeout <= 0f))
			{
				return;
			}
			if ((Object)(object)ObjectDB.instance == (Object)null)
			{
				_waitTimeout -= dt;
			}
			else if (!TryApplyAxeFX(val2))
			{
				_waitTimeout -= dt;
				if (_waitTimeout <= 0f)
				{
					_fxTried = true;
				}
			}
		}

		public override void Stop()
		{
			_stopping = true;
			IsStopping = true;
			((StatusEffect)this).Stop();
			Character obj = m_char;
			Player val = (Player)(object)((obj is Player) ? obj : null);
			if ((Object)(object)val != (Object)null)
			{
				BerserkBurstRPC.ApplyFromStatus(val, active: false);
			}
			CleanupAxeFX();
			if ((Object)(object)val != (Object)null && (Object)(object)((Character)val).m_nview != (Object)null && ((Character)val).m_nview.IsValid() && ((Character)val).m_nview.GetZDO() != null && (Object)(object)ZNet.instance != (Object)null)
			{
				ZDO zDO = ((Character)val).m_nview.GetZDO();
				zDO.Set("naz_fury", 0f);
				float num = (float)ZNet.instance.GetTimeSeconds();
				zDO.Set("naz_berserkburst_cd_until", num + 15f);
			}
			if ((Object)(object)val != (Object)null && (Object)(object)val == (Object)(object)Player.m_localPlayer)
			{
				val.m_stamina = Mathf.Min(_savedStamina, ((Character)val).GetMaxStamina());
				Debug.Log((object)$"[BerserkBurst] Stamina restaurada={val.m_stamina:F1}");
			}
			if ((Object)(object)val != (Object)null && !((Character)val).IsDead())
			{
				SEMan sEMan = ((Character)val).GetSEMan();
				if (sEMan != null && (Object)(object)sEMan.GetStatusEffect(SE_Berserkfury.NameHash) == (Object)null)
				{
					sEMan.AddStatusEffect(SE_Berserkfury.NameHash, false, 0, 0f);
				}
				if ((Object)(object)Player.m_localPlayer == (Object)(object)val)
				{
					SkillsUI.StartCooldown(15f);
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				MonoBehaviour component = ((Component)val).GetComponent<MonoBehaviour>();
				if ((Object)(object)component != (Object)null)
				{
					component.StartCoroutine(ResetStoppingFlag());
				}
			}
		}

		private static IEnumerator ResetStoppingFlag()
		{
			yield return null;
			IsStopping = false;
		}

		private bool TryApplyAxeFX(Player player)
		{
			//IL_016b: 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_0191: 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_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			string itemName;
			bool flag = TryFindOneHandedAxe(player, out itemName);
			string itemName2;
			bool flag2 = !flag && TryFindTwoHandedAxe(player, out itemName2);
			if (!flag && !flag2)
			{
				_fxTried = true;
				return false;
			}
			HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "nihoggrAxe", "Viking_Axe", "collider" };
			string text;
			bool flag3;
			bool flag4;
			if (flag)
			{
				text = "teq_nihoggr_axe";
				flag3 = true;
				flag4 = true;
			}
			else
			{
				text = "teq_skoll_battleaxe";
				flag3 = true;
				flag4 = false;
				hashSet.Add("LeviathanAxe");
			}
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text);
			if ((Object)(object)itemPrefab == (Object)null)
			{
				return false;
			}
			Transform val = itemPrefab.transform.Find("attach");
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			Transform val2 = (flag3 ? ((Component)player).transform.Find("Visual/Armature/Hips/Spine/Spine1/Spine2/RightShoulder/RightArm/RightForeArm/RightHand/RightHand_Attach/attach(Clone)") : null);
			Transform val3 = (flag4 ? ((Component)player).transform.Find("Visual/Armature/Hips/Spine/Spine1/Spine2/LeftShoulder/LeftArm/LeftForeArm/LeftHand/LeftHand_Attach/attach(Clone)") : null);
			if (flag3 && (Object)(object)val2 == (Object)null)
			{
				return false;
			}
			if (flag4 && (Object)(object)val3 == (Object)null)
			{
				return false;
			}
			int num = 0;
			int num2 = 0;
			for (int i = 0; i < val.childCount; i++)
			{
				Transform child = val.GetChild(i);
				if (!hashSet.Contains(((Object)child).name))
				{
					if ((Object)(object)val2 != (Object)null)
					{
						GameObject val4 = Object.Instantiate<GameObject>(((Component)child).gameObject, val2);
						((Object)val4).name = ((Object)child).name;
						val4.transform.localPosition = child.localPosition;
						val4.transform.localRotation = child.localRotation;
						val4.transform.localScale = child.localScale;
						ForceActivateHierarchy(val4);
						_spawnedRight.Add(val4);
						num++;
					}
					if ((Object)(object)val3 != (Object)null)
					{
						GameObject val5 = Object.Instantiate<GameObject>(((Component)child).gameObject, val3);
						((Object)val5).name = ((Object)child).name;
						val5.transform.localPosition = child.localPosition;
						val5.transform.localRotation = child.localRotation;
						val5.transform.localScale = child.localScale;
						ForceActivateHierarchy(val5);
						_spawnedLeft.Add(val5);
						num2++;
					}
				}
			}
			_fxApplied = num + num2 > 0;
			_fxTried = true;
			return _fxApplied;
		}

		private void CleanupAxeFX()
		{
			_fxApplied = false;
			SafeCleanup(_spawnedRight);
			SafeCleanup(_spawnedLeft);
			_spawnedRight.Clear();
			_spawnedLeft.Clear();
		}

		private static bool TryFindOneHandedAxe(Player p, out string itemName)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Invalid comparison between Unknown and I4
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Invalid comparison between Unknown and I4
			itemName = null;
			foreach (ItemData candidateItem in GetCandidateItems(p))
			{
				if (candidateItem?.m_shared != null && (int)candidateItem.m_shared.m_skillType == 7 && (int)candidateItem.m_shared.m_itemType == 3)
				{
					itemName = candidateItem.m_shared.m_name;
					return true;
				}
			}
			return false;
		}

		private static bool TryFindTwoHandedAxe(Player p, out string itemName)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Invalid comparison between Unknown and I4
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			itemName = null;
			foreach (ItemData candidateItem in GetCandidateItems(p))
			{
				if (candidateItem?.m_shared != null && (int)candidateItem.m_shared.m_skillType == 7 && (int)candidateItem.m_shared.m_itemType == 14)
				{
					itemName = candidateItem.m_shared.m_name;
					return true;
				}
			}
			return false;
		}

		private static IEnumerable<ItemData> GetCandidateItems(Player p)
		{
			yield return ((Humanoid)p).GetCurrentWeapon();
			yield return ((Humanoid)p).GetRightItem();
			yield return ((Humanoid)p).GetLeftItem();
		}

		private static void ForceActivateHierarchy(GameObject root)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)root == (Object)null))
			{
				SetActiveRecursive(root.transform, active: true);
				ParticleSystem[] componentsInChildren = root.GetComponentsInChildren<ParticleSystem>(true);
				foreach (ParticleSystem val in componentsInChildren)
				{
					EmissionModule emission = val.emission;
					((EmissionModule)(ref emission)).enabled = true;
					val.Clear(true);
					val.Play(true);
				}
				TrailRenderer[] componentsInChildren2 = root.GetComponentsInChildren<TrailRenderer>(true);
				for (int j = 0; j < componentsInChildren2.Length; j++)
				{
					((Renderer)componentsInChildren2[j]).enabled = true;
					componentsInChildren2[j].Clear();
				}
				LineRenderer[] componentsInChildren3 = root.GetComponentsInChildren<LineRenderer>(true);
				for (int k = 0; k < componentsInChildren3.Length; k++)
				{
					((Renderer)componentsInChildren3[k]).enabled = true;
				}
				Light[] componentsInChildren4 = root.GetComponentsInChildren<Light>(true);
				for (int l = 0; l < componentsInChildren4.Length; l++)
				{
					((Behaviour)componentsInChildren4[l]).enabled = true;
				}
			}
		}

		private static void SetActiveRecursive(Transform t, bool active)
		{
			((Component)t).gameObject.SetActive(active);
			for (int i = 0; i < t.childCount; i++)
			{
				SetActiveRecursive(t.GetChild(i), active);
			}
		}

		private static int SafeCleanup(List<GameObject> list)
		{
			int num = 0;
			for (int i = 0; i < list.Count; i++)
			{
				if ((Object)(object)list[i] != (Object)null)
				{
					Object.Destroy((Object)(object)list[i]);
					num++;
				}
			}
			list.Clear();
			return num;
		}
	}
	public static class SE_BerserkBurstSetup
	{
		private static bool _asmRegistered;

		public static void Init()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			SE_BerserkBurst sE_BerserkBurst = ScriptableObject.CreateInstance<SE_BerserkBurst>();
			CustomStatusEffect val = new CustomStatusEffect((StatusEffect)(object)sE_BerserkBurst, true);
			ItemManager.Instance.AddStatusEffect(val);
			Log.Info("[NazhikaCore] ✅ SE_BerserkBurst registrado (usa BerserkBurstRPC para FX+SFX+Roar).");
			if (_asmRegistered)
			{
				return;
			}
			_asmRegistered = true;
			AnimationSpeedManager.Add(delegate(Character character, double speed)
			{
				Player val2 = (Player)(object)((character is Player) ? character : null);
				if ((Object)(object)val2 == (Object)null)
				{
					return speed;
				}
				if (!ClassApi.HasClass(val2, "Berserker"))
				{
					return speed;
				}
				if (!((Character)val2).InAttack() || ((Humanoid)val2).m_currentAttack == null)
				{
					return speed;
				}
				SEMan sEMan = ((Character)val2).GetSEMan();
				return (sEMan == null || (Object)(object)sEMan.GetStatusEffect(SE_BerserkBurst.NameHash) == (Object)null) ? speed : (speed * (double)BalanceConfig.BerserkAtkSpeedMult);
			});
		}
	}
	public class SE_BerserkerGod : StatusEffect
	{
		public static readonly int NameHash = StringExtensionMethods.GetStableHashCode("SE_BerserkerGod");

		public const string FuryBlockZdoKey = "naz_fury_block";

		public const string GodCdZdoKey = "naz_bg_cd_until";

		private const float CooldownSeconds = 80f;

		public SE_BerserkerGod()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			((Object)this).name = "SE_BerserkerGod";
			base.m_name = "Berserker God";
			base.m_icon = IconHelper.Load("BerserkerGod.png");
			base.m_tooltip = "Invulnerable por 8s";
			base.m_ttl = 8f;
			base.m_cooldown = 80f;
			base.m_startMessage = "† Berserker God activado †";
			base.m_startMessageType = (MessageType)2;
		}

		public override void Setup(Character character)
		{
			((StatusEffect)this).Setup(character);
			try
			{
				Player val = (Player)(object)((character is Player) ? character : null);
				if ((Object)(object)val != (Object)null)
				{
					val.SetGodMode(true);
				}
				Character character2 = base.m_character;
				object obj;
				if (character2 == null)
				{
					obj = null;
				}
				else
				{
					ZNetView nview = character2.m_nview;
					obj = ((nview != null) ? nview.GetZDO() : null);
				}
				ZDO val2 = (ZDO)obj;
				if (val2 != null)
				{
					val2.Set("naz_fury_block", true);
				}
			}
			catch
			{
			}
		}

		public override void Stop()
		{
			try
			{
				Character character = base.m_character;
				Player val = (Player)(object)((character is Player) ? character : null);
				if ((Object)(object)val != (Object)null)
				{
					val.SetGodMode(false);
				}
				Character character2 = base.m_character;
				object obj;
				if (character2 == null)
				{
					obj = null;
				}
				else
				{
					ZNetView nview = character2.m_nview;
					obj = ((nview != null) ? nview.GetZDO() : null);
				}
				ZDO val2 = (ZDO)obj;
				if (val2 != null)
				{
					val2.Set("naz_fury_block", false);
				}
				float num = (((Object)(object)EnvMan.instance != (Object)null) ? ((float)EnvMan.instance.m_totalSeconds) : Time.time);
				if ((Object)(object)val != (Object)null)
				{
					val.m_customData["naz_bg_cd_until"] = (num + 80f).ToString(CultureInfo.InvariantCulture);
					Debug.Log((object)string.Format("[NazhikaCore][BerserkerGod] SE_BerserkerGod.Stop: customData[{0}]={1:0.#}", "naz_bg_cd_until", num + 80f));
				}
				Character character3 = base.m_character;
				SEMan val3 = ((character3 != null) ? character3.GetSEMan() : null);
				if (val3 != null && (Object)(object)val3.GetStatusEffect(SE_BerserkerGodCooldown.NameHash) == (Object)null)
				{
					SE_BerserkerGodCooldown sE_BerserkerGodCooldown = val3.AddStatusEffect(SE_BerserkerGodCooldown.NameHash, false, 0, 0f) as SE_BerserkerGodCooldown;
					if ((Object)(object)sE_BerserkerGodCooldown != (Object)null)
					{
						sE_BerserkerGodCooldown.SetDuration(80f);
					}
				}
			}
			catch
			{
			}
			((StatusEffect)this).Stop();
		}
	}
	public static class SE_BerserkerGodSetup
	{
		public static void Init()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			SE_BerserkerGod sE_BerserkerGod = ScriptableObject.CreateInstance<SE_BerserkerGod>();
			CustomStatusEffect val = new CustomStatusEffect((StatusEffect)(object)sE_BerserkerGod, true);
			ItemManager.Instance.AddStatusEffect(val);
			Debug.Log((object)"[NazhikaCore] ✅ SE_BerserkerGod registrado.");
		}
	}
	public class SE_BerserkerGodCooldown : StatusEffect
	{
		public const string InternalName = "SE_BerserkerGodCooldown";

		public static readonly int NameHash = StringExtensionMethods.GetStableHashCode("SE_BerserkerGodCooldown");

		public SE_BerserkerGodCooldown()
		{
			((Object)this).name = "SE_BerserkerGodCooldown";
			base.m_name = "God";
			base.m_tooltip = "En recarga...";
			base.m_ttl = 80f;
			base.m_cooldownIcon = true;
			base.m_icon = IconHelper.Load("BerserkerGod.png");
		}

		public void SetDuration(float seconds)
		{
			base.m_ttl = Mathf.Max(0.1f, seconds);
			base.m_time = 0f;
		}

		public override void UpdateStatusEffect(float dt)
		{
			((StatusEffect)this).UpdateStatusEffect(dt);
			float num = Mathf.Max(0f, base.m_ttl - base.m_time);
			base.m_tooltip = $"En recarga ({num:0}s)";
		}
	}
	public static class SE_BerserkerGodCooldownSetup
	{
		public static void Init()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			SE_BerserkerGodCooldown sE_BerserkerGodCooldown = ScriptableObject.CreateInstance<SE_BerserkerGodCooldown>();
			CustomStatusEffect val = new CustomStatusEffect((StatusEffect)(object)sE_BerserkerGodCooldown, true);
			ItemManager.Instance.AddStatusEffect(val);
			Debug.Log((object)"[NazhikaCore] ✅ SE_BerserkerGodCooldown registrado.");
		}
	}
	public class SE_Berserkfury : StatusEffect
	{
		public static readonly int NameHash = StringExtensionMethods.GetStableHashCode("SE_Berserkfury");

		private const string FuryKey = "naz_fury";

		public SE_Berserkfury()
		{
			((Object)this).name = "SE_Berserkfury";
			base.m_name = "Berserker Fury";
			base.m_icon = IconHelper.Load("BerserkerFury.png");
			base.m_tooltip = "La furia se carga al golpear.";
			base.m_ttl = 999999f;
		}

		public override string GetIconText()
		{
			Character character = base.m_character;
			object obj;
			if (character == null)
			{
				obj = null;
			}
			else
			{
				ZNetView nview = character.m_nview;
				obj = ((nview != null) ? nview.GetZDO() : null);
			}
			ZDO val = (ZDO)obj;
			if (val == null)
			{
				return "";
			}
			float num = val.GetFloat("naz_fury", 0f);
			if (!(num > 0f))
			{
				return "";
			}
			return ((int)num).ToString();
		}
	}
	public static class SE_BerserkfurySetup
	{
		public static void Init()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			SE_Berserkfury sE_Berserkfury = ScriptableObject.CreateInstance<SE_Berserkfury>();
			CustomStatusEffect val = new CustomStatusEffect((StatusEffect)(object)sE_Berserkfury, true);
			ItemManager.Instance.AddStatusEffect(val);
			Log.Info("[NazhikaCore] ✅ SE_Berserkfury registrado (marcador).");
		}
	}
	public class SE_Bleeding : StatusEffect
	{
		public static readonly int NameHash = StringExtensionMethods.GetStableHashCode("SE_Bleeding");

		private float tickTimer;

		private float fxTimer;

		private const float BaseHpCap = 10000f;

		private const float MoveSpeedMultiplier = 0.95f;

		internal const string ZdoBleedStacksKey = "nz_bleed_stacks";

		private int _stacks = 1;

		public int Stacks => _stacks;

		public SE_Bleeding()
		{
			((Object)this).name = "SE_Bleeding";
			base.m_name = "Bleeding";
			base.m_tooltip = "Estás sangrando: pierdes vida cada segundo.";
			base.m_icon = IconHelper.Load("bleed.png");
			base.m_ttl = 5f;
		}

		public override void Setup(Character c)
		{
			((StatusEffect)this).Setup(c);
			if (_stacks <= 0)
			{
				_stacks = 1;
			}
			_stacks = Mathf.Clamp(_stacks, 1, BalanceConfig.BleedMaxStacks);
			tickTimer = 0f;
			fxTimer = 0f;
			WriteStacksToZdo(_stacks);
			ApplyBleedTick();
		}

		public override void ModifySpeed(float baseSpeed, ref float speed, Character character, Vector3 dir)
		{
			speed *= 0.95f;
		}

		public override void UpdateStatusEffect(float dt)
		{
			((StatusEffect)this).UpdateStatusEffect(dt);
			tickTimer += dt;
			fxTimer += dt;
			if (tickTimer >= BalanceConfig.BleedTickInterval)
			{
				tickTimer = 0f;
				ApplyBleedTick();
			}
			if (fxTimer >= 1f)
			{
				fxTimer = 0f;
				SpawnBloodFXSafe();
			}
			base.m_tooltip = $"Estás sangrando ({_stacks} stack(s)): el daño por tick se duplica a {BalanceConfig.BleedMaxStacks} stacks. " + "Movimiento -5% (no afecta ataque).";
		}

		public void AddBleedStack()
		{
			_stacks = Mathf.Clamp(_stacks + 1, 1, BalanceConfig.BleedMaxStacks);
			base.m_time = 0f;
			if (base.m_ttl < 3f)
			{
				base.m_ttl = 3f;
			}
			WriteStacksToZdo(_stacks);
		}

		private void ApplyBleedTick()
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)base.m_character == (Object)null || !base.m_character.IsOwner())
			{
				return;
			}
			float maxHealthSafe = GetMaxHealthSafe(base.m_character);
			if (!(maxHealthSafe <= 0f))
			{
				int tier = GetTier(maxHealthSafe);
				float num = maxHealthSafe * 0.1f;
				if (tier >= 7 && num > 10000f)
				{
					num = 10000f;
				}
				float fixedBaseByTier = GetFixedBaseByTier(tier);
				float num2 = num * BalanceConfig.BleedFractionPerStack;
				float num3 = fixedBaseByTier + num2;
				float stackMultiplier = GetStackMultiplier(_stacks);
				float num4 = Mathf.Max(0f, num3 * stackMultiplier * 0.333f);
				float health = base.m_character.GetHealth();
				float health2 = Mathf.Max(0f, health - num4);
				base.m_character.SetHealth(health2);
				BleedingPopupRPC.SendBleedPopup(base.m_character.GetCenterPoint(), num4, _stacks);
				Debug.Log((object)($"[NazhikaCore/Bleeding] {((Object)base.m_character).name} maxHP={maxHealthSafe:0} tier={tier} stacks={_stacks} " + $"hpBase={num:0.#} fixed={fixedBaseByTier:0.#} scaled1={num2:0.##} base1={num3:0.##} mult={stackMultiplier:0.###} dmg={num4:0.##}"));
			}
		}

		private float GetStackMultiplier(int stacks)
		{
			int bleedMaxStacks = BalanceConfig.BleedMaxStacks;
			stacks = Mathf.Clamp(stacks, 1, bleedMaxStacks);
			if (bleedMaxStacks <= 1)
			{
				return 1f;
			}
			return 1f + ((float)stacks - 1f) / ((float)bleedMaxStacks - 1f);
		}

		private static int GetTier(float hp)
		{
			if (hp < 60f)
			{
				return 0;
			}
			if (hp < 180f)
			{
				return 1;
			}
			if (hp < 450f)
			{
				return 2;
			}
			if (hp < 1500f)
			{
				return 3;
			}
			if (hp < 3000f)
			{
				return 4;
			}
			if (hp < 5000f)
			{
				return 5;
			}
			if (hp < 10000f)
			{
				return 6;
			}
			if (hp < 50000f)
			{
				return 7;
			}
			return 8;
		}

		private static float GetFixedBaseByTier(int tier)
		{
			return tier switch
			{
				0 => BalanceConfig.BleedFixedT0, 
				1 => BalanceConfig.BleedFixedT1, 
				2 => BalanceConfig.BleedFixedT2, 
				3 => BalanceConfig.BleedFixedT3, 
				4 => BalanceConfig.BleedFixedT4, 
				5 => BalanceConfig.BleedFixedT5, 
				6 => BalanceConfig.BleedFixedT6, 
				7 => BalanceConfig.BleedFixedT7, 
				8 => BalanceConfig.BleedFixedT8, 
				_ => 10f, 
			};
		}

		private static float GetMaxHealthSafe(Character ch)
		{
			try
			{
				return ch.GetMaxHealth();
			}
			catch
			{
				return Mathf.Max(1f, ch.GetHealth());
			}
		}

		private void SpawnBloodFXSafe()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)base.m_character == (Object)null) && !((Object)(object)ZNetScene.instance == (Object)null))
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("vfx_BloodHit");
				if (Object.op_Implicit((Object)(object)prefab))
				{
					Object.Instantiate<GameObject>(prefab, base.m_character.GetCenterPoint(), Quaternion.identity);
				}
			}
		}

		public override void Stop()
		{
			WriteStacksToZdo(0);
			((StatusEffect)this).Stop();
		}

		private void WriteStacksToZdo(int stacks)
		{
			try
			{
				if (!((Object)(object)base.m_character == (Object)null) && !((Object)(object)base.m_character.m_nview == (Object)null) && base.m_character.m_nview.IsValid())
				{
					ZDO zDO = base.m_character.m_nview.GetZDO();
					if (zDO != null)
					{
						zDO.Set("nz_bleed_stacks", stacks);
					}
				}
			}
			catch
			{
			}
		}
	}
	public static class SE_BleedingSetup
	{
		public static void Init()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			SE_Bleeding sE_Bleeding = ScriptableObject.CreateInstance<SE_Bleeding>();
			CustomStatusEffect val = new CustomStatusEffect((StatusEffect)(object)sE_Bleeding, true);
			ItemManager.Instance.AddStatusEffect(val);
			Debug.Log((object)"[NazhikaCore] SE_Bleeding registrado (ZDO stacks sync).");
		}
	}
	public class SE_Blindness : StatusEffect
	{
		private GameObject blackoutCanvas;

		private Image blackoutImage;

		private float fadeSpeed = 2f;

		private float targetAlpha = 0.95f;

		public SE_Blindness()
		{
			((Object)this).name = "SE_Blindness";
			base.m_name = "Blindness";
			base.m_tooltip = "Estás cegado. Tu visión se oscurece.";
			base.m_icon = IconHelper.Load("Blindness.png");
			base.m_cooldownIcon = true;
			base.m_ttl = 6f;
		}

		public override void Setup(Character character)
		{
			((StatusEffect)this).Setup(character);
			Player val = (Player)(object)((character is Player) ? character : null);
			if (val != null && (Object)(object)val == (Object)(object)Player.m_localPlayer)
			{
				CreateBlackout();
			}
		}

		public override void UpdateStatusEffect(float dt)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			((StatusEffect)this).UpdateStatusEffect(dt);
			if ((Object)(object)blackoutImage != (Object)null)
			{
				Color color = ((Graphic)blackoutImage).color;
				color.a = Mathf.MoveTowards(color.a, targetAlpha, fadeSpeed * dt);
				((Graphic)blackoutImage).color = color;
			}
		}

		public override void Stop()
		{
			RemoveBlackout();
		}

		private void CreateBlackout()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)blackoutCanvas != (Object)null))
			{
				blackoutCanvas = new GameObject("Naz_BlindnessCanvas");
				Canvas val = blackoutCanvas.AddComponent<Canvas>();
				val.renderMode = (RenderMode)0;
				val.sortingOrder = 9999;
				CanvasGroup val2 = blackoutCanvas.AddComponent<CanvasGroup>();
				val2.blocksRaycasts = false;
				val2.interactable = false;
				GameObject val3 = new GameObject("Naz_BlindnessImage");
				val3.transform.SetParent(blackoutCanvas.transform, false);
				blackoutImage = val3.AddComponent<Image>();
				((Graphic)blackoutImage).color = new Color(0f, 0f, 0f, 0f);
				RectTransform rectTransform = ((Graphic)blackoutImage).rectTransform;
				rectTransform.anchorMin = Vector2.zero;
				rectTransform.anchorMax = Vector2.one;
				rectTransform.offsetMin = Vector2.zero;
				rectTransform.offsetMax = Vector2.zero;
				Object.DontDestroyOnLoad((Object)(object)blackoutCanvas);
			}
		}

		private void RemoveBlackout()
		{
			if ((Object)(object)blackoutCanvas != (Object)null)
			{
				Object.Destroy((Object)(object)blackoutCanvas);
				blackoutCanvas = null;
				blackoutImage = null;
			}
		}
	}
	public static class SE_BlindnessSetup
	{
		public static void Init()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			SE_Blindness sE_Blindness = ScriptableObject.CreateInstance<SE_Blindness>();
			CustomStatusEffect val = new CustomStatusEffect((StatusEffect)(object)sE_Blindness, true);
			ItemManager.Instance.AddStatusEffect(val);
			Debug.Log((object)"[NazhikaCore] SE_Blindness registrado correctamente.");
		}
	}
	public class SE_BloodBurst : StatusEffect
	{
		public static readonly int NameHash = StringExtensionMethods.GetStableHashCode("SE_BloodBurst");

		private const float RadiusMeters = 60f;

		private const bool DebugLogs = true;

		private const float MaxStacks = 7f;

		private const float MinSkillLevel = 20f;

		private const float MinTotalDamage = 40f;

		private const float DamagePerLevelAt7 = 4f;

		public SE_BloodBurst()
		{
			((Object)this).name = "SE_BloodBurst";
			base.m_name = "BloodBurst";
			base.m_icon = IconHelper.Load("bloodburst.png");
			base.m_tooltip = "Detona sangrados cercanos.";
			base.m_ttl = 1f;
		}

		public override void Setup(Character character)
		{
			((StatusEffect)this).Setup(character);
			ExecuteLocal(character);
			base.m_time = base.m_ttl;
		}

		private static void ExecuteLocal(Character caster)
		{
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Expected O, but got Unknown
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: 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_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)caster == (Object)null)
			{
				return;
			}
			Player val = (Player)(object)((caster is Player) ? caster : null);
			float num = ((val != null) ? ((Character)val).GetSkills().GetSkillLevel((SkillType)4) : 0f);
			float num2 = ((num < 20f) ? 5.714286f : (num * 4f / 7f));
			Debug.Log((object)$"[BloodBurst] skillLevel={num} damagePerStack={num2:F1}");
			List<Character> list = new List<Character>();
			Character.GetCharactersInRange(((Component)caster).transform.position, 60f, list);
			Debug.Log((object)$"[BloodBurst] Characters cercanos: {list.Count}");
			int num3 = 0;
			foreach (Character item in list)
			{
				if ((Object)(object)item == (Object)null || (Object)(object)item == (Object)(object)caster || item.IsDead())
				{
					continue;
				}
				int num4 = 0;
				try
				{
					ZNetView nview = item.m_nview;
					ZDO val2 = ((nview != null) ? nview.GetZDO() : null);
					if (val2 != null)
					{
						num4 = val2.GetInt("nz_bleed_stacks", 0);
					}
				}
				catch
				{
				}
				if (num4 <= 0)
				{
					Debug.Log((object)("[BloodBurst][SKIP] " + ((Object)item).name + " sin bleeding"));
					continue;
				}
				float num5 = num2 * (float)num4;
				Debug.Log((object)$"[BloodBurst][HIT] {((Object)item).name} stacks={num4} damage={num5:F1} hp={item.GetHealth():F1}");
				HitData val3 = new HitData();
				val3.m_damage.m_damage = num5;
				val3.m_point = ((Component)item).transform.position;
				Vector3 val4 = ((Component)item).transform.position - ((Component)caster).transform.position;
				val3.m_dir = ((Vector3)(ref val4)).normalized;
				val3.m_skillLevel = 0f;
				item.Damage(val3);
				BleedApplyRPC.RequestCancelBleed(item);
				BloodBurstNet.TryBroadcastFx(item.GetCenterPoint());
				num3++;
			}
			Debug.Log((object)$"[BloodBurst] afectados={num3}");
		}
	}
	internal static class BloodBurstNet
	{
		private class RegRunner : MonoBehaviour
		{
			private bool _running;

			public void Kick()
			{
				if (!_running)
				{
					_running = true;
					((MonoBehaviour)this).StartCoroutine(Loop());
				}
			}

			private IEnumerator Loop()
			{
				float t = 0f;
				while (t < 2f && !_registered)
				{
					if (ZRoutedRpc.instance != null)
					{
						EnsureRegisteredNow();
						break;
					}
					t += 0.1f;
					yield return (object)new WaitForSeconds(0.1f);
				}
				_running = false;
			}
		}

		internal const string RpcFxName = "NazhikaCore_BloodBurstFx";

		private const bool DebugLogs = true;

		private static bool _registered;

		private static GameObject _regRunnerGo;

		private static RegRunner _regRunner;

		public static void Init(Harmony harmony)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			MethodInfo methodInfo = AccessTools.Method(typeof(ZNet), "Start", (Type[])null, (Type[])null);
			HarmonyMethod val = new HarmonyMethod(typeof(BloodBurstNet), "ZNet_Start_Postfix", (Type[])null);
			harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Debug.Log((object)"[NazhikaCore/BloodBurstNet] Init OK");
		}

		private static void ZNet_Start_Postfix()
		{
			EnsureRegisteredRobust();
		}

		public static void EnsureRegisteredRobust()
		{
			if (!_registered)
			{
				if (ZRoutedRpc.instance != null)
				{
					EnsureRegisteredNow();
					return;
				}
				EnsureRegRunner();
				_regRunner.Kick();
			}
		}

		private static void EnsureRegRunner()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			if (!((Object)(object)_regRunner != (Object)null))
			{
				_regRunnerGo = GameObject.Find("NazhikaCore_BloodBurst_RegRunner");
				if ((Object)(object)_regRunnerGo == (Object)null)
				{
					_regRunnerGo = new GameObject("NazhikaCore_BloodBurst_RegRunner");
					Object.DontDestroyOnLoad((Object)(object)_regRunnerGo);
				}
				_regRunner = _regRunnerGo.GetComponent<RegRunner>();
				if ((Object)(object)_regRunner == (Object)null)
				{
					_regRunner = _regRunnerGo.AddComponent<RegRunner>();
				}
			}
		}

		private static void EnsureRegisteredNow()
		{
			if (!_registered && ZRoutedRpc.instance != null)
			{
				ZRoutedRpc.instance.Register<Vector3>("NazhikaCore_BloodBurstFx", (Action<long, Vector3>)RPC_SpawnFx);
				_registered = true;
				Debug.Log((object)"[NazhikaCore/BloodBurstNet] RPC registrado: FX=NazhikaCore_BloodBurstFx");
			}
		}

		public static bool TryBroadcastFx(Vector3 pos)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			EnsureRegisteredRobust();
			if (ZRoutedRpc.instance == null)
			{
				return false;
			}
			try
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "NazhikaCore_BloodBurstFx", new object[1] { pos });
				return true;
			}
			catch (Exception arg)
			{
				Debug.LogWarning((object)$"[NazhikaCore/BloodBurstNet] BroadcastFx ex: {arg}");
				return false;
			}
		}

		private static void RPC_SpawnFx(long sender, Vector3 pos)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated())
			{
				BloodBurstFxFactory.SpawnAtRobust(pos);
			}
		}
	}
	internal static class BloodBurstFxFactory
	{
		private class FxRunner : MonoBehaviour
		{
			private readonly Queue<Vector3> _queue = new Queue<Vector3>();

			private bool _running;

			public void Enqueue(Vector3 pos)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				_queue.Enqueue(pos);
				if (!_running)
				{
					_running = true;
					((MonoBehaviour)this).StartCoroutine(Loop());
				}
			}

			private IEnumerator Loop()
			{
				while (_queue.Count > 0)
				{
					Vector3 pos = _queue.Dequeue();
					yield return SpawnWithRetry(pos);
				}
				_running = false;
			}

			private IEnumerator SpawnWithRetry(Vector3 pos)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				yield return (object)new WaitForSeconds(0.05f);
				float t = 0f;
				while (t < 3f)
				{
					if ((Object)(object)ZNetScene.instance != (Object)null)
					{
						GameObject vanillaPrefab = GetVanillaPrefab();
						if ((Object)(object)vanillaPrefab != (Object)null)
						{
							GameObject val = Object.Instantiate<GameObject>(vanillaPrefab, pos, Quaternion.identity);
							if ((Object)(object)val != (Object)null)
							{
								PruneAndScaleInstance(val);
								ForceActivate(val);
								val.SetActive(true);
								break;
							}
						}
					}
					t += 0.1f;
					yield return (object)new WaitForSeconds(0.1f);
				}
			}
		}

		private const string VanillaFxName = "fx_CharredStone_Destruction";

		private static GameObject _vanillaPrefab;

		private static readonly string[] KeepKeywords = new string[3] { "skull", "smoke", "glow" };

		private static GameObject _runnerGo;

		private static FxRunner _runner;

		public static void SpawnAtRobust(Vector3 pos)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			EnsureRunner();
			_runner.Enqueue(pos);
		}

		private static void EnsureRunner()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			if (!((Object)(object)_runner != (Object)null))
			{
				_runnerGo = GameObject.Find("NazhikaCore_BloodBurst_FxRunner");
				if ((Object)(object)_runnerGo == (Object)null)
				{
					_runnerGo = new GameObject("NazhikaCore_BloodBurst_FxRunner");
					Object.DontDestroyOnLoad((Object)(object)_runnerGo);
				}
				_runner = _runnerGo.GetComponent<FxRunner>();
				if ((Object)(object)_runner == (Object)null)
				{
					_runner = _runnerGo.AddComponent<FxRunner>();
				}
			}
		}

		private static GameObject GetVanillaPrefab()
		{
			if ((Object)(object)_vanillaPrefab != (Object)null)
			{
				return _vanillaPrefab;
			}
			if ((Object)(object)ZNetScene.instance == (Object)null)
			{
				return null;
			}
			_vanillaPrefab = ZNetScene.instance.GetPrefab("fx_CharredStone_Destruction");
			return _vanillaPrefab;
		}

		private static void PruneAndScaleInstance(GameObject fxInstance)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)fxInstance == (Object)null)
			{
				return;
			}
			int num = 0;
			Transform[] componentsInChildren = fxInstance.GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if ((Object)(object)val != (Object)null && IsKeepName(((Object)val).name))
				{
					num++;
				}
			}
			if (num <= 0)
			{
				return;
			}
			DisableNonKeepBranches(fxInstance.transform);
			Transform[] componentsInChildren2 = fxInstance.GetComponentsInChildren<Transform>(true);
			foreach (Transform val2 in componentsInChildren2)
			{
				if ((Object)(object)val2 != (Object)null && IsKeepName(((Object)val2).name))
				{
					val2.localScale *= 0.5f;
				}
			}
		}

		private static void DisableNonKeepBranches(Transform root)
		{
			for (int i = 0; i < root.childCount; i++)
			{
				Transform child = root.GetChild(i);
				if (!((Object)(object)child == (Object)null) && !BranchHasKeep(child))
				{
					((Component)child).gameObject.SetActive(false);
				}
			}
		}

		private static bool BranchHasKeep(Transform t)
		{
			if ((Object)(object)t == (Object)null)
			{
				return false;
			}
			if (IsKeepName(((Object)t).name))
			{
				return true;
			}
			for (int i = 0; i < t.childCount; i++)
			{
				if (BranchHasKeep(t.GetChild(i)))
				{
					return true;
				}
			}
			return false;
		}

		private static bool IsKeepName(string name)
		{
			if (string.IsNullOrEmpty(name))
			{
				return false;
			}
			string text = name.ToLowerInvariant();
			for (int i = 0; i < KeepKeywords.Length; i++)
			{
				if (text.Contains(KeepKeywords[i]))
				{
					return true;
				}
			}
			return false;
		}

		private static void ForceActivate(GameObject root)
		{
			//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)
			if (Object.op_Implicit((Object)(object)root))
			{
				Transform[] componentsInChildren = root.GetComponentsInChildren<Transform>(true);
				foreach (Transform val in componentsInChildren)
				{
					((Component)val).gameObject.SetActive(true);
				}
				ParticleSystem[] componentsInChildren2 = root.GetComponentsInChildren<ParticleSystem>(true);
				foreach (ParticleSystem val2 in componentsInChildren2)
				{
					EmissionModule emission = val2.emission;
					((EmissionModule)(ref emission)).enabled = true;
					val2.Clear(true);
					val2.Play(true);
				}
			}
		}
	}
	public static class SE_BloodBurstSetup
	{
		public static void Init()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			SE_BloodBurst sE_BloodBurst = ScriptableObject.CreateInstance<SE_BloodBurst>();
			CustomStatusEffect val = new CustomStatusEffect((StatusEffect)(object)sE_BloodBurst, true);
			ItemManager.Instance.AddStatusEffect(val);
			BloodBurstNet.EnsureRegisteredRobust();
			Debug.Log((object)"[NazhikaCore] SE_BloodBurst registrado (daño escalado por Polearms + stacks).");
		}
	}
	public class SE_Curse : StatusEffect
	{
		private float tickTimer;

		private float fxTimer;

		private float damagePerTick = 5f;

		private float tickInterval = 2f;

		public SE_Curse()
		{
			((Object)this).name = "SE_Curse";
			base.m_name = "Curse";
			base.m_tooltip = "Estas maldito, el daño que haga se te devolvera.";
			base.m_icon = IconHelper.Load("curse.png");
			base.m_ttl = 5f;
		}

		public override void UpdateStatusEffect(float dt)
		{
		}
	}
	public static class SE_CurseSetup
	{
		public static void Init()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			SE_Curse sE_Curse = ScriptableObject.CreateInstance<SE_Curse>();
			CustomStatusEffect val = new CustomStatusEffect((StatusEffect)(object)sE_Curse, true);
			ItemManager.Instance.AddStatusEffect(val);
			Debug.Log((object)"[NazhikaCore] SE_Curse registrado correctamente.");
		}
	}
	public class SE_FocusShot : StatusEffect
	{
		public const string InternalName = "SE_FocusShot";

		public static readonly int NameHash = StringExtensionMethods.GetStableHashCode("SE_FocusShot");

		public const string ZdoKeyActive = "focusshot_active";

		private Character _ch;

		public SE_FocusShot()
		{
			((Object)this).name = "SE_FocusShot";
			base.m_name = "Focus Shot";
			base.m_icon = IconHelper.Load("focusshot.png");
			base.m_ttl = 15f;
			base.m_tooltip = "Concentración del arquero: más daño al próximo disparo de arco.";
		}

		public override void Setup(Character character)
		{
			((StatusEffect)this).Setup(character);
			_ch = character;
			Player val = (Player)(object)((character is Player) ? character : null);
			if ((Object)(object)val != (Object)null)
			{
				ZNetView component = ((Component)val).GetComponent<ZNetView>();
				if ((Object)(object)component != (Object)null && component.IsValid() && component.GetZDO() != null && component.IsOwner())
				{
					component.GetZDO().Set("focusshot_active", 1);
					Debug.Log((object)("[SE_FocusShot] ZDO flag set → focusshot_active=1 para " + val.GetPlayerName()));
				}
			}
		}

		public override void UpdateStatusEffect(float dt)
		{
			((StatusEffect)this).UpdateStatusEffect(dt);
			base.m_tooltip = "Focus Shot activo (" + Mathf.CeilToInt(GetRemainingTTL()) + "s)";
		}

		public override void Stop()
		{
			Character ch = _ch;
			Player val = (Player)(object)((ch is Player) ? ch : null);
			if ((Object)(object)val != (Object)null)
			{
				ZNetView component = ((Component)val).GetComponent<ZNetView>();
				if ((Object)(object)component != (Object)null && component.IsValid() && component.GetZDO() != null && component.IsOwner())
				{
					component.GetZDO().Set("focusshot_active", 0);
					Debug.Log((object)("[SE_FocusShot] ZDO flag cleared → focusshot_active=0 para " + val.GetPlayerName()));
				}
				long playerID = val.GetPlayerID();
				FocusShotRuntime.RaiseFocusRemoved(playerID);
				PlayerClassBase playerClassBase = ClassManager.GetClass(val);
				if (playerClassBase != null)
				{
					playerClassBase.TryBeginCooldown(val);
					SkillsUI.StartCooldown(playerClassBase.CooldownSeconds);
					Log.Info($"[SE_FocusShot] Buff terminado → cooldown de {playerClassBase.CooldownSeconds}s iniciado para {val.GetPlayerName()}");
				}
			}
			((StatusEffect)this).Stop();
		}

		private float GetRemainingTTL()
		{
			return Mathf.Max(0f, base.m_ttl - base.m_time);
		}
	}
	public static class SE_FocusShotSetup
	{
		public static void Init()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			SE_FocusShot sE_FocusShot = ScriptableObject.CreateInstance<SE_FocusShot>();
			CustomStatusEffect val = new CustomStatusEffect((StatusEffect)(object)sE_FocusShot, true);
			ItemManager.Instance.AddStatusEffect(val);
			Debug.Log((object)"[NazhikaCore] ✅ SE_FocusShot registrado en Jotunn");
		}
	}
	public static class FocusShotRuntime
	{
		public static event Action<long> FocusRemoved;

		public static void RaiseFocusRemoved(long playerId)
		{
			try
			{
				if (FocusShotRuntime.FocusRemoved != null)
				{
					FocusShotRuntime.FocusRemoved(playerId);
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[FocusShot] FocusRemoved event error: " + ex));
			}
		}
	}
	public class SE_LavaRocks : StatusEffect
	{
		private class NoDamageCleaner : MonoBehaviour
		{
			private GameObject _root;

			private int _frames;

			public void Run(GameObject r, int frames)
			{
				_root = r;
				_frames = frames;
			}

			private void LateUpdate()
			{
				if ((Object)(object)_root == (Object)null)
				{
					Object.Destroy((Object)(object)this);
					return;
				}
				CleanOnce(_root);
				if (--_frames <= 0)
				{
					Object.Destroy((Object)(object)this);
				}
			}
		}

		public const string InternalName = "SE_LavaRocks";

		public static readonly int NameHash = StringExtensionMethods.GetStableHashCode("SE_LavaRocks");

		private const KeyCode ToggleKey = (KeyCode)57;

		private const string LavaRockPrefabName = "LavaRock";

		private const int RocksCount = 4;

		private const float CircleYOffset = 0.06f;

		private const float SymbolWorldSize = 6f;

		private static readonly Vector3 MarkerScale = Vector3.one;

		private const string MarkerTextureFile = "sealSymbol3.png";

		private const float SpawnRadius = 6f;

		private const float SpawnYOffset = 0.15f;

		private const float MinCenterDistance = 0.9f;

		private Character _ch;

		private GameObject _marker;

		private GameObject _symbol;

		private bool _spawnReadyShown;

		public SE_LavaRocks()
		{
			((Object)this).name = "SE_LavaRocks";
			base.m_name = "Lava Rocks";
			base.m_icon = IconHelper.Load("LavaRocks.png");
			base.m_tooltip = "Apunta y haz clic derecho para invocar rocas de lava. Esc: cancelar.";
			base.m_ttl = 8f;
		}

		public override void Setup(Character character)
		{
			((StatusEffect)this).Setup(character);
			_ch = character;
			Character ch = _ch;
			Player val = (Player)(object)((ch is Player) ? ch : null);
			if (val != null && (Object)(object)Player.m_localPlayer == (Object)(object)val)
			{
				EnsureMarker(val);
				_marker.SetActive(true);
				SnapMarkerToMouse();
				_spawnReadyShown = true;
			}
		}

		public override void UpdateStatusEffect(float dt)
		{
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			((StatusEffect)this).UpdateStatusEffect(dt);
			base.m_tooltip = $"Lava Rocks ({Mathf.CeilToInt(Mathf.Max(0f, base.m_ttl - base.m_time))}s) — RMB: rocas, LMB/Esc: cancelar";
			Character ch = _ch;
			Player val = (Player)(object)((ch is Player) ? ch : null);
			if (val == null || (Object)(object)Player.m_localPlayer != (Object)(object)val)
			{
				return;
			}
			if (Input.GetKeyDown((KeyCode)57))
			{
				EnsureMarker(val);
				_marker.SetActive(!_marker.activeSelf);
			}
			if ((Object)(object)_marker == (Object)null)
			{
				return;
			}
			if (_marker.activeSelf)
			{
				if (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)27))
				{
					_marker.SetActive(false);
					return;
				}
				SnapMarkerToMouse();
				if (Input.GetMouseButtonDown(1))
				{
					if ((Object)(object)((Character)val).m_nview != (Object)null && ((Character)val).m_nview.IsValid())
					{
						((Character)val).m_nview.InvokeRPC(ZNetView.Everybody, "RPC_Nazhika_PlayCheer", Array.Empty<object>());
					}
					Vector3 position = _marker.transform.position;
					SpawnLavaRocks(position, 6f, 4);
					_marker.SetActive(false);
					base.m_time = base.m_ttl;
				}
			}
			else if (!_spawnReadyShown)
			{
				EnsureMarker(val);
				_marker.SetActive(true);
				SnapMarkerToMouse();
				_spawnReadyShown = true;
			}
		}

		public override void Stop()
		{
			((StatusEffect)this).Stop();
			Character character = base.m_character;
			Player val = (Player)(object)((character is Player) ? character : null);
			if (val != null)
			{
				PlayerClassBase playerClassBase = ClassManager.GetClass(val);
				if (playerClassBase != null)
				{
					playerClassBase.TryBeginCooldown(val);
					SkillsUI.StartCooldown(playerClassBase.CooldownSeconds);
				}
			}
			try
			{
				if ((Object)(object)_marker != (Object)null)
				{
					Object.Destroy((Object)(object)_marker);
				}
				_marker = null;
				_symbol = null;
			}
			catch
			{
			}
		}

		private void EnsureMarker(Player owner)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0030: 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_00ad: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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_0153: Expected O, but got Unknown
			if ((Object)(object)_marker != (Object)null)
			{
				return;
			}
			_marker = new GameObject("LavaRocksMarker_SE");
			_marker.transform.position = ((Component)owner).transform.position;
			_marker.transform.localScale = MarkerScale;
			_marker.SetActive(false);
			_symbol = GameObject.CreatePrimitive((PrimitiveType)5);
			((Object)_symbol).name = "SealSymbol3";
			_symbol.transform.SetParent(_marker.transform, false);
			_symbol.transform.localPosition = new Vector3(0f, 0.06f, 0f);
			_symbol.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f);
			_symbol.transform.localScale = Vector3.one * 6f;
			Renderer component = _symbol.GetComponent<Renderer>();
			Shader val = TryFindShader("Unlit/Transparent", "Sprites/Default", "Legacy Shaders/Transparent/Diffuse", "Particles/Standard Unlit", "Standard");
			if ((Object)(object)component != (Object)null && (Object)(object)val != (Object)null)
			{
				Material val2 = new Material(val);
				val2.mainTexture = (Texture)(object)LoadTexture_NoRef("sealSymbol3.png");
				val2.renderQueue = 3000;
				try
				{
					if (val2.HasProperty("_Cull"))
					{
						val2.SetInt("_Cull", 0);
					}
				}
				catch
				{
				}
				component.material = val2;
			}
			Collider component2 = _symbol.GetComponent<Collider>();
			if ((Object)(object)component2 != (Object)null)
			{
				Object.Destroy((Object)(object)component2);
			}
		}

		private void SnapMarkerToMouse()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			Camera gameCamera = GetGameCamera();
			if (!((Object)(object)gameCamera == (Object)null) && !((Object)(object)_marker == (Object)null))
			{
				Ray val = gameCamera.ScreenPointToRay(Input.mousePosition);
				RaycastHit val2 = default(RaycastHit);
				if (Physics.Raycast(val, ref val2, 500f, -1, (QueryTriggerInteraction)1))
				{
					Vector3 point = ((RaycastHit)(ref val2)).point;
					point.y += 0.06f;
					_marker.transform.position = point;
				}
			}
		}

		private static void SpawnLavaRocks(Vector3 center, float radius, int count)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ZNetScene.instance == (Object)null)
			{
				return;
			}
			GameObject prefab = ZNetScene.instance.GetPrefab("LavaRock");
			if ((Object)(object)prefab == (Object)null)
			{
				Debug.LogWarning((object)"[SE_LavaRocks] Prefab no encontrado: \"LavaRock\"");
				return;
			}
			Vector3 val2 = default(Vector3);
			for (int i = 0; i < count; i++)
			{
				Vector2 val = Random.insideUnitCircle * radius;
				if (((Vector2)(ref val)).magnitude < 0.9f)
				{
					val = ((Vector2)(ref val)).normalized * 0.9f;
				}
				((Vector3)(ref val2))..ctor(center.x + val.x, center.y, center.z + val.y);
				if (TrySnapToGround(val2, out var snapped))
				{
					val2 = snapped;
				}
				val2.y += 0.15f;
				Quaternion val3 = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f);
				GameObject root = Object.Instantiate<GameObject>(prefab, val2, val3);
				NukeDamageComponents(root);
			}
		}

		private static bool TrySnapToGround(Vector3 near, out Vector3 snapped)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			snapped = near;
			Vector3 val = near + Vector3.up * 25f;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val, Vector3.down, ref val2, 80f, -1, (QueryTriggerInteraction)1))
			{
				snapped = ((RaycastHit)(ref val2)).point;
				return true;
			}
			return false;
		}

		private static void NukeDamageComponents(GameObject root)
		{
			if (Object.op_Implicit((Object)(object)root))
			{
				CleanOnce(root);
				NoDamageCleaner noDamageCleaner = root.AddComponent<NoDamageCleaner>();
				noDamageCleaner.Run(root, 6);
			}
		}

		private static void CleanOnce(GameObject root)
		{
			//IL_001f: 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)
			try
			{
				Aoe[] componentsInChildren = root.GetComponentsInChildren<Aoe>(true);
				foreach (Aoe val in componentsInChildren)
				{
					if (!((Object)(object)val == (Object)null))
					{
						val.m_damage = default(DamageTypes);
						((Behaviour)val).enabled = false;
					}
				}
				Projectile[] componentsInChildren2 = root.GetComponentsInChildren<Projectile>(true);
				foreach (Projectile val2 in componentsInChildren2)
				{
					if (!((Object)(object)val2 == (Object)null))
					{
						val2.m_damage = default(DamageTypes);
						((Behaviour)val2).enabled = false;
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[SE_LavaRocks] CleanOnce error: " + ex.Message));
			}
		}

		private static Camera GetGameCamera()
		{
			if ((Object)(object)GameCamera.instance?.m_camera != (Object)null)
			{
				return GameCamera.instance.m_camera;
			}
			return Camera.main;
		}

		private static Shader TryFindShader(params string[] names)
		{
			foreach (string text in names)
			{
				Shader val = Shader.Find(text);
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			return null;
		}

		private static Texture2D LoadTexture_NoRef(string fileName)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			string text = Path.Combine(Paths.PluginPath, "NazhikaCore", "Assets", "Images", fileName);
			if (!File.Exists(text))
			{
				Debug.LogWarning((object)("[SE_LavaRocks] PNG no encontrado: " + text));
				return Texture2D.whiteTexture;
			}
			byte[] array = File.ReadAllBytes(text);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			try
			{
				MethodInfo methodInfo = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule")?.GetMethod("LoadImage", new Type[3]
				{
					typeof(Texture2D),
					typeof(byte[]),
					typeof(bool)
				});
				if (methodInfo != null && (bool)methodInfo.Invoke(null, new object[3] { val, array, false }))
				{
					return val;
				}
			}
			catch
			{
			}
			return Texture2D.whiteTexture;
		}
	}
	public static class SE_LavaRocksSetup
	{
		public static void Init()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			SE_LavaRocks sE_LavaRocks = ScriptableObject.CreateInstance<SE_LavaRocks>();
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)sE_LavaRocks, true));
			Debug.Log((object)"[NazhikaCore] ✅ SE_LavaRocks registrado en Jotunn");
		}
	}
	public class SE_LightningStorm : StatusEffect
	{
		private class NoDamageCleaner : MonoBehaviour
		{
			private GameObject _root;

			private int _frames;

			public void Run(GameObject r, int frames)
			{
				_root = r;
				_frames = frames;
			}

			private void LateUpdate()
			{
				if ((Object)(object)_root == (Object)null)
				{
					Object.Destroy((Object)(object)this);
					return;
				}
				CleanOnce(_root);
				_frames--;
				if (_frames <= 0)
				{
					Object.Destroy((Object)(object)this);
				}
			}
		}

		public const string InternalName = "SE_LightningStorm";

		public static readonly int NameHash = StringExtensionMethods.GetStableHashCode("SE_LightningStorm");

		private const KeyCode ToggleKey = (KeyCode)57;

		private const string LightningPrefabName = "lightningAOE";

		private const float CircleYOffset = 0.06f;

		private const float SymbolWorldSize = 3.5f;

		private static readonly Vector3 MarkerScale = Vector3.one;

		private const float ImmobilizeRadius = 5f;

		private const float ImmobilizeCenterBonus = 0f;

		private const float ImmobilizeDuration = 3f;

		private const float SlowDuration = 3f;

		private const float SlowMovePenalty = -0.5f;

		private const float LightningDamageBase = 5f;

		private const float LightningDamagePerSkillLv = 0.2f;

		private const string ImmobilizedName = "ImmobilizedAshlands";

		private static readonly int ImmobilizedHash = StringExtensionMethods.GetStableHashCode("ImmobilizedAshlands");

		private Character _ch;

		private GameObject _marker;

		private GameObject _symbol;

		private bool _spawnReadyShown;

		public SE_LightningStorm()
		{
			((Object)this).name = "SE_LightningStorm";
			base.m_name = "Lightning Storm";
			base.m_icon = IconHelper.Load("LightningStorm.png");
			base.m_tooltip = "Apunta y haz clic derecho para invocar rayos. Esc: cancelar.";
			base.m_ttl = 15f;
		}

		public override void Setup(Character character)
		{
			((StatusEffect)this).Setup(character);
			_ch = character;
			Character ch = _ch;
			Player val = (Player)(object)((ch is Player) ? ch : null);
			if (val != null && (Object)(object)Player.m_localPlayer == (Object)(object)val)
			{
				EnsureMarker(val);
				_marker.SetActive(true);
				SnapMarkerToMouse();
				_spawnReadyShown = true;
			}
		}

		public override void UpdateStatusEffect(float dt)
		{
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			((StatusEffect)this).UpdateStatusEffect(dt);
			base.m_tooltip = $"Lightning Storm ({Mathf.CeilToInt(Mathf.Max(0f, base.m_ttl - base.m_time))}s) — RMB: rayos, LMB/Esc: cancelar";
			Character ch = _ch;
			Player val = (Player)(object)((ch is Player) ? ch : null);
			if (val == null || (Object)(object)Player.m_localPlayer != (Object)(object)val)
			{
				return;
			}
			if (Input.GetKeyDown((KeyCode)57))
			{
				EnsureMarker(val);
				_marker.SetActive(!_marker.activeSelf);
			}
			if ((Object)(object)_marker == (Object)null)
			{
				return;
			}
			if (_marker.activeSelf)
			{
				if (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)27))
				{
					_marker.SetActive(false);
					return;
				}
				SnapMarkerToMouse();
				if (Input.GetMouseButtonDown(1))
				{
					if ((Object)(object)((Character)val).m_nview != (Object)null && ((Character)val).m_nview.IsValid())
					{
						((Character)val).m_nview.InvokeRPC(ZNetView.Everybody, "RPC_Nazhika_PlayCheer", Array.Empty<object>());
					}
					Vector3 position = _marker.transform.position;
					SpawnLightningBurst(position, val);
					_marker.SetActive(false);
					base.m_time = base.m_ttl;
				}
			}
			else if (!_spawnReadyShown)
			{
				EnsureMarker(val);
				_marker.SetActive(true);
				SnapMarkerToMouse();
				_spawnReadyShown = true;
			}
		}

		public override void Stop()
		{
			((StatusEffect)this).Stop();
			Character character = base.m_character;
			Player val = (Player)(object)((character is Player) ? character : null);
			if (val != null)
			{
				PlayerClassBase playerClassBase = ClassManager.GetClass(val);
				if (playerClassBase != null)
				{
					playerClassBase.TryBeginCooldown(val);
					SkillsUI.StartCooldown(playerClassBase.CooldownSeconds);
				}
			}
			try
			{
				if ((Object)(object)_marker != (Object)null)
				{
					Object.Destroy((Object)(object)_marker);
				}
				_marker = null;
				_symbol = null;
			}
			catch
			{
			}
		}

		private void EnsureMarker(Player owner)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0030: 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_00ad: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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_0170: Expected O, but got Unknown
			if ((Object)(object)_marker != (Object)null)
			{
				return;
			}
			_marker = new GameObject("LightningMarker_SE");
			_marker.transform.position = ((Component)owner).transform.position;
			_marker.transform.localScale = MarkerScale;
			_marker.SetActive(false);
			_symbol = GameObject.CreatePrimitive((PrimitiveType)5);
			((Object)_symbol).name = "SealSymbol";
			_symbol.transform.SetParent(_marker.transform, false);
			_symbol.transform.localPosition = new Vector3(0f, 0.06f, 0f);
			_symbol.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f);
			_symbol.transform.localScale = Vector3.one * 3.5f;
			Renderer component = _symbol.GetComponent<Renderer>();
			Shader val = TryFindShader("Unlit/Transparent", "Sprites/Default", "Legacy Shaders/Transparent/Diffuse", "Legacy Shaders/Particles/Alpha Blended", "Particles/Standard Unlit", "Standard");
			Material val2 = (Material)((!((Object)(object)val != (Object)null)) ? ((object)(((Object)(object)component != (Object)null) ? (component.material ?? component.sharedMaterial) : null)) : ((object)new Material(val)));
			if ((Object)(object)val2 != (Object)null)
			{
				try
				{
					if (val2.HasProperty("_Cull"))
					{
						val2.SetInt("_Cull", 0);
					}
				}
				catch
				{
				}
				try
				{
					val2.renderQueue = 3000;
				}
				catch
				{
				}
				val2.mainTexture = (Texture)(object)LoadTexture_NoRef("sealSymbol2.png");
				component.material = val2;
			}
			Collider component2 = _symbol.GetComponent<Collider>();
			if ((Object)(object)component2 != (Object)null)
			{
				Object.Destroy((Object)(object)component2);
			}
		}

		private void SnapMarkerToMouse()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			Camera gameCamera = GetGameCamera();
			if (!((Object)(object)gameCamera == (Object)null) && !((Object)(object)_marker == (Object)null))
			{
				Ray val = gameCamera.ScreenPointToRay(Input.mousePosition);
				RaycastHit val2 = default(RaycastHit);
				if (Physics.Raycast(val, ref val2, 500f, -1, (QueryTriggerInteraction)1))
				{
					Vector3 point = ((RaycastHit)(ref val2)).point;
					point.y = ((RaycastHit)(ref val2)).point.y + 0.06f;
					_marker.transform.position = point;
				}
			}
		}

		private void SpawnLightningBurst(Vector3 center, Player caster)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_009c: 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)
			if ((Object)(object)ZNetScene.instance == (Object)null)
			{
				return;
			}
			GameObject prefab = ZNetScene.instance.GetPrefab("lightningAOE");
			if ((Object)(object)prefab == (Object)null)
			{
				Debug.LogWarning((object)"[SE_LightningStorm] Prefab no encontrado: \"lightningAOE\"");
				return;
			}
			float num = (((Object)(object)caster != (Object)null) ? ((Character)caster).GetSkills().GetSkillLevel((SkillType)9) : 0f);
			float damage = 5f + num * 0.2f;
			for (int i = 0; i < 4; i++)
			{
				Vector3 val = center + Random.insideUnitSphere * 4f;
				val.y = center.y;
				GameObject root = Object.Instantiate<GameObject>(prefab, val, Quaternion.identity);
				NukeDamageComponents(root);
				ApplyImmobilizedInRadius(val, 5f, center, damage);
			}
		}

		private static void TryApplyImmobilized(Character ch, Vector3 hitCenter, float damage)
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ch == (Object)null || ch.IsDead() || ch.IsPlayer())
			{
				return;
			}
			SEMan sEMan = ch.GetSEMan();
			if (sEMan != null)
			{
				sEMan.RemoveStatusEffect(ImmobilizedHash, false);
				StatusEffect val = sEMan.AddStatusEffect(ImmobilizedHash, false, 0, 0f);
				if ((Object)(object)val != (Object)null)
				{
					val.m_ttl = 3f;
				}
				SE_Stats val2 = ScriptableObject.CreateInstance<SE_Stats>();
				((Object)val2).name = "LightningSlow_Temp";
				((StatusEffect)val2).m_ttl = 3f;
				val2.m_speedModifier = -0.5f;
				sEMan.AddStatusEffect((StatusEffect)(object)val2, false, 0, 0f);
				HitData val3 = new HitData();
				val3.m_damage.m_lightning = damage;
				val3.m_point = ((Component)ch).transform.position;
				Vector3 val4 = ((Component)ch).transform.position - hitCenter;
				val3.m_dir = ((Vector3)(ref val4)).normalized;
				val3.m_skillLevel = 0f;
				ch.Damage(val3);
			}
		}

		private static void ApplyImmobilizedInRadius(Vector3 center, float radius, Vector3 hitCenter, float damage)
		{
			//IL_0000: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			Collider[] array = Physics.OverlapSphere(center, radius, -1, (QueryTriggerInteraction)1);
			if (array == null || array.Length == 0)
			{
				return;
			}
			Vector3 val2 = default(Vector3);
			foreach (Collider val in array)
			{
				if (!Object.op_Implicit((Object)(object)val))
				{
					continue;
				}
				Character componentInParent = ((Component)val).GetComponentInParent<Character>();
				if (!((Object)(object)componentInParent == (Object)null))
				{
					Vector3 position = ((Component)componentInParent).transform.position;
					((Vector3)(ref val2))..ctor(center.x, position.y, center.z);
					if (!(Vector3.Distance(position, val2) > radius + 0.15f))
					{
						TryApplyImmobilized(componentInParent, hitCenter, damage);
					}
				}
			}
		}

		private static void NukeDamageComponents(GameObject root)
		{
			if (Object.op_Implicit((Object)(object)root))
			{
				CleanOnce(root);
				NoDamageCleaner noDamageCleaner = root.AddComponent<NoDamageCleaner>();
				noDamageCleaner.Run(root, 6);
			}
		}

		private static void CleanOnce(GameObject root)
		{
			//IL_001f: 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)
			try
			{
				Aoe[] componentsInChildren = root.GetComponentsInChildren<Aoe>(true);
				foreach (Aoe val in componentsInChildren)
				{
					if (!((Object)(object)val == (Object)null))
					{
						val.m_damage = default(DamageTypes);
						((Behaviour)val).enabled = false;
					}
				}
				Projectile[] componentsInChildren2 = root.GetComponentsInChildren<Projectile>(true);
				foreach (Projectile val2 in componentsInChildren2)
				{
					if (!((Object)(object)val2 == (Object)null))
					{
						val2.m_damage = default(DamageTypes);
						((Behaviour)val2).enabled = false;
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[SE_LightningStorm] CleanOnce error: " + ex.Message));
			}
		}

		private static Camera GetGameCamera()
		{
			if ((Object)(object)GameCamera.instance?.m_camera != (Object)null)
			{
				return GameCamera.instance.m_camera;
			}
			return Camera.main;
		}

		private static Shader TryFindShader(params string[] names)
		{
			foreach (string text in names)
			{
				Shader val = Shader.Find(text);
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			return null;
		}

		private static Texture2D LoadTexture_NoRef(string fileName)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			string text = Path.Combine(Paths.PluginPath, "NazhikaCore", "Assets", "Images", fileName);
			if (!File.Exists(text))
			{
				Debug.LogWarning((object)("[SE_LightningStorm] PNG no encontrado: " + text));
				return Texture2D.whiteTexture;
			}
			byte[] array = File.ReadAllBytes(text);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			try
			{
				MethodInfo methodInfo = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule")?.GetMethod("LoadImage", new Type[3]
				{
					typeof(Texture2D),
					typeof(byte[]),
					typeof(bool)
				});
				if (methodInfo != null && (bool)methodInfo.Invoke(null, new object[3] { val, array, false }))
				{
					return val;
				}
			}
			catch
			{
			}
			return Texture2D.whiteTexture;
		}
	}
	public static class SE_LightningStormSetup
	{
		public static void Init()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			SE_LightningStorm sE_LightningStorm = ScriptableObject.CreateInstance<SE_LightningStorm>();
			CustomStatusEffect val = new CustomStatusEffect((StatusEffect)(object)sE_LightningStorm, true);
			ItemManager.Instance.AddStatusEffect(val);
			Debug.Log((object)"[NazhikaCore] ✅ SE_LightningStorm registrado en Jotunn");
		}
	}
	public class SE_MagicRoots : StatusEffect
	{
		private class NoDamageCleaner : MonoBehaviour
		{
			private GameObject _root;

			private int _frames;

			public void Run(GameObject r, int frames)
			{
				_root = r;
				_frames = frames;
			}

			private void LateUpdate()
			{
				if ((Object)(object)_root == (Object)null)
				{
					Object.Destroy((Object)(object)this);
					return;
				}
				CleanOnce(_root);
				if (--_frames <= 0)
				{
					Object.Destroy((Object)(object)this);
				}
			}
		}

		public const string InternalName = "SE_MagicRoots";

		public static readonly int NameHash = StringExtensionMethods.GetStableHashCode("SE_MagicRoots");

		private const KeyCode ToggleKey = (KeyCode)57;

		private const string RootFxPrefab = "fx_RootAshlands";

		private const string RootSfxPrefab = "sfx_weapons_nature_root";

		private const float CircleYOffset = 0.06f;

		private const float SymbolWorldSize = 12f;

		private static readonly Vector3 MarkerScale = Vector3.one;

		private const float ImmobilizeRadius = 8f;

		private const float ImmobilizeDuration = 5f;

		private const string ImmobilizedName = "ImmobilizedLong";

		private static readonly int ImmobilizedHash = StringExtensionMethods.GetStableHashCode("ImmobilizedLong");

		private static readonly int MagicRootsFxHash = SE_MagicRootsFX_Target.NameHash;

		private Character _ch;

		private GameObject _marker;

		private GameObject _symbol;

		private bool _spawnReadyShown;

		public SE_MagicRoots()
		{
			((Object)this).name = "SE_MagicRoots";
			base.m_name = "Magic Roots";
			base.m_icon = IconHelper.Load("MagicRoots.png");
			base.m_tooltip = "Apunta y haz clic derecho para invocar raíces. Esc: cancelar.";
			base.m_ttl = 10f;
		}

		public override void Setup(Character character)
		{
			((StatusEffect)this).Setup(character);
			_ch = character;
			Character ch = _ch;
			Player val = (Player)(object)((ch is Player) ? ch : null);
			if (val != null && (Object)(object)Player.m_localPlayer == (Object)(object)val)
			{
				EnsureMarker(val);
				_marker.SetActive(true);
				SnapMarkerToMouse();
				_spawnReadyShown = true;
			}
		}

		public override void UpdateStatusEffect(float dt)
		{
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			((StatusEffect)this).UpdateStatusEffect(dt);
			base.m_tooltip = $"Magic Roots ({Mathf.CeilToInt(Mathf.Max(0f, base.m_ttl - base.m_time))}s) — RMB: raíces, LMB/Esc: cancelar";
			Character ch = _ch;
			Player val = (Player)(object)((ch is Player) ? ch : null);
			if (val == null || (Object)(object)Player.m_localPlayer != (Object)(object)val)
			{
				return;
			}
			if (Input.GetKeyDown((KeyCode)57))
			{
				EnsureMarker(val);
				_marker.SetActive(!_marker.activeSelf);
			}
			if ((Object)(object)_marker == (Object)null)
			{
				return;
			}
			if (_marker.activeSelf)
			{
				if (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)27))
				{
					_marker.SetActive(false);
					return;
				}
				SnapMarkerToMouse();
				if (Input.GetMouseButtonDown(1))
				{
					if ((Object)(object)((Character)val).m_nview != (Object)null && ((Character)val).m_nview.IsValid())
					{
						((Character)val).m_nview.InvokeRPC(ZNetView.Everybody, "RPC_Nazhika_PlayCheer", Array.Empty<object>());
					}
					Vector3 position = _marker.transform.position;
					SpawnRoots(position);
					_marker.SetActive(false);
					base.m_time = base.m_ttl;
				}
			}
			else if (!_spawnReadyShown)
			{
				EnsureMarker(val);
				_marker.SetActive(true);
				SnapMarkerToMouse();
				_spawnReadyShown = true;
			}
		}

		public override void Stop()
		{
			((StatusEffect)this).Stop();
			Character character = base.m_character;
			Player val = (Player)(object)((character is Player) ? character : null);
			if (val != null)
			{
				PlayerClassBase playerClassBase = ClassManager.GetClass(val);
				if (playerClassBase != null)
				{
					playerClassBase.TryBeginCooldown(val);
					SkillsUI.StartCooldown(playerClassBase.CooldownSeconds);
				}
			}
			try
			{
				if ((Object)(object)_marker != (Object)null)
				{
					Object.Destroy((Object)(object)_marker);
				}
				_marker = null;
				_symbol = null;
			}
			catch
			{
			}
		}

		private void EnsureMarker(Player owner)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0030: 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_00ad: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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_0153: Expected O, but got Unknown
			if (!((Object)(object)_marker != (Object)null))
			{
				_marker = new GameObject("MagicRootsMarker_SE");
				_marker.transform.position = ((Component)owner).transform.position;
				_marker.transform.localScale = MarkerScale;
				_marker.SetActive(false);
				_symbol = GameObject.CreatePrimitive((PrimitiveType)5);
				((Object)_symbol).name = "RootSymbol";
				_symbol.transform.SetParent(_marker.transform, false);
				_symbol.transform.localPosition = new Vector3(0f, 0.06f, 0f);
				_symbol.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f);
				_symbol.transform.localScale = Vector3.one * 12f;
				Renderer component = _symbol.GetComponent<Renderer>();
				Shader val = TryFindShader("Unlit/Transparent", "Sprites/Default", "Legacy Shaders/Transparent/Diffuse", "Particles/Standard Unlit", "Standard");
				if ((Object)(object)component != (Object)null && (Object)(object)val != (Object)null)
				{
					Material val2 = new Material(val);
					val2.mainTexture = (Texture)(object)LoadTexture_NoRef("sealSymbol2.png");
					val2.renderQueue = 3000;
					component.material = val2;
				}
				Collider component2 = _symbol.GetComponent<Collider>();
				if ((Object)(object)component2 != (Object)null)
				{
					Object.Destroy((Object)(object)component2);
				}
			}
		}

		private void SnapMarkerToMouse()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			Camera gameCamera = GetGameCamera();
			if (!((Object)(object)gameCamera == (Object)null) && !((Object)(object)_marker == (Object)null))
			{
				Ray val = gameCamera.ScreenPointToRay(Input.mousePosition);
				RaycastHit val2 = default(RaycastHit);
				if (Physics.Raycast(val, ref val2, 500f, -1, (QueryTriggerInteraction)1))
				{
					Vector3 point = ((RaycastHit)(ref val2)).point;
					point.y += 0.06f;
					_marker.transform.position = point;
				}
			}
		}

		private void SpawnRoots(Vector3 center)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ZNetScene.instance == (Object)null)
			{
				return;
			}
			GameObject prefab = ZNetScene.instance.GetPrefab("fx_RootAshlands");
			if ((Object)(object)prefab == (Object)null)
			{
				Debug.LogWarning((object)"[SE_MagicRoots] Prefab no encontrado: fx_RootAshlands");
				return;
			}
			GameObject root = Object.Instantiate<GameObject>(prefab, center, Quaternion.identity);
			NukeDamageComponents(root);
			PlayRootSound(center);
			ApplyImmobilizedInRadius(center, 8f);
			Character ch = _ch;
			Player val = (Player)(object)((ch is Player) ? ch : null);
			if (val != null && (Object)(object)((Character)val).m_nview != (Object)null && ((Character)val).m_nview.IsValid())
			{
				MagicRootGlow.SendApplyGlow(val, center, 8f);
				GlowRemoveScheduler glowRemoveScheduler = ((Component)val).gameObject.GetComponent<GlowRemoveScheduler>() ?? ((Component)val).gameObject.AddComponent<GlowRemoveScheduler>();
				glowRemoveScheduler.Schedule(val, center, 8f, 5f);
			}
		}

		private static void PlayRootSound(Vector3 pos)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)ZNetScene.instance == (Object)null))
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("sfx_weapons_nature_root");
				if ((Object)(object)prefab == (Object)null)
				{
					Debug.LogWarning((object)"[SE_MagicRoots] SFX no encontrado: sfx_weapons_nature_root");
				}
				else
				{
					Object.Instantiate<GameObject>(prefab, pos, Quaternion.identity);
				}
			}
		}

		private static void TryApplyImmobilized(Character ch)
		{
			if ((Object)(object)ch == (Object)null || ch.IsDead() || ch.IsPlayer())
			{
				return;
			}
			SEMan sEMan = ch.GetSEMan();
			if (sEMan != null)
			{
				StatusEffect val = sEMan.AddStatusEffect(ImmobilizedHash, false, 0, 0f);
				if ((Object)(object)val != (Object)null)
				{
					val.m_ttl = 5f;
				}
				StatusEffect val2 = sEMan.AddStatusEffect(MagicRootsFxHash, false, 0, 0f);
				if ((Object)(object)val2 != (Object)null)
				{
					val2.m_ttl = 5f;
				}
			}
		}

		private static void ApplyImmobilizedInRadius(Vector3 center, float radius)
		{
			//IL_0000: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_005e: 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)
			Collider[] array = Physics.OverlapSphere(center, radius, -1, (QueryTriggerInteraction)1);
			if (array == null || array.Length == 0)
			{
				return;
			}
			Collider[] array2 = array;
			Vector3 val2 = default(Vector3);
			foreach (Collider val in array2)
			{
				if (!Object.op_Implicit((Object)(object)val))
				{
					continue;
				}
				Character componentInParent = ((Component)val).GetComponentInParent<Character>();
				if (!((Object)(object)componentInParent == (Object)null))
				{
					Vector3 position = ((Component)componentInParent).transform.position;
					((Vector3)(ref val2))..ctor(center.x, position.y, center.z);
					if (!(Vector3.Distance(position, val2) > radius + 0.15f))
					{
						TryApplyImmobilized(componentInParent);
					}
				}
			}
		}

		private static void NukeDamageComponents(GameObject root)
		{
			if (Object.op_Implicit((Object)(object)root))
			{
				CleanOnce(root);
				NoDamageCleaner noDamageCleaner = root.AddComponent<NoDamageCleaner>();
				noDamageCleaner.Run(root, 6);
			}
		}

		private static void CleanOnce(GameObject root)
		{
			//IL_001f: 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)
			try
			{
				Aoe[] componentsInChildren = root.GetComponentsInChildren<Aoe>(true);
				foreach (Aoe val in componentsInChildren)
				{
					if (!((Object)(object)val == (Object)null))
					{
						val.m_damage = default(DamageTypes);
						((Behaviour)val).enabled = false;
					}
				}
				Projectile[] componentsInChildren2 = root.GetComponentsInChildren<Projectile>(true);
				foreach (Projectile val2 in componentsInChildren2)
				{
					if (!((Object)(object)val2 == (Object)null))
					{
						val2.m_damage = default(DamageTypes);
						((Behaviour)val2).enabled = false;
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[SE_MagicRoots] CleanOnce error: " + ex.Message));
			}
		}

		private static Camera GetGameCamera()
		{
			if ((Object)(object)GameCamera.instance?.m_camera != (Object)null)
			{
				return GameCamera.instance.m_camera;
			}
			return Camera.main;
		}

		private static Shader TryFindShader(params string[] names)
		{
			foreach (string text in names)
			{
				Shader val = Shader.Find(text);
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			return null;
		}

		private static Texture2D LoadTexture_NoRef(string fileName)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			string text = Path.Combine(Paths.PluginPath, "NazhikaCore", "Assets", "Images", fileName);
			if (!File.Exists(text))
			{
				Debug.LogWarning((object)("[SE_MagicRoots] PNG no encontrado: " + text));
				return Texture2D.whiteTexture;
			}
			byte[] array = File.ReadAllBytes(text);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			try
			{
				MethodInfo methodInfo = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule")?.GetMethod("LoadImage", new Type[3]
				{
					typeof(Texture2D),
					typeof(byte[]),
					typeof(bool)
				});
				if (methodInfo != null && (bool)methodInfo.Invoke(null, new object[3] { val, array, false }))
				{
					return val;
				}
			}
			catch
			{
			}
			return Texture2D.whiteTexture;
		}
	}
	public class GlowRemoveScheduler : MonoBehaviour
	{
		private IEnumerator ScheduleCoroutine(Player p, Vector3 center, float radius, float delay)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			yield return (object)new WaitFo

BepInEx/plugins/Profesiones.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EinjarheimProfessions;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Profesiones")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Profesiones")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("50CF68F9-AA2B-4F41-B995-4C2EB29C4A19")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[HarmonyPatch(typeof(WearNTear), "GetMaterialProperties")]
internal static class Construction_Patch_GetMaterialProperties
{
	private static void Postfix(WearNTear __instance, ref float maxSupport, ref float minSupport, ref float horizontalLoss, ref float verticalLoss)
	{
		try
		{
			if (!((Object)(object)__instance.m_nview != (Object)null) || !__instance.m_nview.IsValid())
			{
				return;
			}
			ZDO zDO = __instance.m_nview.GetZDO();
			if (zDO == null)
			{
				return;
			}
			float num = zDO.GetFloat("nazhi_construction_maxsupport", 0f);
			if (num > 0f)
			{
				float num2 = minSupport / maxSupport;
				maxSupport = num;
				minSupport = num * num2;
				float num3 = zDO.GetFloat("nazhi_construction_maxsupport_vloss", 0f);
				float num4 = zDO.GetFloat("nazhi_construction_maxsupport_hloss", 0f);
				if (num3 > 0f)
				{
					verticalLoss = num3;
				}
				if (num4 > 0f)
				{
					horizontalLoss = num4;
				}
			}
		}
		catch (Exception arg)
		{
			EinjarheimProfessionsPlugin.Log.LogError((object)$"[Construction] Error GetMaterialProperties: {arg}");
		}
	}
}
namespace EinjarheimProfessions;

[BepInPlugin("nazhi.einjarheim.professions", "Einjarheim Professions", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("valheim.exe")]
public class EinjarheimProfessionsPlugin : BaseUnityPlugin
{
	public const string PluginGuid = "nazhi.einjarheim.professions";

	public const string PluginName = "Einjarheim Professions";

	public const string PluginVersion = "1.0.0";

	internal static ManualLogSource Log;

	internal static ConfigEntry<float> ConstructionSupportPerLevel;

	internal const string ZdoKeyMaxSupport = "nazhi_construction_maxsupport";

	internal static SE_Stats ChefRegenHP;

	internal static SE_Stats ChefRegenStamina;

	internal static SE_Stats ChefRegenEitr;

	private Harmony _harmony;

	internal static EinjarheimProfessionsPlugin Instance { get; private set; }

	private void Awake()
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Expected O, but got Unknown
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		Log.LogInfo((object)"[Einjarheim Professions] v1.0.0 – iniciando...");
		BindConfigs();
		InitChefSEs();
		BlacksmithingSystem.RegisterSkill();
		AlchemySystem.RegisterSkill();
		SpecializationSystem.RegisterCommand();
		_harmony = new Harmony("nazhi.einjarheim.professions");
		_harmony.PatchAll();
		Log.LogInfo((object)"[Einjarheim Professions] Profesiones cargadas:");
		Log.LogInfo((object)"[Einjarheim Professions]   · Cooking       – bonus HP/Stamina/Eitr según nivel de cocina del chef");
		Log.LogInfo((object)"[Einjarheim Professions]   · Blacksmithing – durabilidad, daño y armadura según nivel de herrería");
		Log.LogInfo((object)"[Einjarheim Professions]   · Construction  – HP de estructuras y descuento de recursos según Crafting");
		Log.LogInfo((object)"[Einjarheim Professions]   · Alchemy       – potencia, duración y fermentación según nivel de alquimia");
		Log.LogInfo((object)"[Einjarheim Professions]   · Comando /masterizar disponible");
		Log.LogInfo((object)string.Format("[{0}]   · Construction SupportPerLevel={1}", "Einjarheim Professions", ConstructionSupportPerLevel.Value));
	}

	private static void InitChefSEs()
	{
		ChefRegenHP = ScriptableObject.CreateInstance<SE_Stats>();
		((Object)ChefRegenHP).name = "nazhi_chef_regen_hp";
		((StatusEffect)ChefRegenHP).m_name = "Sazón del Chef (HP)";
		((StatusEffect)ChefRegenHP).m_tooltip = "Comida maestra: regeneración de HP aumentada";
		ChefRegenHP.m_healthRegenMultiplier = 1.3f;
		((StatusEffect)ChefRegenHP).m_startMessage = "Sazón del Chef activo (HP)";
		ChefRegenStamina = ScriptableObject.CreateInstance<SE_Stats>();
		((Object)ChefRegenStamina).name = "nazhi_chef_regen_stamina";
		((StatusEffect)ChefRegenStamina).m_name = "Sazón del Chef (Stamina)";
		((StatusEffect)ChefRegenStamina).m_tooltip = "Comida maestra: regeneración de Stamina aumentada";
		ChefRegenStamina.m_staminaRegenMultiplier = 1.2f;
		((StatusEffect)ChefRegenStamina).m_startMessage = "Sazón del Chef activo (Stamina)";
		ChefRegenEitr = ScriptableObject.CreateInstance<SE_Stats>();
		((Object)ChefRegenEitr).name = "nazhi_chef_regen_eitr";
		((StatusEffect)ChefRegenEitr).m_name = "Sazón del Chef (Eitr)";
		((StatusEffect)ChefRegenEitr).m_tooltip = "Comida maestra: regeneración de Eitr aumentada";
		ChefRegenEitr.m_eitrRegenMultiplier = 1.2f;
		((StatusEffect)ChefRegenEitr).m_startMessage = "Sazón del Chef activo (Eitr)";
		Log.LogInfo((object)"[Cooking] SE de Chef maestro inicializados (x10 testing)");
	}

	private void BindConfigs()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		ConstructionSupportPerLevel = ((BaseUnityPlugin)this).Config.Bind<float>("Construction", "SupportPerLevel", 0.5f, new ConfigDescription("Buff de estabilidad cada 10 niveles de Crafting (escalonado). El techo de soporte se multiplica por (1 + tier * valor) donde tier = nivel/10. Las losses se dividen por (1 + tier * valor*0.5). Ej: 0.25 → lv10 +25% soporte (~2 bloques extra en Wood). Para producción usar ~0.25.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
	}

	private void OnDestroy()
	{
		ManualLogSource log = Log;
		if (log != null)
		{
			log.LogInfo((object)"[Einjarheim Professions] OnDestroy – deshaciendo patches.");
		}
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}
}
public enum ProfessionType
{
	None,
	Cooking,
	Blacksmithing,
	Construction,
	Alchemy
}
internal static class SpecializationSystem
{
	private const string ProfileKey = "nazhi_specialization";

	internal const float LevelCap = 50f;

	internal const float SpecializedCap = 100f;

	private static readonly Dictionary<long, ProfessionType> _specializations = new Dictionary<long, ProfessionType>();

	private static string RejectedKey(ProfessionType profession)
	{
		return $"nazhi_spec_rejected_{profession}";
	}

	internal static void RegisterCommand()
	{
		CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new MasterizarCommand());
		CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new RenegarCommand());
	}

	internal static void Save(Player player, ProfessionType spec)
	{
		if ((Object)(object)player == (Object)null)
		{
			return;
		}
		_specializations[player.GetPlayerID()] = spec;
		try
		{
			MethodInfo method = typeof(Player).GetMethod("SetCustomData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (method != null)
			{
				object[] obj = new object[2] { "nazhi_specialization", null };
				int num = (int)spec;
				obj[1] = num.ToString();
				method.Invoke(player, obj);
			}
			else if (typeof(Player).GetField("m_customData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(player) is Dictionary<string, string> dictionary)
			{
				int num = (int)spec;
				dictionary["nazhi_specialization"] = num.ToString();
			}
			EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Specialization] Guardado: {player.GetPlayerName()} → {spec}");
		}
		catch (Exception ex)
		{
			EinjarheimProfessionsPlugin.Log.LogWarning((object)("[Specialization] Save error: " + ex.Message));
		}
	}

	internal static ProfessionType Load(Player player)
	{
		if ((Object)(object)player == (Object)null)
		{
			return ProfessionType.None;
		}
		try
		{
			MethodInfo method = typeof(Player).GetMethod("GetCustomData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			string value = null;
			if (method != null)
			{
				value = method.Invoke(player, new object[1] { "nazhi_specialization" }) as string;
			}
			else if (typeof(Player).GetField("m_customData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(player) is Dictionary<string, string> dictionary)
			{
				dictionary.TryGetValue("nazhi_specialization", out value);
			}
			if (!string.IsNullOrEmpty(value) && int.TryParse(value, out var result))
			{
				return (ProfessionType)result;
			}
		}
		catch (Exception ex)
		{
			EinjarheimProfessionsPlugin.Log.LogWarning((object)("[Specialization] Load error: " + ex.Message));
		}
		return ProfessionType.None;
	}

	internal static void SaveRejection(Player player, ProfessionType profession)
	{
		if ((Object)(object)player == (Object)null)
		{
			return;
		}
		try
		{
			MethodInfo method = typeof(Player).GetMethod("SetCustomData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (method != null)
			{
				method.Invoke(player, new object[2]
				{
					RejectedKey(profession),
					"1"
				});
			}
			else if (typeof(Player).GetField("m_customData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(player) is Dictionary<string, string> dictionary)
			{
				dictionary[RejectedKey(profession)] = "1";
			}
			EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Specialization] Rechazo guardado: {profession}");
		}
		catch (Exception ex)
		{
			EinjarheimProfessionsPlugin.Log.LogWarning((object)("[Specialization] SaveRejection error: " + ex.Message));
		}
	}

	internal static bool HasRejected(Player player, ProfessionType profession)
	{
		if ((Object)(object)player == (Object)null)
		{
			return false;
		}
		try
		{
			MethodInfo method = typeof(Player).GetMethod("GetCustomData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			string value = null;
			if (method != null)
			{
				value = method.Invoke(player, new object[1] { RejectedKey(profession) }) as string;
			}
			else if (typeof(Player).GetField("m_customData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(player) is Dictionary<string, string> dictionary)
			{
				dictionary.TryGetValue(RejectedKey(profession), out value);
			}
			return value == "1";
		}
		catch
		{
			return false;
		}
	}

	internal static ProfessionType GetSpecialization(Player player)
	{
		if ((Object)(object)player == (Object)null)
		{
			return ProfessionType.None;
		}
		long playerID = player.GetPlayerID();
		if (_specializations.TryGetValue(playerID, out var value))
		{
			return value;
		}
		ProfessionType professionType = Load(player);
		_specializations[playerID] = professionType;
		return professionType;
	}

	internal static bool IsMaster(Player player)
	{
		return GetSpecialization(player) != ProfessionType.None;
	}

	internal static bool IsMasterOf(Player player, ProfessionType profession)
	{
		return GetSpecialization(player) == profession;
	}

	internal static float GetCap(Player player, ProfessionType profession)
	{
		return IsMasterOf(player, profession) ? 100f : 50f;
	}

	internal static void Specialize(Player player, ProfessionType newSpec)
	{
		if ((Object)(object)player == (Object)null || newSpec == ProfessionType.None)
		{
			return;
		}
		ProfessionType specialization = GetSpecialization(player);
		if (specialization != ProfessionType.None && specialization != newSpec)
		{
			float skillLevel = GetSkillLevel(player, specialization);
			if (skillLevel > 50f)
			{
				ClampSkill(player, specialization, 50f);
				EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Specialization] {specialization} bajado a {50f}");
			}
		}
		Save(player, newSpec);
		ProfessionType[] array = new ProfessionType[4]
		{
			ProfessionType.Cooking,
			ProfessionType.Blacksmithing,
			ProfessionType.Construction,
			ProfessionType.Alchemy
		};
		foreach (ProfessionType professionType in array)
		{
			if (professionType != newSpec)
			{
				float skillLevel2 = GetSkillLevel(player, professionType);
				if (skillLevel2 >= 50f)
				{
					ClampSkill(player, professionType, 50f);
					EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Specialization] {professionType} clampeado a {50f} al masterizar {newSpec}");
				}
			}
		}
		Player localPlayer = Player.m_localPlayer;
		if (localPlayer != null)
		{
			((Character)localPlayer).Message((MessageType)2, "<color=#FFD700>¡Te has especializado en " + GetProfessionDisplayName(newSpec) + "!</color>", 0, (Sprite)null);
		}
		EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Specialization] {player.GetPlayerName()} → Maestro de {newSpec}");
	}

	internal static void ExecuteMasterizar(Player player)
	{
		if ((Object)(object)player == (Object)null)
		{
			return;
		}
		if (IsMaster(player))
		{
			ProfessionType specialization = GetSpecialization(player);
			((Character)player).Message((MessageType)1, "<color=#FFD700>Ya eres Maestro de " + GetProfessionDisplayName(specialization) + ".</color>", 0, (Sprite)null);
			return;
		}
		List<ProfessionType> list = new List<ProfessionType>();
		ProfessionType[] array = new ProfessionType[4]
		{
			ProfessionType.Cooking,
			ProfessionType.Blacksmithing,
			ProfessionType.Construction,
			ProfessionType.Alchemy
		};
		foreach (ProfessionType professionType in array)
		{
			if (GetSkillLevel(player, professionType) >= 50f)
			{
				list.Add(professionType);
			}
		}
		if (list.Count == 0)
		{
			((Character)player).Message((MessageType)1, "<color=#FF8888>Necesitás al menos nivel 50 en una profesión para masterizarte.</color>", 0, (Sprite)null);
		}
		else
		{
			ShowSpecializationPopup(player, list);
		}
	}

	internal static void ExecuteRenegar(Player player)
	{
		if (!((Object)(object)player == (Object)null))
		{
			if (!IsMaster(player))
			{
				((Character)player).Message((MessageType)1, "<color=#FF8888>No sos Maestro de ninguna profesión.</color>", 0, (Sprite)null);
				return;
			}
			ProfessionType specialization = GetSpecialization(player);
			ShowRenegarPopup(player, specialization);
		}
	}

	internal static void ShowRenegarPopup(Player player, ProfessionType current)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		if (!StoreGui.IsVisible() && !InventoryGui.IsVisible())
		{
			GameObject val = new GameObject("EinjarheimRenegarPopup");
			RenegarPopupHandler renegarPopupHandler = val.AddComponent<RenegarPopupHandler>();
			renegarPopupHandler.Init(player, current);
		}
	}

	internal static void RemoveMastery(Player player)
	{
		if ((Object)(object)player == (Object)null)
		{
			return;
		}
		_specializations[player.GetPlayerID()] = ProfessionType.None;
		try
		{
			MethodInfo method = typeof(Player).GetMethod("SetCustomData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (method != null)
			{
				method.Invoke(player, new object[2]
				{
					"nazhi_specialization",
					0.ToString()
				});
			}
			else if (typeof(Player).GetField("m_customData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(player) is Dictionary<string, string> dictionary)
			{
				dictionary["nazhi_specialization"] = 0.ToString();
			}
		}
		catch (Exception ex)
		{
			EinjarheimProfessionsPlugin.Log.LogWarning((object)("[Specialization] RemoveMastery error: " + ex.Message));
		}
		ProfessionType[] array = new ProfessionType[4]
		{
			ProfessionType.Cooking,
			ProfessionType.Blacksmithing,
			ProfessionType.Construction,
			ProfessionType.Alchemy
		};
		foreach (ProfessionType profession in array)
		{
			float skillLevel = GetSkillLevel(player, profession);
			if (skillLevel > 50f)
			{
				ClampSkill(player, profession, 50f);
			}
		}
		((Character)player).Message((MessageType)2, "<color=#FF8888>Has abandonado tu Maestría. Todas las profesiones quedan limitadas a nivel 50.</color>", 0, (Sprite)null);
		EinjarheimProfessionsPlugin.Log.LogInfo((object)("[Specialization] " + player.GetPlayerName() + " abandonó su Maestría."));
	}

	internal static void ShowSpecializationPopup(Player player, List<ProfessionType> available)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		if (!StoreGui.IsVisible() && !InventoryGui.IsVisible())
		{
			GameObject val = new GameObject("EinjarheimSpecPopup");
			SpecializationPopupHandler specializationPopupHandler = val.AddComponent<SpecializationPopupHandler>();
			specializationPopupHandler.Init(player, available);
		}
	}

	internal static float GetSkillLevel(Player player, ProfessionType profession)
	{
		//IL_0048: 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_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)player == (Object)null)
		{
			return 0f;
		}
		return profession switch
		{
			ProfessionType.Cooking => ((Character)player).GetSkillLevel((SkillType)105), 
			ProfessionType.Construction => ((Character)player).GetSkillLevel((SkillType)107), 
			ProfessionType.Blacksmithing => ((int)BlacksmithingSystem.BlacksmithingSkillType != 0) ? ((Character)player).GetSkillLevel(BlacksmithingSystem.BlacksmithingSkillType) : 0f, 
			ProfessionType.Alchemy => ((int)AlchemySystem.SkillType != 0) ? ((Character)player).GetSkillLevel(AlchemySystem.SkillType) : 0f, 
			_ => 0f, 
		};
	}

	internal static SkillType GetSkillType(ProfessionType profession)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		return (SkillType)(profession switch
		{
			ProfessionType.Cooking => 105, 
			ProfessionType.Blacksmithing => BlacksmithingSystem.BlacksmithingSkillType, 
			ProfessionType.Construction => 107, 
			ProfessionType.Alchemy => AlchemySystem.SkillType, 
			_ => 0, 
		});
	}

	internal static string GetProfessionDisplayName(ProfessionType profession)
	{
		return profession switch
		{
			ProfessionType.Cooking => "Cocina", 
			ProfessionType.Blacksmithing => "Herrería", 
			ProfessionType.Construction => "Construcción", 
			ProfessionType.Alchemy => "Alquimia", 
			_ => "Ninguna", 
		};
	}

	internal static void ClampSkill(Player player, ProfessionType profession, float cap)
	{
		//IL_0050: 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_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Invalid comparison between Unknown and I4
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)player == (Object)null)
		{
			return;
		}
		try
		{
			object? obj = typeof(Player).GetField("m_skills", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(player);
			Skills val = (Skills)((obj is Skills) ? obj : null);
			if (!((Object)(object)val == (Object)null))
			{
				SkillType skillType = GetSkillType(profession);
				if ((int)skillType != 0 && val.m_skillData.TryGetValue(skillType, out var value) && value.m_level >= cap)
				{
					value.m_level = cap;
					value.m_accumulator = 0f;
					EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Specialization] ClampSkill: {profession} → {cap}");
				}
			}
		}
		catch (Exception ex)
		{
			EinjarheimProfessionsPlugin.Log.LogWarning((object)$"[Specialization] ClampSkill error ({profession}): {ex.Message}");
		}
	}

	internal static void OnPlayerSpawned(Player player)
	{
		if ((Object)(object)player == (Object)null || (Object)(object)player != (Object)(object)Player.m_localPlayer)
		{
			return;
		}
		ProfessionType specialization = GetSpecialization(player);
		ProfessionType[] array = new ProfessionType[4]
		{
			ProfessionType.Cooking,
			ProfessionType.Blacksmithing,
			ProfessionType.Construction,
			ProfessionType.Alchemy
		};
		foreach (ProfessionType profession in array)
		{
			float skillLevel = GetSkillLevel(player, profession);
			float cap = GetCap(player, profession);
			if (skillLevel > cap)
			{
				ClampSkill(player, profession, cap);
			}
		}
		EinjarheimProfessionsPlugin.Log.LogInfo((object)("[Specialization] " + player.GetPlayerName() + " → Maestro: " + GetProfessionDisplayName(specialization)));
	}
}
internal class MasterizarCommand : ConsoleCommand
{
	public override string Name => "masterizar";

	public override string Help => "Abre el menú de especialización de profesión si tenés nivel 50+.";

	public override bool IsCheat => false;

	public override void Run(string[] args)
	{
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null)
		{
			Console.instance.Print("No hay jugador local.");
		}
		else
		{
			SpecializationSystem.ExecuteMasterizar(localPlayer);
		}
	}
}
internal class SpecializationPopupHandler : MonoBehaviour
{
	private Player _player;

	private List<ProfessionType> _available;

	private float _waitTimer;

	private bool _shown;

	private GameObject _panel;

	internal void Init(Player player, List<ProfessionType> available)
	{
		_player = player;
		_available = available;
		_shown = false;
		_waitTimer = 0f;
	}

	private void Update()
	{
		if (!_shown)
		{
			_waitTimer += Time.deltaTime;
			if (!(_waitTimer < 0.3f) && !InventoryGui.IsVisible() && !TextInput.IsVisible())
			{
				BuildUI();
				_shown = true;
			}
		}
	}

	private void BuildUI()
	{
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_0219: 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_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0267: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: Expected O, but got Unknown
		//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0314: Expected O, but got Unknown
		if (GUIManager.Instance == null || (Object)(object)GUIManager.CustomGUIFront == (Object)null)
		{
			EinjarheimProfessionsPlugin.Log.LogWarning((object)"[Specialization] GUIManager no disponible.");
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		float num = 380f + (float)_available.Count * 80f;
		_panel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 700f, num, false);
		GameObject val = GUIManager.Instance.CreateText("Elige tu Especialización", _panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -70f), GUIManager.Instance.AveriaSerifBold, 44, GUIManager.Instance.ValheimOrange, true, Color.black, 640f, 70f, false);
		val.GetComponent<Text>().alignment = (TextAnchor)4;
		GameObject val2 = GUIManager.Instance.CreateText("<color=#AADDAA>La profesión elegida podrá subir hasta nivel 100.</color>\n<color=#DDAAAA>Las otras 3 quedarán limitadas al nivel 50.</color>", _panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -155f), GUIManager.Instance.AveriaSerif, 28, Color.white, false, Color.black, 640f, 80f, false);
		val2.GetComponent<Text>().alignment = (TextAnchor)4;
		float num2 = -260f;
		for (int i = 0; i < _available.Count; i++)
		{
			ProfessionType prof = _available[i];
			string professionDisplayName = SpecializationSystem.GetProfessionDisplayName(prof);
			float skillLevel = SpecializationSystem.GetSkillLevel(_player, prof);
			GameObject val3 = GUIManager.Instance.CreateButton($"<color=#88FF88>{professionDisplayName}</color>  <color=#FFD700>(Nivel {skillLevel:0})</color>", _panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, num2 - (float)i * 80f), 500f, 65f);
			((UnityEvent)val3.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				SpecializationSystem.Specialize(_player, prof);
				GUIManager.BlockInput(false);
				Object.Destroy((Object)(object)_panel);
				Object.Destroy((Object)(object)((Component)this).gameObject);
			});
		}
		float num3 = num2 - (float)_available.Count * 80f;
		GameObject val4 = GUIManager.Instance.CreateButton("<color=#FF8888>Cancelar</color>", _panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, num3), 280f, 65f);
		((UnityEvent)val4.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
		{
			GUIManager.BlockInput(false);
			Object.Destroy((Object)(object)_panel);
			Object.Destroy((Object)(object)((Component)this).gameObject);
		});
		GUIManager.BlockInput(true);
		EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Specialization] Popup mostrado con {_available.Count} opcion(es).");
	}

	private void OnDestroy()
	{
		_shown = false;
		GUIManager.BlockInput(false);
	}
}
internal class RenegarCommand : ConsoleCommand
{
	public override string Name => "renegar";

	public override string Help => "Abre confirmación para abandonar tu Maestría actual.";

	public override bool IsCheat => false;

	public override void Run(string[] args)
	{
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null)
		{
			Console.instance.Print("No hay jugador local.");
		}
		else
		{
			SpecializationSystem.ExecuteRenegar(localPlayer);
		}
	}
}
internal class RenegarPopupHandler : MonoBehaviour
{
	private Player _player;

	private ProfessionType _current;

	private float _waitTimer;

	private bool _shown;

	private GameObject _panel;

	internal void Init(Player player, ProfessionType current)
	{
		_player = player;
		_current = current;
		_shown = false;
		_waitTimer = 0f;
	}

	private void Update()
	{
		if (!_shown)
		{
			_waitTimer += Time.deltaTime;
			if (!(_waitTimer < 0.3f) && !InventoryGui.IsVisible() && !TextInput.IsVisible())
			{
				BuildUI();
				_shown = true;
			}
		}
	}

	private void BuildUI()
	{
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0208: Expected O, but got Unknown
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Expected O, but got Unknown
		if (GUIManager.Instance == null || (Object)(object)GUIManager.CustomGUIFront == (Object)null)
		{
			EinjarheimProfessionsPlugin.Log.LogWarning((object)"[Specialization] GUIManager no disponible.");
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		string professionDisplayName = SpecializationSystem.GetProfessionDisplayName(_current);
		_panel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 700f, 450f, false);
		GameObject val = GUIManager.Instance.CreateText("Abandonar Maestría", _panel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -75f), GUIManager.Instance.AveriaSerifBold, 44, GUIManager.Instance.ValheimOrange, true, Color.black, 640f, 70f, false);
		val.GetComponent<Text>().alignment = (TextAnchor)4;
		GameObject val2 = GUIManager.Instance.CreateText("¿Estás seguro que querés abandonar tu Maestría en <color=#FFD700>" + professionDisplayName + "</color>?\n\n<color=#DDAAAA>Todas las profesiones quedarán limitadas al nivel 50.\nPodrás volver a masterizarte con /masterizar.</color>", _panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 20f), GUIManager.Instance.AveriaSerif, 26, Color.white, false, Color.black, 640f, 180f, false);
		val2.GetComponent<Text>().alignment = (TextAnchor)4;
		GameObject val3 = GUIManager.Instance.CreateButton("<color=#FF6666>Abandonar Maestría</color>", _panel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(-180f, 70f), 300f, 60f);
		((UnityEvent)val3.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
		{
			SpecializationSystem.RemoveMastery(_player);
			GUIManager.BlockInput(false);
			Object.Destroy((Object)(object)_panel);
			Object.Destroy((Object)(object)((Component)this).gameObject);
		});
		GameObject val4 = GUIManager.Instance.CreateButton("<color=#88FF88>Cancelar</color>", _panel.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(180f, 70f), 220f, 60f);
		((UnityEvent)val4.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
		{
			GUIManager.BlockInput(false);
			Object.Destroy((Object)(object)_panel);
			Object.Destroy((Object)(object)((Component)this).gameObject);
		});
		GUIManager.BlockInput(true);
		EinjarheimProfessionsPlugin.Log.LogInfo((object)"[Specialization] Popup renegar mostrado.");
	}

	private void OnDestroy()
	{
		_shown = false;
		GUIManager.BlockInput(false);
	}
}
[HarmonyPatch(typeof(Player), "RaiseSkill")]
internal static class Specialization_Patch_RaiseSkill
{
	private static void Postfix(Player __instance, SkillType skill)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)__instance == (Object)null || (Object)(object)__instance != (Object)(object)Player.m_localPlayer)
		{
			return;
		}
		ProfessionType professionType = SkillToProfession(skill);
		if (professionType != ProfessionType.None && !SpecializationSystem.IsMasterOf(__instance, professionType))
		{
			float skillLevel = SpecializationSystem.GetSkillLevel(__instance, professionType);
			if (skillLevel >= 50f)
			{
				SpecializationSystem.ClampSkill(__instance, professionType, 50f);
			}
		}
	}

	internal static ProfessionType SkillToProfession(SkillType skill)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0004: Invalid comparison between Unknown and I4
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Invalid comparison between Unknown and I4
		//IL_001b: 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_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: 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)
		if ((int)skill == 105)
		{
			return ProfessionType.Cooking;
		}
		if ((int)skill == 107)
		{
			return ProfessionType.Construction;
		}
		if ((int)BlacksmithingSystem.BlacksmithingSkillType != 0 && skill == BlacksmithingSystem.BlacksmithingSkillType)
		{
			return ProfessionType.Blacksmithing;
		}
		if ((int)AlchemySystem.SkillType != 0 && skill == AlchemySystem.SkillType)
		{
			return ProfessionType.Alchemy;
		}
		return ProfessionType.None;
	}
}
[HarmonyPatch(typeof(Player), "OnSpawned")]
internal static class Specialization_Patch_OnSpawned
{
	private static void Postfix(Player __instance)
	{
		if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
		{
			SpecializationSystem.OnPlayerSpawned(__instance);
		}
	}
}
internal static class AlchemySystem
{
	public const string SkillIdentifier = "nazhi.alchemist";

	private static SkillType s_skillType = (SkillType)0;

	public const string CD_ALCHEMIST_LV = "nazhi_alchemist_lv";

	public const string CD_ALCHEMIST_NAME = "nazhi_alchemist_name";

	public const string CD_ALCHEMIST_MASTER = "nazhi_alchemist_master";

	public const string ZDO_CRAFTER_NAME = "nazhi_alchemist_crafter_name";

	public const string ZDO_CRAFTER_LEVEL = "nazhi_alchemist_crafter_level";

	private const float XP_PotionConsumed = 1f;

	private const float XP_PotionCrafted = 2f;

	private const float BasePowerBonus = 0.1f;

	private const float PowerPerLevel = 0.003f;

	private const float MaxPowerBonus = 0.4f;

	private const float BaseDurationBonus = 0.2f;

	private const float DurationPerLevel = 0.005f;

	private const float MaxDurationBonus = 0.7f;

	private const float BaseExtraChance = 0.15f;

	private const float ExtraChancePerLevel = 0.0015f;

	private const float MaxExtraChance = 0.3f;

	private const float BaseCooldownReduction = 0.1f;

	private const float CooldownReductionPerLevel = 0.002f;

	private const float MaxCooldownReduction = 0.3f;

	private const float BaseFermentReduction = 0.2f;

	private const float FermentReductionPerLevel = 0.004f;

	private const float MaxFermentReduction = 0.6f;

	private static bool _minLevelApplied = false;

	private static readonly Dictionary<long, int> _pendingConsumeLevel = new Dictionary<long, int>();

	internal static SkillType SkillType => s_skillType;

	internal static void ResetMinLevelFlag()
	{
		_minLevelApplied = false;
	}

	internal static void SetPendingConsumeLevel(long playerID, int level)
	{
		_pendingConsumeLevel[playerID] = level;
	}

	internal static bool TryConsumePendingLevel(long playerID, out int level)
	{
		if (_pendingConsumeLevel.TryGetValue(playerID, out level))
		{
			_pendingConsumeLevel.Remove(playerID);
			return true;
		}
		level = 1;
		return false;
	}

	internal static void RegisterSkill()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: 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_002a: 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_003f: Expected O, but got Unknown
		//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_005e: Unknown result type (might be due to invalid IL or missing references)
		SkillConfig val = new SkillConfig
		{
			Identifier = "nazhi.alchemist",
			Name = "Alquimista",
			Description = "$skill_alchemist_desc",
			Icon = null,
			IncreaseStep = 1f
		};
		s_skillType = SkillManager.Instance.AddSkill(val);
		EinjarheimProfessionsPlugin.Log.LogInfo((object)string.Format("[Alchemy] Skill registrada: {0} ({1})", "nazhi.alchemist", s_skillType));
	}

	internal static void AddExperience(Player player, float amount)
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)player == (Object)null) && (int)s_skillType != 0 && !(amount <= 0f) && !((Object)(object)((Character)player).m_nview == (Object)null) && ((Character)player).m_nview.IsOwner())
		{
			((Character)player).RaiseSkill(s_skillType, amount);
		}
	}

	internal static void OnPotionConsumed(Player player)
	{
		AddExperience(player, 1f);
	}

	internal static void OnPotionCrafted(Player player)
	{
		AddExperience(player, 2f);
	}

	internal static float GetLevel(Player player)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)player == (Object)null)
		{
			return 0f;
		}
		return ((Character)player).GetSkillLevel(s_skillType);
	}

	internal static int GetLevelInt(Player player)
	{
		return Mathf.Max(1, Mathf.FloorToInt(GetLevel(player)));
	}

	internal static void StampItem(ItemData item, Player alchemist)
	{
		if (item != null && !((Object)(object)alchemist == (Object)null))
		{
			if (item.m_customData == null)
			{
				item.m_customData = new Dictionary<string, string>();
			}
			item.m_customData["nazhi_alchemist_lv"] = GetLevelInt(alchemist).ToString();
			item.m_customData["nazhi_alchemist_name"] = alchemist.GetPlayerName();
			if (SpecializationSystem.IsMasterOf(alchemist, ProfessionType.Alchemy))
			{
				item.m_customData["nazhi_alchemist_master"] = "1";
			}
			else
			{
				item.m_customData.Remove("nazhi_alchemist_master");
			}
		}
	}

	internal static void StampItemDirect(ItemData item, string crafterName, int crafterLevel)
	{
		if (item != null)
		{
			if (item.m_customData == null)
			{
				item.m_customData = new Dictionary<string, string>();
			}
			item.m_customData["nazhi_alchemist_lv"] = Mathf.Max(1, crafterLevel).ToString();
			item.m_customData["nazhi_alchemist_name"] = (string.IsNullOrEmpty(crafterName) ? "Desconocido" : crafterName);
		}
	}

	internal static bool IsAlchemistMaster(ItemData item)
	{
		if (item?.m_customData == null)
		{
			return false;
		}
		string value;
		return item.m_customData.TryGetValue("nazhi_alchemist_master", out value) && value == "1";
	}

	internal static int GetStampedLevel(ItemData item)
	{
		if (item?.m_customData == null)
		{
			return 1;
		}
		if (item.m_customData.TryGetValue("nazhi_alchemist_lv", out var value) && int.TryParse(value, out var result))
		{
			return Mathf.Max(1, result);
		}
		return 1;
	}

	internal static string GetStampedName(ItemData item)
	{
		if (item?.m_customData == null)
		{
			return "Desconocido";
		}
		if (item.m_customData.TryGetValue("nazhi_alchemist_name", out var value) && !string.IsNullOrEmpty(value))
		{
			return value;
		}
		return "Desconocido";
	}

	internal static bool HasStamp(ItemData item)
	{
		return item?.m_customData != null && item.m_customData.ContainsKey("nazhi_alchemist_lv");
	}

	internal static float GetPotionPowerMultiplier(int level)
	{
		float num = 0.1f + 0.003f * (float)level;
		return 1f + Mathf.Clamp(num, 0.1f, 0.4f);
	}

	internal static float GetPotionDurationMultiplier(int level)
	{
		float num = 0.2f + 0.005f * (float)level;
		return 1f + Mathf.Clamp(num, 0.2f, 0.7f);
	}

	internal static float GetExtraPotionChance(Player player)
	{
		float num = 0.15f + 0.0015f * GetLevel(player);
		return Mathf.Clamp(num, 0.15f, 0.3f);
	}

	internal static float GetPotionCooldownMultiplier(Player player)
	{
		float num = 0.1f + 0.002f * GetLevel(player);
		return 1f - Mathf.Clamp(num, 0.1f, 0.3f);
	}

	internal static float GetFermentationReduction(Player player)
	{
		float num = 0.2f + 0.004f * GetLevel(player);
		return Mathf.Clamp(num, 0f, 0.6f);
	}

	internal static float GetFermentationTimeMultiplier(Player player)
	{
		return 1f - GetFermentationReduction(player);
	}

	internal static bool RollExtraPotion(Player player)
	{
		return Random.value <= GetExtraPotionChance(player);
	}

	internal static void EnsureMinLevel(Player player)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Invalid comparison between Unknown and I4
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		if (!_minLevelApplied && !((Object)(object)player == (Object)null) && (int)s_skillType != 0)
		{
			if (((Character)player).GetSkillLevel(s_skillType) < 1f)
			{
				((Character)player).RaiseSkill(s_skillType, 0.5f);
				EinjarheimProfessionsPlugin.Log.LogInfo((object)"[Alchemy] Nivel inicial de Alquimia establecido a 1.");
			}
			_minLevelApplied = true;
		}
	}
}
internal static class AlchemyPotionUtils
{
	internal static bool IsPotion(ItemData item)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Invalid comparison between Unknown and I4
		if (item?.m_shared == null)
		{
			return false;
		}
		if ((int)item.m_shared.m_itemType != 2)
		{
			return false;
		}
		return (Object)(object)item.m_shared.m_consumeStatusEffect != (Object)null;
	}

	internal static bool IsMeadBase(ItemData item)
	{
		if (item?.m_shared == null)
		{
			return false;
		}
		string text = item.m_shared.m_name.ToLowerInvariant();
		return text.Contains("item_meadbase") || text.Contains("meadbase") || text.Contains("mead_base") || (text.Contains("ketill") && (text.Contains("mead") || text.Contains("base")));
	}

	internal static bool IsFinalMead(ItemData item)
	{
		if (item?.m_shared == null)
		{
			return false;
		}
		string text = item.m_shared.m_name.ToLowerInvariant();
		return text.Contains("item_mead_") || (text.Contains("mead") && !text.Contains("meadbase"));
	}
}
internal static class AlchemyStatsApplier
{
	internal static void ApplyPowerAndDuration(int alchemistLevel, SE_Stats stats)
	{
		if (!((Object)(object)stats == (Object)null) && alchemistLevel > 0)
		{
			float potionDurationMultiplier = AlchemySystem.GetPotionDurationMultiplier(alchemistLevel);
			float potionPowerMultiplier = AlchemySystem.GetPotionPowerMultiplier(alchemistLevel);
			if (!(stats.m_healthUpFront > 0f) && !(stats.m_staminaUpFront > 0f) && !(stats.m_eitrUpFront > 0f) && !(stats.m_healthOverTime > 0f) && !(stats.m_staminaOverTime > 0f) && !(stats.m_eitrOverTime > 0f) && !(stats.m_healthOverTimeDuration > 0f) && !(stats.m_staminaOverTimeDuration > 0f) && !(stats.m_eitrOverTimeDuration > 0f) && ((StatusEffect)stats).m_ttl > 0f)
			{
				((StatusEffect)stats).m_ttl = ((StatusEffect)stats).m_ttl * potionDurationMultiplier;
			}
			if (stats.m_healthOverTimeDuration > 0f)
			{
				stats.m_healthOverTimeDuration *= potionDurationMultiplier;
			}
			if (stats.m_staminaOverTimeDuration > 0f)
			{
				stats.m_staminaOverTimeDuration *= potionDurationMultiplier;
			}
			if (stats.m_eitrOverTimeDuration > 0f)
			{
				stats.m_eitrOverTimeDuration *= potionDurationMultiplier;
			}
			stats.m_healthUpFront *= potionPowerMultiplier;
			stats.m_staminaUpFront *= potionPowerMultiplier;
			stats.m_eitrUpFront *= potionPowerMultiplier;
			stats.m_healthOverTime *= potionPowerMultiplier;
			stats.m_staminaOverTime *= potionPowerMultiplier;
			stats.m_eitrOverTime *= potionPowerMultiplier;
			stats.m_healthRegenMultiplier *= potionPowerMultiplier;
			stats.m_staminaRegenMultiplier *= potionPowerMultiplier;
			stats.m_eitrRegenMultiplier *= potionPowerMultiplier;
		}
	}
}
[HarmonyPatch(typeof(Player), "Update")]
internal static class Alchemy_Patch_EnsureMinLevel
{
	private static void Postfix(Player __instance)
	{
		if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
		{
			AlchemySystem.EnsureMinLevel(__instance);
		}
	}
}
[HarmonyPatch(typeof(Player), "OnSpawned")]
internal static class Alchemy_Patch_OnSpawned
{
	private static void Postfix(Player __instance)
	{
		if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
		{
			AlchemySystem.ResetMinLevelFlag();
		}
	}
}
[HarmonyPatch(typeof(Player), "ConsumeItem")]
internal static class Alchemy_Patch_ConsumeItem
{
	private static void Prefix(Player __instance, ItemData item)
	{
		try
		{
			if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && AlchemyPotionUtils.IsPotion(item))
			{
				AlchemySystem.OnPotionConsumed(__instance);
				int num = (AlchemySystem.HasStamp(item) ? AlchemySystem.GetStampedLevel(item) : AlchemySystem.GetLevelInt(__instance));
				AlchemySystem.SetPendingConsumeLevel(__instance.GetPlayerID(), num);
				EinjarheimProfessionsPlugin.Log.LogInfo((object)($"[Alchemy] ConsumeItem: usando nivel alquimista={num} " + $"(stamp={AlchemySystem.HasStamp(item)})"));
			}
		}
		catch (Exception arg)
		{
			EinjarheimProfessionsPlugin.Log.LogWarning((object)$"[Alchemy] Error en ConsumeItem: {arg}");
		}
	}
}
[HarmonyPatch(typeof(SE_Stats), "Setup")]
internal static class Alchemy_Patch_SE_Stats_Setup
{
	private static void Prefix(SE_Stats __instance, Character character)
	{
		try
		{
			Player val = (Player)(object)((character is Player) ? character : null);
			if (val != null && !((Object)(object)val != (Object)(object)Player.m_localPlayer) && AlchemySystem.TryConsumePendingLevel(val.GetPlayerID(), out var level))
			{
				AlchemyStatsApplier.ApplyPowerAndDuration(level, __instance);
			}
		}
		catch (Exception arg)
		{
			EinjarheimProfessionsPlugin.Log.LogWarning((object)$"[Alchemy] Error en SE_Stats.Setup: {arg}");
		}
	}
}
[HarmonyPatch(typeof(InventoryGui), "DoCrafting")]
internal static class Alchemy_Patch_DoCrafting_Stamp
{
	internal static readonly Dictionary<long, (string name, int level)> _pendingCrafter = new Dictionary<long, (string, int)>();

	private static void Prefix(InventoryGui __instance, Player player)
	{
		if ((Object)(object)player == (Object)null)
		{
			return;
		}
		Recipe craftRecipe = __instance.m_craftRecipe;
		if (craftRecipe?.m_item?.m_itemData != null)
		{
			ItemData itemData = craftRecipe.m_item.m_itemData;
			if (AlchemyPotionUtils.IsPotion(itemData) || AlchemyPotionUtils.IsFinalMead(itemData) || AlchemyPotionUtils.IsMeadBase(itemData))
			{
				long playerID = player.GetPlayerID();
				_pendingCrafter[playerID] = (player.GetPlayerName(), AlchemySystem.GetLevelInt(player));
				EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Alchemy] DoCrafting: pending stamp para {player.GetPlayerName()} lv={AlchemySystem.GetLevelInt(player)}");
			}
		}
	}
}
[HarmonyPatch]
internal static class Alchemy_Patch_Inventory_AddItem_Stamp
{
	private static IEnumerable<MethodBase> TargetMethods()
	{
		return from m in typeof(Inventory).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
			where m.Name == "AddItem" && m.GetParameters().Length != 0 && m.GetParameters()[0].ParameterType == typeof(ItemData)
			select m;
	}

	private static void Prefix(Inventory __instance, ItemData item)
	{
		try
		{
			if (item == null || (!AlchemyPotionUtils.IsPotion(item) && !AlchemyPotionUtils.IsFinalMead(item) && !AlchemyPotionUtils.IsMeadBase(item)) || AlchemySystem.HasStamp(item))
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || ((Humanoid)localPlayer).GetInventory() != __instance)
			{
				return;
			}
			long playerID = localPlayer.GetPlayerID();
			if (Alchemy_Patch_DoCrafting_Stamp._pendingCrafter.TryGetValue(playerID, out (string, int) value))
			{
				if (item.m_customData == null)
				{
					item.m_customData = new Dictionary<string, string>();
				}
				item.m_customData["nazhi_alchemist_name"] = value.Item1;
				item.m_customData["nazhi_alchemist_lv"] = value.Item2.ToString();
				Alchemy_Patch_DoCrafting_Stamp._pendingCrafter.Remove(playerID);
				EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Alchemy] Stamp aplicado (caldero): {item.m_shared?.m_name} → {value.Item1} lv={value.Item2}");
			}
		}
		catch (Exception arg)
		{
			EinjarheimProfessionsPlugin.Log.LogWarning((object)$"[Alchemy] Error en AddItem Stamp: {arg}");
		}
	}
}
[HarmonyPatch(typeof(Fermenter), "AddItem")]
internal static class Alchemy_Patch_Fermenter_AddItem
{
	private static void Postfix(Fermenter __instance, Humanoid user, ItemData item, bool __result)
	{
		try
		{
			if (!__result || item == null || !AlchemyPotionUtils.IsMeadBase(item))
			{
				return;
			}
			EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Alchemy] Mead base en fermenter: {item.m_shared.m_name} x{item.m_stack}");
			Player val = (Player)(object)((user is Player) ? user : null);
			if (val != null && (Object)(object)val == (Object)(object)Player.m_localPlayer)
			{
				AlchemySystem.OnPotionCrafted(val);
				int num = (AlchemySystem.HasStamp(item) ? AlchemySystem.GetStampedLevel(item) : AlchemySystem.GetLevelInt(val));
				string text = (AlchemySystem.HasStamp(item) ? AlchemySystem.GetStampedName(item) : val.GetPlayerName());
				ZNetView nview = __instance.m_nview;
				if (((nview != null) ? nview.GetZDO() : null) != null)
				{
					__instance.m_nview.GetZDO().Set("nazhi_alchemist_crafter_name", text);
					__instance.m_nview.GetZDO().Set("nazhi_alchemist_crafter_level", num);
					EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Alchemy] Crafter guardado en ZDO: {text} lv={num}");
				}
			}
		}
		catch (Exception arg)
		{
			EinjarheimProfessionsPlugin.Log.LogWarning((object)$"[Alchemy] Error en Fermenter.AddItem: {arg}");
		}
	}
}
[HarmonyPatch(typeof(Fermenter), "RPC_AddItem")]
internal static class Alchemy_Patch_Fermenter_RPC_AddItem
{
	private static void Postfix(Fermenter __instance, long sender, string name)
	{
		try
		{
			if ((Object)(object)__instance?.m_nview == (Object)null || !__instance.m_nview.IsOwner())
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			float fermentationReduction = AlchemySystem.GetFermentationReduction(localPlayer);
			if (!(fermentationReduction <= 0f))
			{
				ZDO zDO = __instance.m_nview.GetZDO();
				long num = zDO.GetLong(ZDOVars.s_startTime, 0L);
				if (num != 0)
				{
					double num2 = __instance.m_fermentationDuration * fermentationReduction;
					long num3 = (long)(num2 * 10000000.0);
					long num4 = Math.Max(0L, num - num3);
					zDO.Set(ZDOVars.s_startTime, num4);
					EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Alchemy] Fermentación acelerada -{fermentationReduction * 100f:0}% (~{num2:0}s) para '{name}'.");
				}
			}
		}
		catch (Exception arg)
		{
			EinjarheimProfessionsPlugin.Log.LogWarning((object)$"[Alchemy] Error en RPC_AddItem: {arg}");
		}
	}
}
[HarmonyPatch(typeof(Fermenter), "DelayedTap")]
internal static class Alchemy_Patch_Fermenter_DelayedTap
{
	private static void Postfix(Fermenter __instance)
	{
		try
		{
			string delayedTapItem = __instance.m_delayedTapItem;
			if (string.IsNullOrEmpty(delayedTapItem))
			{
				return;
			}
			ItemConversion itemConversion = __instance.GetItemConversion(delayedTapItem);
			if ((Object)(object)itemConversion?.m_to == (Object)null)
			{
				return;
			}
			EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Alchemy] Fermenter produjo: {itemConversion.m_to.m_itemData?.m_shared?.m_name} x{itemConversion.m_producedItems}");
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null))
			{
				AlchemySystem.OnPotionCrafted(localPlayer);
				string text = "Desconocido";
				int num = 1;
				ZNetView nview = __instance.m_nview;
				if (((nview != null) ? nview.GetZDO() : null) != null)
				{
					text = __instance.m_nview.GetZDO().GetString("nazhi_alchemist_crafter_name", "Desconocido");
					num = __instance.m_nview.GetZDO().GetInt("nazhi_alchemist_crafter_level", 1);
					EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Alchemy] Crafter leído del ZDO: {text} lv={num}");
				}
				long playerID = localPlayer.GetPlayerID();
				Alchemy_Patch_DoCrafting_Stamp._pendingCrafter[playerID] = (text, num);
			}
		}
		catch (Exception arg)
		{
			EinjarheimProfessionsPlugin.Log.LogWarning((object)$"[Alchemy] Error en DelayedTap: {arg}");
		}
	}
}
[HarmonyPatch]
internal static class Alchemy_Patch_Tooltip
{
	private static IEnumerable<MethodBase> TargetMethods()
	{
		return from m in typeof(ItemData).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
			where m.Name == "GetTooltip" && m.ReturnType == typeof(string)
			select m;
	}

	private static void Postfix(ItemData __instance, ref string __result)
	{
		try
		{
			if (__instance?.m_shared != null)
			{
				bool flag = AlchemyPotionUtils.IsPotion(__instance);
				bool flag2 = AlchemyPotionUtils.IsMeadBase(__instance);
				bool flag3 = AlchemyPotionUtils.IsFinalMead(__instance);
				if ((flag || flag2 || flag3) && !__result.Contains("=== Alquimia ==="))
				{
					int stampedLevel = AlchemySystem.GetStampedLevel(__instance);
					string stampedName = AlchemySystem.GetStampedName(__instance);
					float num = (AlchemySystem.GetPotionDurationMultiplier(stampedLevel) - 1f) * 100f;
					float num2 = (AlchemySystem.GetPotionPowerMultiplier(stampedLevel) - 1f) * 100f;
					Player localPlayer = Player.m_localPlayer;
					float num3 = (((Object)(object)localPlayer != (Object)null) ? (AlchemySystem.GetFermentationReduction(localPlayer) * 100f) : 0f);
					string text = (AlchemySystem.IsAlchemistMaster(__instance) ? "[GranAlquimista] " : "");
					__result = __result + $"\n\n<color=#E9C46A><b>==== Alquimia Level <color=#FFF44F>[{stampedLevel}]</color> ====</b></color>" + "\n<color=#00FFFF>Preparada por: " + text + stampedName + "</color>" + $"\nPotencia de poción: <color=#FF5CDF>+{num2:0}%</color>" + $"\nDuración de poción: <color=#CBA0FF>+{num:0}%</color>" + ((flag2 || flag3) ? $"\nFermentación rápida: <color=#A6FF4D>-{num3:0}%</color>" : "");
				}
			}
		}
		catch (Exception arg)
		{
			EinjarheimProfessionsPlugin.Log.LogWarning((object)$"[Alchemy] Error en Tooltip: {arg}");
		}
	}
}
internal static class BlacksmithingSystem
{
	private const string DurabilityKey = "nazhi_blacksmith_durability";

	private const string LevelKey = "nazhi_blacksmith_lvl";

	private const string CrafterKey = "nazhi_blacksmith_crafter";

	private const string MasterKey = "nazhi_blacksmith_master";

	private const float MaxDurabilityBonusAt100 = 0.6f;

	private const float DamageMaxBonusAt100 = 0.5f;

	private const float ArmorMaxBonusAt100 = 0.5f;

	internal static SkillType BlacksmithingSkillType;

	private static bool _minLevelApplied;

	internal static void ResetMinLevelFlag()
	{
		_minLevelApplied = false;
	}

	internal static void RegisterSkill()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: 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_002a: 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_003f: Expected O, but got Unknown
		//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)
		SkillConfig val = new SkillConfig
		{
			Identifier = "nazhi.blacksmithing.skill",
			Name = "Herreria",
			Description = "Mejora la durabilidad y calidad del equipo forjado en fragua, fragua negra y mesa de trabajo.",
			Icon = null,
			IncreaseStep = 5f
		};
		BlacksmithingSkillType = SkillManager.Instance.AddSkill(val);
	}

	internal static float GetLevel(Player player)
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Invalid comparison between Unknown and I4
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)player == (Object)null || (int)BlacksmithingSkillType == 0)
		{
			return 0f;
		}
		return Mathf.Clamp(((Character)player).GetSkillLevel(BlacksmithingSkillType), 0f, 100f);
	}

	internal static float GetDurabilityFactor(float level)
	{
		if (level <= 0f)
		{
			return 1f;
		}
		return 1f + 0.6f * Mathf.Clamp01(level / 100f);
	}

	internal static float GetDamageFactor(int level)
	{
		if (level <= 0)
		{
			return 1f;
		}
		return 1f + 0.5f * Mathf.Clamp01((float)level / 100f);
	}

	internal static float GetDamagePercent(int level)
	{
		return (GetDamageFactor(level) - 1f) * 100f;
	}

	internal static float GetArmorFactor(int level)
	{
		if (level <= 0)
		{
			return 1f;
		}
		return 1f + 0.5f * Mathf.Clamp01((float)level / 100f);
	}

	internal static float GetArmorPercent(int level)
	{
		return (GetArmorFactor(level) - 1f) * 100f;
	}

	internal static void OnItemForged(Player player, ItemData item)
	{
		//IL_018d: 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)
		if ((Object)(object)player == (Object)null || item == null || item.m_shared == null)
		{
			return;
		}
		string text = (((Object)(object)item.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : "");
		string text2 = item.m_shared.m_name ?? "";
		if (text.IndexOf("arrow", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("flecha", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("seed", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("semilla", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("twig", StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf("arrow", StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf("flecha", StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf("seeds", StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf("semillas", StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf("twig", StringComparison.OrdinalIgnoreCase) >= 0 || text == "Cultivator")
		{
			return;
		}
		int num = Mathf.RoundToInt(GetLevel(player));
		if ((text.IndexOf("Club", StringComparison.OrdinalIgnoreCase) >= 0 && num >= 50) || (text.IndexOf("Torch", StringComparison.OrdinalIgnoreCase) >= 0 && num >= 55) || (text.IndexOf("Hammer", StringComparison.OrdinalIgnoreCase) >= 0 && num >= 60) || (text.IndexOf("Hoe", StringComparison.OrdinalIgnoreCase) >= 0 && num >= 65))
		{
			return;
		}
		if (HasSignature(item))
		{
			((Character)player).RaiseSkill(BlacksmithingSkillType, 1f);
			return;
		}
		float level = GetLevel(player);
		float durabilityFactor = GetDurabilityFactor(level);
		int num2 = Mathf.RoundToInt(level);
		string playerName = player.GetPlayerName();
		if (item.m_customData == null)
		{
			item.m_customData = new Dictionary<string, string>();
		}
		item.m_customData["nazhi_blacksmith_durability"] = durabilityFactor.ToString(CultureInfo.InvariantCulture);
		item.m_customData["nazhi_blacksmith_lvl"] = num2.ToString(CultureInfo.InvariantCulture);
		item.m_customData["nazhi_blacksmith_crafter"] = playerName;
		if (SpecializationSystem.IsMasterOf(player, ProfessionType.Blacksmithing) && GetLevel(player) >= 50f)
		{
			item.m_customData["nazhi_blacksmith_master"] = "1";
		}
		else
		{
			item.m_customData.Remove("nazhi_blacksmith_master");
		}
		((Character)player).RaiseSkill(BlacksmithingSkillType, 1f);
	}

	internal static float GetSavedDurabilityFactor(ItemData item)
	{
		if (item?.m_customData == null)
		{
			return 1f;
		}
		if (!item.m_customData.TryGetValue("nazhi_blacksmith_durability", out var value))
		{
			return 1f;
		}
		if (!float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
		{
			return 1f;
		}
		return (result > 1f) ? result : 1f;
	}

	internal static int GetSavedLevel(ItemData item)
	{
		if (item?.m_customData == null)
		{
			return 0;
		}
		if (!item.m_customData.TryGetValue("nazhi_blacksmith_lvl", out var value))
		{
			return 0;
		}
		int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result);
		return result;
	}

	internal static string GetSavedCrafter(ItemData item)
	{
		if (item?.m_customData == null)
		{
			return null;
		}
		item.m_customData.TryGetValue("nazhi_blacksmith_crafter", out var value);
		return value;
	}

	internal static bool IsMasterForged(ItemData item)
	{
		if (item?.m_customData == null)
		{
			return false;
		}
		string value;
		return item.m_customData.TryGetValue("nazhi_blacksmith_master", out value) && value == "1";
	}

	internal static bool HasSignature(ItemData item)
	{
		if (item?.m_customData == null)
		{
			return false;
		}
		return item.m_customData.ContainsKey("nazhi_blacksmith_durability") || item.m_customData.ContainsKey("nazhi_blacksmith_lvl") || item.m_customData.ContainsKey("nazhi_blacksmith_crafter");
	}

	internal static bool IsExcludedUtility(ItemData item)
	{
		if (item == null)
		{
			return false;
		}
		string text = (((Object)(object)item.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : (item.m_shared?.m_name ?? ""));
		return text == "Cultivator";
	}

	internal static void EnsureMinLevel(Player player)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Invalid comparison between Unknown and I4
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		if (!_minLevelApplied && !((Object)(object)player == (Object)null) && (int)BlacksmithingSkillType != 0)
		{
			float skillLevel = ((Character)player).GetSkillLevel(BlacksmithingSkillType);
			if (skillLevel < 1f)
			{
				((Character)player).RaiseSkill(BlacksmithingSkillType, 0.5f);
			}
			_minLevelApplied = true;
		}
	}
}
internal static class BlacksmithingCraftContext
{
	[ThreadStatic]
	private static bool _active;

	[ThreadStatic]
	private static CraftingStation _station;

	[ThreadStatic]
	private static Player _crafter;

	internal static bool Active
	{
		get
		{
			return _active;
		}
		set
		{
			_active = value;
		}
	}

	internal static CraftingStation Station
	{
		get
		{
			return _station;
		}
		set
		{
			_station = value;
		}
	}

	internal static Player Crafter
	{
		get
		{
			return _crafter;
		}
		set
		{
			_crafter = value;
		}
	}

	internal static bool IsForgeStation(CraftingStation station)
	{
		if ((Object)(object)station == (Object)null)
		{
			return false;
		}
		return station.m_name == "$piece_forge" || station.m_name == "$piece_blackforge" || station.m_name == "$piece_workbench";
	}

	internal static void Begin(Player player)
	{
		Active = true;
		Crafter = player;
		Station = ((player != null) ? player.GetCurrentCraftingStation() : null);
	}

	internal static void End()
	{
		Active = false;
		Station = null;
		Crafter = null;
	}
}
[HarmonyPatch(typeof(Player), "Update")]
internal static class Blacksmithing_Patch_EnsureMinLevel
{
	private static void Postfix(Player __instance)
	{
		if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
		{
			BlacksmithingSystem.EnsureMinLevel(__instance);
		}
	}
}
[HarmonyPatch(typeof(Player), "OnSpawned")]
internal static class Blacksmithing_Patch_OnSpawned
{
	private static void Postfix(Player __instance)
	{
		if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
		{
			BlacksmithingSystem.ResetMinLevelFlag();
		}
	}
}
[HarmonyPatch(typeof(InventoryGui), "DoCrafting")]
internal static class Blacksmithing_Patch_DoCrafting
{
	private static void Prefix(Player player)
	{
		BlacksmithingCraftContext.Begin(player);
	}

	private static void Finalizer()
	{
		BlacksmithingCraftContext.End();
	}
}
[HarmonyPatch(typeof(Inventory), "AddItem", new Type[]
{
	typeof(string),
	typeof(int),
	typeof(int),
	typeof(int),
	typeof(long),
	typeof(string),
	typeof(Vector2i),
	typeof(bool)
})]
internal static class Blacksmithing_Patch_AddItem
{
	private static void Postfix(ref ItemData __result)
	{
		if (BlacksmithingCraftContext.Active && __result != null)
		{
			CraftingStation station = BlacksmithingCraftContext.Station;
			Player crafter = BlacksmithingCraftContext.Crafter;
			bool flag = BlacksmithingCraftContext.IsForgeStation(station);
			if ((!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) && !((Object)(object)crafter == (Object)null) && flag)
			{
				BlacksmithingSystem.OnItemForged(crafter, __result);
			}
		}
	}
}
[HarmonyPatch(typeof(ItemData), "GetMaxDurability", new Type[] { })]
internal static class Blacksmithing_Patch_MaxDurability
{
	private static void Postfix(ItemData __instance, ref float __result)
	{
		if (__instance != null)
		{
			float savedDurabilityFactor = BlacksmithingSystem.GetSavedDurabilityFactor(__instance);
			if (savedDurabilityFactor > 1f)
			{
				__result *= savedDurabilityFactor;
			}
		}
	}
}
[HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[]
{
	typeof(ItemData),
	typeof(int),
	typeof(bool),
	typeof(float),
	typeof(int)
})]
internal static class Blacksmithing_Patch_Tooltip
{
	private static void Postfix([HarmonyArgument(0)] ItemData item, ref string __result)
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Invalid comparison between Unknown and I4
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Invalid comparison between Unknown and I4
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Invalid comparison between Unknown and I4
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Invalid comparison between Unknown and I4
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Invalid comparison between Unknown and I4
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Invalid comparison between Unknown and I4
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Invalid comparison between Unknown and I4
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Invalid comparison between Unknown and I4
		if (item != null && BlacksmithingSystem.HasSignature(item))
		{
			float savedDurabilityFactor = BlacksmithingSystem.GetSavedDurabilityFactor(item);
			int savedLevel = BlacksmithingSystem.GetSavedLevel(item);
			string text = BlacksmithingSystem.GetSavedCrafter(item) ?? item.m_crafterName;
			SharedData shared = item.m_shared;
			ItemType val = (ItemType)((shared != null) ? ((int)shared.m_itemType) : 0);
			bool flag = (int)val == 3 || (int)val == 14 || (int)val == 4 || (int)val == 19;
			bool flag2 = (int)val == 6 || (int)val == 7 || (int)val == 11 || (int)val == 17;
			if (flag && BlacksmithingSystem.IsExcludedUtility(item))
			{
				flag = false;
			}
			float damagePercent = BlacksmithingSystem.GetDamagePercent(savedLevel);
			float armorPercent = BlacksmithingSystem.GetArmorPercent(savedLevel);
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine();
			stringBuilder.AppendLine();
			if (savedDurabilityFactor > 1f)
			{
				stringBuilder.AppendLine($"<color=#00ff00>Durabilidad extra +{(savedDurabilityFactor - 1f) * 100f:0.#}%</color>");
			}
			if (flag && damagePercent > 0.01f)
			{
				stringBuilder.AppendLine($"<color=#ffcc00>Daño aumentado +{damagePercent:0.#}%</color>");
			}
			else if (flag2 && armorPercent > 0.01f)
			{
				stringBuilder.AppendLine($"<color=#ffcc00>Armadura aumentada +{armorPercent:0.#}%</color>");
			}
			string text2 = ((!string.IsNullOrEmpty(text)) ? text : "Desconocido");
			string text3 = ((savedLevel > 0) ? savedLevel.ToString() : "?");
			string text4 = (BlacksmithingSystem.IsMasterForged(item) ? "Maestro Herrero" : "Herrero");
			stringBuilder.AppendLine("<color=#cccccc>Forjado por: " + text2 + " · " + text4 + " nivel " + text3 + "</color>");
			__result += stringBuilder.ToString();
		}
	}
}
[HarmonyPatch(typeof(ItemData), "GetDamage", new Type[]
{
	typeof(int),
	typeof(float)
})]
internal static class Blacksmithing_Patch_Damage
{
	private static void Postfix(ItemData __instance, ref DamageTypes __result)
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Invalid comparison between Unknown and I4
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Invalid comparison between Unknown and I4
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Invalid comparison between Unknown and I4
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Invalid comparison between Unknown and I4
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Invalid comparison between Unknown and I4
		if (__instance == null || !BlacksmithingSystem.HasSignature(__instance))
		{
			return;
		}
		SharedData shared = __instance.m_shared;
		ItemType val = (ItemType)((shared != null) ? ((int)shared.m_itemType) : 0);
		if (((int)val == 3 || (int)val == 14 || (int)val == 4 || (int)val == 19 || (int)val == 5) && !BlacksmithingSystem.IsExcludedUtility(__instance))
		{
			int savedLevel = BlacksmithingSystem.GetSavedLevel(__instance);
			float damageFactor = BlacksmithingSystem.GetDamageFactor(savedLevel);
			if (!(damageFactor <= 1f))
			{
				__result.m_blunt *= damageFactor;
				__result.m_slash *= damageFactor;
				__result.m_pierce *= damageFactor;
				__result.m_chop *= damageFactor;
				__result.m_pickaxe *= damageFactor;
				__result.m_fire *= damageFactor;
				__result.m_frost *= damageFactor;
				__result.m_lightning *= damageFactor;
				__result.m_poison *= damageFactor;
				__result.m_spirit *= damageFactor;
			}
		}
	}
}
[HarmonyPatch(typeof(ItemData), "GetArmor", new Type[]
{
	typeof(int),
	typeof(float)
})]
internal static class Blacksmithing_Patch_Armor
{
	private static void Postfix(ItemData __instance, ref float __result)
	{
		//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_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Invalid comparison between Unknown and I4
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Invalid comparison between Unknown and I4
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Invalid comparison between Unknown and I4
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Invalid comparison between Unknown and I4
		if (__instance == null || !BlacksmithingSystem.HasSignature(__instance))
		{
			return;
		}
		SharedData shared = __instance.m_shared;
		ItemType val = (ItemType)((shared != null) ? ((int)shared.m_itemType) : 0);
		if ((int)val == 6 || (int)val == 7 || (int)val == 11 || (int)val == 17)
		{
			int savedLevel = BlacksmithingSystem.GetSavedLevel(__instance);
			float armorFactor = BlacksmithingSystem.GetArmorFactor(savedLevel);
			if (!(armorFactor <= 1f))
			{
				__result *= armorFactor;
			}
		}
	}
}
[HarmonyPatch(typeof(InventoryGui), "RepairOneItem")]
internal static class Blacksmithing_Patch_Repair
{
	[ThreadStatic]
	private static float _missingPct;

	private static void Prefix(InventoryGui __instance)
	{
		_missingPct = 0f;
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		CraftingStation currentCraftingStation = Player.m_localPlayer.GetCurrentCraftingStation();
		if (!BlacksmithingCraftContext.IsForgeStation(currentCraftingStation))
		{
			return;
		}
		List<ItemData> list = new List<ItemData>();
		((Humanoid)Player.m_localPlayer).GetInventory().GetWornItems(list);
		foreach (ItemData item in list)
		{
			if (__instance.CanRepair(item))
			{
				float maxDurability = item.GetMaxDurability();
				if (maxDurability > 0f)
				{
					_missingPct = Mathf.Clamp01(1f - item.m_durability / maxDurability);
				}
				break;
			}
		}
	}

	private static void Postfix()
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		if (!(_missingPct <= 0.05f))
		{
			Player localPlayer = Player.m_localPlayer;
			if (BlacksmithingCraftContext.IsForgeStation((localPlayer != null) ? localPlayer.GetCurrentCraftingStation() : null))
			{
				((Character)Player.m_localPlayer).RaiseSkill(BlacksmithingSystem.BlacksmithingSkillType, _missingPct * 0.5f);
			}
		}
	}
}
internal static class ConstructionSystem
{
	internal const string ZdoKeyMaxHealth = "nazhi_construction_maxhp";

	internal const string ZdoKeyPaidPrefix = "nazhi_paid_";

	internal const string RpcSetBuilderMult = "nazhi_construction_SetBuilderHP";

	internal const string RpcSetBuilderTier = "nazhi_construction_SetBuilderTier";

	private static readonly Dictionary<long, float> _pendingMult = new Dictionary<long, float>();

	private static readonly Dictionary<long, int> _pendingTier = new Dictionary<long, int>();

	internal static readonly Dictionary<string, int> PendingPaid = new Dictionary<string, int>();

	private static HashSet<Container> _acbContainers = null;

	internal static void RegisterRpc()
	{
		ZRoutedRpc.instance.Register<float>("nazhi_construction_SetBuilderHP", (Action<long, float>)OnRpcSetBuilderMult);
		ZRoutedRpc.instance.Register<float>("nazhi_construction_SetBuilderTier", (Action<long, float>)OnRpcSetBuilderTier);
	}

	private static void OnRpcSetBuilderMult(long senderPeerID, float hpMult)
	{
		ZNet instance = ZNet.instance;
		ZNetPeer val = ((instance != null) ? instance.GetPeer(senderPeerID) : null);
		if (val != null)
		{
			long userID = ((ZDOID)(ref val.m_characterID)).UserID;
			_pendingMult[userID] = hpMult;
			EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Construction] RPC HP uid={userID} hpMult={hpMult:0.000}");
		}
	}

	private static void OnRpcSetBuilderTier(long senderPeerID, float tierFloat)
	{
		ZNet instance = ZNet.instance;
		ZNetPeer val = ((instance != null) ? instance.GetPeer(senderPeerID) : null);
		if (val != null)
		{
			long userID = ((ZDOID)(ref val.m_characterID)).UserID;
			_pendingTier[userID] = (int)tierFloat;
			EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Construction] RPC Tier uid={userID} tier={(int)tierFloat}");
		}
	}

	internal static bool TryConsumePendingMult(long uid, out float hpMult)
	{
		if (_pendingMult.TryGetValue(uid, out hpMult))
		{
			_pendingMult.Remove(uid);
			return true;
		}
		hpMult = 1f;
		return false;
	}

	internal static bool TryConsumePendingTier(long uid, out int tier)
	{
		if (_pendingTier.TryGetValue(uid, out tier))
		{
			_pendingTier.Remove(uid);
			return true;
		}
		tier = 0;
		return false;
	}

	internal static float GetCraftingLevel(Player player)
	{
		if ((Object)(object)player == (Object)null)
		{
			return 0f;
		}
		return ((Character)player).GetSkillLevel((SkillType)107);
	}

	internal static float GetHealthMultiplier(Player player)
	{
		return 1f + GetCraftingLevel(player) * 0.01f;
	}

	private static HashSet<Container> GetAcbContainers()
	{
		if (_acbContainers != null)
		{
			return _acbContainers;
		}
		try
		{
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				if (!assembly.GetName().Name.Contains("AzuCraftyBoxes"))
				{
					continue;
				}
				Type type = assembly.GetType("AzuCraftyBoxes.Util.Functions.Boxes");
				if (!(type == null))
				{
					FieldInfo field = type.GetField("Containers", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
					if (!(field == null))
					{
						_acbContainers = field.GetValue(null) as HashSet<Container>;
						EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Construction] ACB Boxes.Containers: {_acbContainers?.Count ?? (-1)} contenedores");
						break;
					}
				}
			}
		}
		catch (Exception ex)
		{
			EinjarheimProfessionsPlugin.Log.LogWarning((object)("[Construction] No se pudo obtener Boxes.Containers: " + ex.Message));
		}
		return _acbContainers;
	}

	internal static List<Container> GetNearbyContainers(Player player, float radius = 10f)
	{
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		List<Container> list = new List<Container>();
		if ((Object)(object)player == (Object)null)
		{
			return list;
		}
		HashSet<Container> acbContainers = GetAcbContainers();
		if (acbContainers != null && acbContainers.Count > 0)
		{
			foreach (Container item in acbContainers)
			{
				if (!((Object)(object)item == (Object)null) && item.GetInventory() != null && !((Object)(object)item.m_nview == (Object)null) && item.m_nview.IsValid() && Vector3.Distance(((Component)item).transform.position, ((Component)player).transform.position) <= radius)
				{
					list.Add(item);
				}
			}
			return list;
		}
		int num = ((Piece.s_pieceRayMask != 0) ? Piece.s_pieceRayMask : LayerMask.GetMask(new string[2] { "piece", "piece_nonsolid" }));
		Collider[] array = Physics.OverlapSphere(((Component)player).transform.position, radius, num);
		Collider[] array2 = array;
		foreach (Collider val in array2)
		{
			if (!((Object)(object)val == (Object)null))
			{
				Container componentInParent = ((Component)val).GetComponentInParent<Container>();
				if (!((Object)(object)componentInParent == (Object)null) && !list.Contains(componentInParent) && componentInParent.GetInventory() != null && !((Object)(object)componentInParent.m_nview == (Object)null) && componentInParent.m_nview.IsValid())
				{
					list.Add(componentInParent);
				}
			}
		}
		return list;
	}

	internal static int CountItemsTotal(Player player, string matName, List<Container> containers)
	{
		int num = ((Humanoid)player).m_inventory.CountItems(matName, -1, true);
		foreach (Container container in containers)
		{
			num += container.GetInventory().CountItems(matName, -1, true);
		}
		return num;
	}

	internal static bool ConsumeFromInventoryAndContainers(Player player, string matName, int amount, int itemQuality, List<Container> containers)
	{
		int num = amount;
		int num2 = ((Humanoid)player).m_inventory.CountItems(matName, -1, true);
		if (num2 > 0)
		{
			int num3 = Mathf.Min(num2, num);
			((Humanoid)player).m_inventory.RemoveItem(matName, num3, itemQuality, true);
			num -= num3;
			EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Construction] Consume inv '{matName}' -{num3} quedan={num}");
		}
		foreach (Container container in containers)
		{
			if (num <= 0)
			{
				break;
			}
			int num4 = container.GetInventory().CountItems(matName, -1, true);
			if (num4 > 0)
			{
				int num5 = Mathf.Min(num4, num);
				container.GetInventory().RemoveItem(matName, num5, itemQuality, true);
				num -= num5;
				EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Construction] Consume container '{((Object)container).name}' '{matName}' -{num5} quedan={num}");
			}
		}
		return num <= 0;
	}

	private static string ZdoPaidKey(string itemName)
	{
		return "nazhi_paid_" + Math.Abs(itemName.GetHashCode()) % 100000;
	}

	internal static void SavePaidToZDO(ZDO zdo, string itemName, int amount)
	{
		if (zdo != null)
		{
			zdo.Set(ZdoPaidKey(itemName), amount);
		}
	}

	internal static int GetPaidFromZDO(ZDO zdo, string itemName)
	{
		if (zdo == null)
		{
			return -1;
		}
		return zdo.GetInt(ZdoPaidKey(itemName), -1);
	}

	internal static bool HasPaidData(ZDO zdo, Piece piece)
	{
		if (zdo == null || (Object)(object)piece == (Object)null)
		{
			return false;
		}
		Requirement[] resources = piece.m_resources;
		foreach (Requirement val in resources)
		{
			if (!((Object)(object)val?.m_resItem == (Object)null) && val.m_amount > 0 && GetPaidFromZDO(zdo, val.m_resItem.m_itemData.m_shared.m_name) >= 0)
			{
				return true;
			}
		}
		return false;
	}

	internal static void SpawnRefundDrops(Piece piece, ZDO zdo, Vector3 position)
	{
		//IL_00b0: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		Requirement[] resources = piece.m_resources;
		foreach (Requirement val in resources)
		{
			if ((Object)(object)val?.m_resItem == (Object)null || val.m_amount <= 0)
			{
				continue;
			}
			string name = val.m_resItem.m_itemData.m_shared.m_name;
			int num = GetPaidFromZDO(zdo, name);
			if (num < 0)
			{
				num = val.m_amount;
			}
			int num2 = Mathf.Max(1, Mathf.RoundToInt((float)num * 0.5f));
			for (int j = 0; j < num2; j++)
			{
				GameObject gameObject = ((Component)val.m_resItem).gameObject;
				if (!((Object)(object)gameObject == (Object)null))
				{
					GameObject val2 = Object.Instantiate<GameObject>(gameObject, position + Random.insideUnitSphere * 0.3f, Quaternion.identity);
					Rigidbody component = val2.GetComponent<Rigidbody>();
					if (component != null)
					{
						component.AddForce(Vector3.up * 2f + Random.insideUnitSphere, (ForceMode)2);
					}
				}
			}
			EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Construction] Refund '{name}' pagado={num} devuelto={num2}");
		}
	}
}
internal static class ConstructionPlaceContext
{
	private static bool _active;

	internal static bool IsActive => _active;

	internal static void Begin()
	{
		_active = true;
	}

	internal static void End()
	{
		_active = false;
	}
}
[HarmonyPatch(typeof(ZNet), "Awake")]
internal static class Construction_Patch_RegisterRpc
{
	private static void Postfix()
	{
		ConstructionSystem.RegisterRpc();
	}
}
[HarmonyPatch(typeof(Player), "SetPlaceMode", new Type[] { typeof(PieceTable) })]
internal static class Construction_Patch_SetPlaceMode
{
	private static void Postfix(Player __instance)
	{
		if (!((Object)(object)__instance == (Object)null))
		{
			float craftingLevel = ConstructionSystem.GetCraftingLevel(__instance);
			float healthMultiplier = ConstructionSystem.GetHealthMultiplier(__instance);
			EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Construction] Modo construcción Crafting={craftingLevel:0} HPmult={healthMultiplier:0.000}");
		}
	}
}
[HarmonyPatch(typeof(Player), "SetSelectedPiece", new Type[] { typeof(Vector2Int) })]
internal static class Construction_Patch_SetSelectedPiece
{
	private static void Postfix(Player __instance)
	{
		if (!((Object)(object)__instance == (Object)null))
		{
			Piece selectedPiece = __instance.GetSelectedPiece();
			if (!((Object)(object)selectedPiece == (Object)null))
			{
				WearNTear component = ((Component)selectedPiece).GetComponent<WearNTear>();
				float num = (((Object)(object)component != (Object)null) ? component.m_health : (-1f));
				float healthMultiplier = ConstructionSystem.GetHealthMultiplier(__instance);
				float craftingLevel = ConstructionSystem.GetCraftingLevel(__instance);
				EinjarheimProfessionsPlugin.Log.LogInfo((object)("[Construction] Pieza=" + ((Object)selectedPiece).name + " BaseHP=" + ((num >= 0f) ? num.ToString("0.0") : "N/A") + " " + string.Format("BuffedHP={0} Crafting={1:0}", (num >= 0f) ? (num * healthMultiplier).ToString("0.0") : "N/A", craftingLevel)));
			}
		}
	}
}
[HarmonyPatch(typeof(Player), "PlacePiece", new Type[]
{
	typeof(Piece),
	typeof(Vector3),
	typeof(Quaternion),
	typeof(bool)
})]
internal static class Construction_Patch_PlacePiece
{
	private static void Prefix(Player __instance, Piece piece)
	{
		if ((Object)(object)__instance == (Object)null || (Object)(object)piece == (Object)null)
		{
			return;
		}
		ConstructionPlaceContext.Begin();
		__instance.m_customData["ACB_PreventPulling"] = "0";
		float healthMultiplier = ConstructionSystem.GetHealthMultiplier(__instance);
		int num = (int)(ConstructionSystem.GetCraftingLevel(__instance) / 10f);
		if (ZRoutedRpc.instance != null)
		{
			long serverPeerID = ZRoutedRpc.instance.GetServerPeerID();
			if (healthMultiplier > 1f)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(serverPeerID, "nazhi_construction_SetBuilderHP", new object[1] { healthMultiplier });
			}
			if (num > 0)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(serverPeerID, "nazhi_construction_SetBuilderTier", new object[1] { (float)num });
			}
		}
	}

	private static void Postfix(Player __instance, Piece piece)
	{
		if (!((Object)(object)__instance == (Object)null) && !((Object)(object)piece == (Object)null))
		{
			ConstructionPlaceContext.End();
			__instance.m_customData["ACB_PreventPulling"] = "1";
			if (ConstructionSystem.PendingPaid.Count > 0)
			{
				Dictionary<string, int> paid = new Dictionary<string, int>(ConstructionSystem.PendingPaid);
				string pieceName = ((Object)piece).name.Replace("(Clone)", "").Trim();
				ConstructionSystem.PendingPaid.Clear();
				((MonoBehaviour)EinjarheimProfessionsPlugin.Instance).StartCoroutine(DelayedFlush(__instance, pieceName, paid));
			}
			EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Construction] PlacePiece '{((Object)piece).name}' lvl={ConstructionSystem.GetCraftingLevel(__instance):0}");
		}
	}

	private static IEnumerator DelayedFlush(Player player, string pieceName, Dictionary<string, int> paid)
	{
		yield return null;
		List<Piece> nearby = new List<Piece>();
		Piece.GetAllPiecesInRadius(((Component)player).transform.position, 8f, nearby);
		float bestDist = 8f;
		ZDO bestZdo = null;
		foreach (Piece p in nearby)
		{
			if ((Object)(object)p == (Object)null || ((Object)p).name.Replace("(Clone)", "").Trim() != pieceName)
			{
				continue;
			}
			WearNTear wt = ((Component)p).GetComponent<WearNTear>();
			if (!((Object)(object)wt == (Object)null) && !((Object)(object)wt.m_nview == (Object)null) && wt.m_nview.IsValid())
			{
				float dist = Vector3.Distance(((Component)p).transform.position, ((Component)player).transform.position);
				if (dist < bestDist)
				{
					bestDist = dist;
					bestZdo = wt.m_nview.GetZDO();
				}
			}
		}
		if (bestZdo == null)
		{
			EinjarheimProfessionsPlugin.Log.LogWarning((object)("[Construction] DelayedFlush: no ZDO para '" + pieceName + "'"));
			yield break;
		}
		foreach (KeyValuePair<string, int> kvp in paid)
		{
			ConstructionSystem.SavePaidToZDO(bestZdo, kvp.Key, kvp.Value);
		}
		EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Construction] DelayedFlush OK: {paid.Count} costes ZDO uid={bestZdo.m_uid}");
	}
}
[HarmonyPatch(typeof(Piece), "SetCreator", new Type[] { typeof(long) })]
internal static class Construction_Patch_SetCreator
{
	private static void Postfix(Piece __instance, long uid)
	{
		try
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
			{
				return;
			}
			WearNTear component = ((Component)__instance).GetComponent<WearNTear>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.m_nview == (Object)null || !component.m_nview.IsValid())
			{
				return;
			}
			ZDO zDO = component.m_nview.GetZDO();
			if (zDO == null || zDO.GetFloat("nazhi_construction_maxhp", 0f) > 0f)
			{
				return;
			}
			float hpMult = 1f;
			if (!ConstructionSystem.TryConsumePendingMult(uid, out hpMult))
			{
				Player player = Player.GetPlayer(uid);
				if ((Object)(object)player != (Object)null)
				{
					hpMult = ConstructionSystem.GetHealthMultiplier(player);
				}
			}
			if (!(hpMult <= 1f))
			{
				float health = component.m_health;
				if (!(health <= 0f))
				{
					float num = (component.m_health = health * hpMult);
					zDO.Set("nazhi_construction_maxhp", num);
					EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Construction] SetCreator HP '{((Object)__instance).name}' {health:0}→{num:0} x{hpMult:0.000}");
				}
			}
		}
		catch (Exception arg)
		{
			EinjarheimProfessionsPlugin.Log.LogError((object)$"[Construction] Error SetCreator: {arg}");
		}
	}
}
[HarmonyPatch(typeof(WearNTear), "Awake")]
internal static class Construction_Patch_WearNTear_Awake
{
	private static void Postfix(WearNTear __instance)
	{
		try
		{
			if ((Object)(object)__instance.m_nview == (Object)null || !__instance.m_nview.IsValid())
			{
				return;
			}
			ZDO zDO = __instance.m_nview.GetZDO();
			if (zDO != null)
			{
				float num = zDO.GetFloat("nazhi_construction_maxhp", 0f);
				if (!(num <= 0f))
				{
					float health = __instance.m_health;
					__instance.m_health = num;
					EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Construction] WearNTear.Awake restore '{((Object)__instance).name}' {health:0}→{num:0}");
				}
			}
		}
		catch (Exception arg)
		{
			EinjarheimProfessionsPlugin.Log.LogError((object)$"[Construction] Error WearNTear.Awake: {arg}");
		}
	}
}
[HarmonyPatch(typeof(Player), "HaveRequirements", new Type[]
{
	typeof(Piece),
	typeof(RequirementMode)
})]
internal static class Construction_Patch_HaveRequirements
{
	private static bool Prefix(Player __instance, Piece piece, RequirementMode mode, ref bool __result)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Invalid comparison between Unknown and I4
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)__instance == (Object)null || (Object)(object)piece == (Object)null)
		{
			return true;
		}
		if ((int)mode > 0)
		{
			return true;
		}
		if (Object.op_Implicit((Object)(object)piece.m_craftingStation) && !Object.op_Implicit((Object)(object)CraftingStation.HaveBuildStationInRange(piece.m_craftingStation.m_name, ((Component)__instance).transform.position)) && !ZoneSystem.instance.GetGlobalKey((GlobalKeys)22))
		{
			__result = false;
			return false;
		}
		if (piece.m_dlc.Length > 0 && !DLCMan.instance.IsDLCInstalled(piece.m_dlc))
		{
			__result = false;
			return false;
		}
		if (ZoneSystem.instance.GetGlobalKey(piece.FreeBuildKey()))
		{
			__result = true;
			return false;
		}
		List<Container> nearbyContainers = ConstructionSystem.GetNearbyContainers(__instance);
		Requirement[] resources = piece.m_resources;
		foreach (Requirement val in resources)
		{
			if (Object.op_Implicit((Object)(object)val.m_resItem) && val.m_amount > 0)
			{
				string name = val.m_resItem.m_itemData.m_shared.m_name;
				int num = ConstructionSystem.CountItemsTotal(__instance, name, nearbyContainers);
				if (num < val.m_amount)
				{
					__result = false;
					return false;
				}
			}
		}
		__result = true;
		return false;
	}
}
[HarmonyPatch(typeof(Player), "ConsumeResources", new Type[]
{
	typeof(Requirement[]),
	typeof(int),
	typeof(int),
	typeof(int)
})]
[HarmonyPriority(800)]
[HarmonyBefore(new string[] { "Azumatt.AzuCraftyBoxes" })]
internal static class Construction_Patch_ConsumeResources
{
	private static bool Prefix(Player __instance, Requirement[] requirements, int qualityLevel, int itemQuality, int multiplier)
	{
		if (!ConstructionPlaceContext.IsActive)
		{
			return true;
		}
		if ((Object)(object)__instance == (Object)null || requirements == null)
		{
			return false;
		}
		List<Container> nearbyContainers = ConstructionSystem.GetNearbyContainers(__instance);
		EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Construction] ConsumeResources containers={nearbyContainers.Count}");
		ConstructionSystem.PendingPaid.Clear();
		foreach (Requirement val in requirements)
		{
			if (Object.op_Implicit((Object)(object)val?.m_resItem))
			{
				int num = val.m_amount * multiplier;
				if (num > 0)
				{
					string name = val.m_resItem.m_itemData.m_shared.m_name;
					ConstructionSystem.ConsumeFromInventoryAndContainers(__instance, name, num, itemQuality, nearbyContainers);
					ConstructionSystem.PendingPaid[name] = num;
				}
			}
		}
		return false;
	}
}
[HarmonyPatch(typeof(Piece), "DropResources")]
internal static class Construction_Patch_DropResources
{
	private static bool Prefix(Piece __instance)
	{
		//IL_0083: 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_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			WearNTear component = ((Component)__instance).GetComponent<WearNTear>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.m_nview == (Object)null || !component.m_nview.IsValid())
			{
				return true;
			}
			ZDO zDO = component.m_nview.GetZDO();
			if (zDO == null)
			{
				return true;
			}
			if (!ConstructionSystem.HasPaidData(zDO, __instance))
			{
				return true;
			}
			ConstructionSystem.SpawnRefundDrops(__instance, zDO, ((Component)__instance).transform.position + Vector3.up * 0.5f);
			return false;
		}
		catch (Exception arg)
		{
			EinjarheimProfessionsPlugin.Log.LogError((object)$"[Construction] Error DropResources: {arg}");
			return true;
		}
	}
}
[HarmonyPatch(typeof(Hud), "SetupPieceInfo")]
internal static class Construction_Patch_HudPieceInfo
{
	private static void Postfix(Hud __instance, Piece piece)
	{
		try
		{
			if ((Object)(object)piece == (Object)null || (Object)(object)__instance == (Object)null)
			{
				return;
			}
			TMP_Text pieceDescription = __instance.m_pieceDescription;
			if (!((Object)(object)pieceDescription == (Object)null))
			{
				Player localPlayer = Player.m_localPlayer;
				if (!((Object)(object)localPlayer == (Object)null))
				{
					float craftingLevel = ConstructionSystem.GetCraftingLevel(localPlayer);
					float healthMultiplier = ConstructionSystem.GetHealthMultiplier(localPlayer);
					WearNTear component = ((Component)piece).GetComponent<WearNTear>();
					float num = (((Object)(object)component != (Object)null) ? component.m_health : 0f);
					float num2 = num * healthMultiplier - num;
					string text = Localization.instance.Localize(piece.m_description);
					pieceDescription.text = text + $"\n<size=16><color=#FFD700>Crafting: Level {craftingLevel:0}</color></size>" + $"\n<size=16><color=#32CD32>Health: {num:0}</color> (+<color=#FFD700>{num2:0}</color>)</size>";
				}
			}
		}
		catch (Exception arg)
		{
			EinjarheimProfessionsPlugin.Log.LogError((object)$"[Construction] Error HUD SetupPieceInfo: {arg}");
		}
	}
}
[HarmonyPatch(typeof(InventoryGui), "SetupRequirement", new Type[]
{
	typeof(Transform),
	typeof(Requirement),
	typeof(Player),
	typeof(bool),
	typeof(int),
	typeof(int)
})]
internal static class Construction_Patch_SetupRequirement
{
	private static void Postfix(Transform elementRoot, Requirement req, Player player, bool craft, int quality, int craftMultiplier)
	{
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (!((Object)(object)player == (Object)null) && !((Object)(object)req?.m_resItem == (Object)null) && !craft && quality == 0)
			{
				Transform obj = elementRoot.Find("res_amount");
				TMP_Text val = ((obj != null) ? ((Component)obj).GetComponent<TMP_Text>() : null);
				if (!((Object)(object)val == (Object)null))
				{
					List<Container> nearbyContainers = ConstructionSystem.GetNearbyContainers(player);
					int num = ConstructionSystem.CountItemsTotal(player, req.m_resItem.m_itemData.m_shared.m_name, nearbyContainers);
					bool flag = (!craft && ZoneSystem.instance.GetGlobalKey((GlobalKeys)19)) || (craft && ZoneSystem.instance.GetGlobalKey((GlobalKeys)20));
					((Graphic)val).color = ((req.m_amount <= 0 || num >= req.m_amount || flag) ? Color.white : ((Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : Color.white));
				}
			}
		}
		catch (Exception arg)
		{
			EinjarheimProfessionsPlugin.Log.LogError((object)$"[Construction] Error SetupRequirement: {arg}");
		}
	}
}
[HarmonyPatch(typeof(Piece), "SetCreator", new Type[] { typeof(long) })]
internal static class Construction_Patch_SetCreator_Support
{
	private static void Postfix(Piece __instance, long uid)
	{
		try
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			WearNTear component = ((Component)__instance).GetComponent<WearNTear>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.m_nview == (Object)null || !component.m_nview.IsValid())
			{
				return;
			}
			ZDO zDO = component.m_nview.GetZDO();
			if (zDO == null || zDO.GetFloat("nazhi_construction_maxsupport", 0f) > 0f)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && localPlayer.GetPlayerID() == uid)
			{
				float craftingLevel = ConstructionSystem.GetCraftingLevel(localPlayer);
				int num = (int)(craftingLevel / 10f);
				if (num > 0)
				{
					float value = EinjarheimProfessionsPlugin.ConstructionSupportPerLevel.Value;
					float num2 = 1f + (float)num * value;
					float num3 = 1f + (float)num * (value * 0.5f);
					float num4 = default(float);
					float num5 = default(float);
					float num6 = default(float);
					float num7 = default(float);
					component.GetMaterialProperties(ref num4, ref num5, ref num6, ref num7);
					float num8 = num4 * num2;
					float num9 = num7 / num3;
					float num10 = num6 / num3;
					zDO.Set("nazhi_construction_maxsupport", num8);
					zDO.Set("nazhi_construction_maxsupport_vloss", num9);
					zDO.Set("nazhi_construction_maxsupport_hloss", num10);
					EinjarheimProfessionsPlugin.Log.LogInfo((object)$"[Construction] SetCreator Support '{((Object)__instance).name}' tier={num} maxSupport={num8:0} vLoss={num9:0.000} hLoss={num

BepInEx/plugins/Rarity.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Testing2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Testing2")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("55CC6F29-0D48-4124-93BF-F657DE656B82")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace YourModName
{
	public static class FixItemCommand
	{
		private class FixItemCmd : ConsoleCommand
		{
			public override string Name => "naz_fixitem";

			public override string Help => "Corrige rareza y herrería del item equipado. Uso: naz_fixitem [all]";

			public override bool IsCheat => true;

			public override void Run(string[] args)
			{
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null)
				{
					Logger.LogWarning((object)"[naz_fixitem] No hay jugador local.");
				}
				else if (args.Length != 0 && args[0].ToLower() == "all")
				{
					FixAllEquipped(localPlayer);
				}
				else
				{
					FixRightHandItem(localPlayer);
				}
			}
		}

		private struct FixResult
		{
			public bool Fixed;

			public bool FixedRarity;

			public bool FixedSmith;

			public bool Error;
		}

		private const string SMITH_LVL_KEY = "nazhi_blacksmith_lvl";

		private const string SMITH_DUR_KEY = "nazhi_blacksmith_durability";

		private const string SMITH_NAME_KEY = "nazhi_blacksmith_crafter";

		private const float SMITH_DMG_MAX = 0.5f;

		private const float SMITH_ARM_MAX = 0.5f;

		private const float SMITH_DUR_MAX = 0.6f;

		public static void Register()
		{
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new FixItemCmd());
		}

		private static void FixRightHandItem(Player player)
		{
			ItemData rightItem = ((Humanoid)player).GetRightItem();
			if (rightItem == null)
			{
				((Character)player).Message((MessageType)2, "<color=#ff5252>No tienes ningún item en mano derecha.</color>", 0, (Sprite)null);
				return;
			}
			FixResult result = TryFixItem(rightItem, player);
			ReportSingle(player, rightItem.m_shared.m_name, result);
		}

		private static void FixAllEquipped(Player player)
		{
			ItemData[] array = (ItemData[])(object)new ItemData[7]
			{
				((Humanoid)player).m_rightItem,
				((Humanoid)player).m_leftItem,
				((Humanoid)player).m_chestItem,
				((Humanoid)player).m_legItem,
				((Humanoid)player).m_helmetItem,
				((Humanoid)player).m_shoulderItem,
				((Humanoid)player).m_utilityItem
			};
			int num = 0;
			int num2 = 0;
			ItemData[] array2 = array;
			foreach (ItemData val in array2)
			{
				if (val != null && RarityPatches.IsWeaponOrArmor(val))
				{
					if (TryFixItem(val, player).Fixed)
					{
						num++;
					}
					else
					{
						num2++;
					}
				}
			}
			string text = ((num > 0) ? $"<color=#00e676>Se corrigieron {num} item(s). {num2} sin cambios.</color>" : "<color=#aaaaaa>Todos los items ya tenían sus stats correctos.</color>");
			((Character)player).Message((MessageType)2, text, 0, (Sprite)null);
		}

		private static FixResult TryFixItem(ItemData item, Player player)
		{
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Invalid comparison between Unknown and I4
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Invalid comparison between Unknown and I4
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Invalid comparison between Unknown and I4
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Invalid comparison between Unknown and I4
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Invalid comparison between Unknown and I4
			FixResult result = default(FixResult);
			if (item == null)
			{
				result.Error = true;
				return result;
			}
			RarityItemData rarityItemData = RarityTooltip.Get(item);
			if (rarityItemData == null)
			{
				rarityItemData = new RarityItemData(ItemRarity.Common);
				rarityItemData.SaveBaseDamages(item);
				RarityTooltip.Save(item, rarityItemData);
				Logger.LogInfo((object)("[naz_fixitem] " + item.m_shared.m_name + " sin RarityData — inicializado como Common"));
			}
			else if (rarityItemData.Rarity != ItemRarity.Common)
			{
				bool flag = false;
				bool flag2 = false;
				float num = 1f + RarityData.Info[rarityItemData.Rarity].StatBonus;
				if (!rarityItemData.HasBaseDamages)
				{
					rarityItemData.SaveBaseDamages(item);
					RarityTooltip.Save(item, rarityItemData);
					flag = rarityItemData.HasBaseDamages;
					Logger.LogInfo((object)("[naz_fixitem] " + item.m_shared.m_name + " BaseDamages recuperados del prefab"));
				}
				else
				{
					DamageTypes damages = item.m_shared.m_damages;
					flag = (rarityItemData.BasePierce > 0f && (ApproxEqual(damages.m_pierce, rarityItemData.BasePierce) || damages.m_pierce < rarityItemData.BasePierce * num - 0.2f)) || (rarityItemData.BaseBlunt > 0f && (ApproxEqual(damages.m_blunt, rarityItemData.BaseBlunt) || damages.m_blunt < rarityItemData.BaseBlunt * num - 0.2f)) || (rarityItemData.BaseSlash > 0f && (ApproxEqual(damages.m_slash, rarityItemData.BaseSlash) || damages.m_slash < rarityItemData.BaseSlash * num - 0.2f));
				}
				ItemType itemType = item.m_shared.m_itemType;
				bool flag3 = (int)itemType == 6 || (int)itemType == 7 || (int)itemType == 11 || (int)itemType == 17;
				bool flag4 = (int)itemType == 5;
				if (flag3 && rarityItemData.BaseArmor > 0f)
				{
					float num2 = rarityItemData.BaseArmor * num - item.m_shared.m_armorPerLevel * (float)(item.m_quality - 1);
					flag2 = item.m_shared.m_armor < num2 - 0.2f;
				}
				if (flag4 && rarityItemData.BaseBlockPower > 0f)
				{
					float num3 = rarityItemData.BaseBlockPower * num - item.m_shared.m_blockPowerPerLevel * (float)(item.m_quality - 1);
					flag2 |= item.m_shared.m_blockPower < num3 - 0.2f;
				}
				if (flag || flag2)
				{
					if (flag)
					{
						rarityItemData.RestoreBaseDamages(item);
						RarityPatches.ApplyStatBonusToDamages(item, rarityItemData);
					}
					if (flag2)
					{
						RarityPatches.ApplyStatBonusToArmor(item, rarityItemData);
					}
					EnchantBonusManager.RefreshSingleItem(item);
					RarityTooltip.Save(item, rarityItemData);
					result.FixedRarity = true;
					Logger.LogInfo((object)($"[naz_fixitem] rareza corregida — {item.m_shared.m_name} [{rarityItemData.Rarity}] " + $"mult={num:0.##} fixDmg={flag} fixArm={flag2}"));
				}
			}
			bool flag5 = SmithHasSignature(item);
			if (!flag5 && RarityPatches.IsWeaponOrArmor(item))
			{
				int currentSmithLevel = GetCurrentSmithLevel(player);
				float num4 = 1f + 0.6f * Mathf.Clamp01((float)currentSmithLevel / 100f);
				item.m_customData["nazhi_blacksmith_lvl"] = currentSmithLevel.ToString(CultureInfo.InvariantCulture);
				item.m_customData["nazhi_blacksmith_durability"] = num4.ToString(CultureInfo.InvariantCulture);
				item.m_customData["nazhi_blacksmith_crafter"] = player.GetPlayerName();
				float num5 = SmithGetDamageFactor(currentSmithLevel);
				Logger.LogInfo((object)("[naz_fixitem] herrería restaurada — " + item.m_shared.m_name + " " + $"smithLvl={currentSmithLevel} dmgFactor={num5:0.##} " + $"(GetDamage() aplicará ×{num5:0.##} en runtime)"));
				result.FixedSmith = true;
			}
			else if (flag5)
			{
				int num6 = SmithGetSavedLevel(item);
				Logger.LogInfo((object)$"[naz_fixitem] herrería ok — {item.m_shared.m_name} smithLvl={num6}");
			}
			if (result.FixedRarity || result.FixedSmith)
			{
				EnchantBonusManager.Refresh(player);
				result.Fixed = true;
				RarityItemData rarityItemData2 = RarityTooltip.Get(item);
				int level = SmithGetSavedLevel(item);
				Logger.LogInfo((object)("[naz_fixitem] ✓ " + item.m_shared.m_name + " " + $"Rarity={rarityItemData2?.Rarity} " + $"blunt={item.m_shared.m_damages.m_blunt:0.#} " + $"(×{SmithGetDamageFactor(level):0.##} smith en runtime) " + $"armor={item.m_shared.m_armor:0.#} " + $"fixRarity={result.FixedRarity} fixSmith={result.FixedSmith}"));
			}
			else
			{
				Logger.LogInfo((object)("[naz_fixitem] " + item.m_shared.m_name + " — sin cambios necesarios"));
			}
			return result;
		}

		private static bool SmithHasSignature(ItemData item)
		{
			if (item?.m_customData == null)
			{
				return false;
			}
			return item.m_customData.ContainsKey("nazhi_blacksmith_lvl") || item.m_customData.ContainsKey("nazhi_blacksmith_durability") || item.m_customData.ContainsKey("nazhi_blacksmith_crafter");
		}

		private static int SmithGetSavedLevel(ItemData item)
		{
			if (item?.m_customData == null)
			{
				return 0;
			}
			if (!item.m_customData.TryGetValue("nazhi_blacksmith_lvl", out var value))
			{
				return 0;
			}
			int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result);
			return result;
		}

		private static float SmithGetDamageFactor(int level)
		{
			if (level <= 0)
			{
				return 1f;
			}
			return 1f + 0.5f * Mathf.Clamp01((float)level / 100f);
		}

		private static int GetCurrentSmithLevel(Player player)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null)
			{
				return 0;
			}
			SkillType val = (SkillType)StringExtensionMethods.GetStableHashCode("nazhi.blacksmithing.skill");
			return Mathf.RoundToInt(Mathf.Clamp(((Character)player).GetSkillLevel(val), 0f, 100f));
		}

		private static void ReportSingle(Player player, string itemName, FixResult result)
		{
			if (result.Error)
			{
				((Character)player).Message((MessageType)2, "<color=#ff5252>Error al procesar " + itemName + ".</color>", 0, (Sprite)null);
				return;
			}
			if (!result.Fixed)
			{
				((Character)player).Message((MessageType)2, "<color=#aaaaaa>" + itemName + ": sin cambios necesarios.</color>", 0, (Sprite)null);
				return;
			}
			bool fixedRarity = result.FixedRarity;
			bool fixedSmith = result.FixedSmith;
			if (1 == 0)
			{
			}
			string text = (fixedRarity ? ((!fixedSmith) ? "rareza corregida" : "rareza + herrería corregidas") : ((!fixedSmith) ? "corregido" : "herrería restaurada"));
			if (1 == 0)
			{
			}
			string text2 = text;
			((Character)player).Message((MessageType)2, "<color=#00e676>✓ " + itemName + ": " + text2 + ".</color>", 0, (Sprite)null);
		}

		private static bool ApproxEqual(float a, float b, float tolerance = 0.15f)
		{
			return Mathf.Abs(a - b) < tolerance;
		}
	}
	public enum ItemRarity
	{
		Common,
		Uncommon,
		Rare,
		Epic,
		Legendary
	}
	public static class RarityData
	{
		public static readonly Dictionary<ItemRarity, RarityInfo> Info = new Dictionary<ItemRarity, RarityInfo>
		{
			{
				ItemRarity.Common,
				new RarityInfo
				{
					Name = "Common",
					Color = new Color(1f, 1f, 1f),
					StatBonus = 0f,
					SlotCount = 0,
					Weight = 20f
				}
			},
			{
				ItemRarity.Uncommon,
				new RarityInfo
				{
					Name = "Uncommon",
					Color = new Color(0.3f, 0.85f, 0.3f),
					StatBonus = 0.05f,
					SlotCount = 1,
					Weight = 40f
				}
			},
			{
				ItemRarity.Rare,
				new RarityInfo
				{
					Name = "Rare",
					Color = new Color(0.3f, 0.5f, 1f),
					StatBonus = 0.1f,
					SlotCount = 2,
					Weight = 25f
				}
			},
			{
				ItemRarity.Epic,
				new RarityInfo
				{
					Name = "Epic",
					Color = new Color(0.7f, 0.3f, 1f),
					StatBonus = 0.15f,
					SlotCount = 3,
					Weight = 15f
				}
			},
			{
				ItemRarity.Legendary,
				new RarityInfo
				{
					Name = "Legendary",
					Color = new Color(1f, 0.85f, 0.1f),
					StatBonus = 0.2f,
					SlotCount = 4,
					Weight = 0f
				}
			}
		};

		private static readonly Dictionary<ItemRarity, float> MasterWeights = new Dictionary<ItemRarity, float>
		{
			{
				ItemRarity.Common,
				0f
			},
			{
				ItemRarity.Uncommon,
				0f
			},
			{
				ItemRarity.Rare,
				45f
			},
			{
				ItemRarity.Epic,
				35f
			},
			{
				ItemRarity.Legendary,
				20f
			}
		};

		public const float MASTER_ROLL_THRESHOLD = 100f;

		public static ItemRarity RollRarity(float smithingLevel = 0f)
		{
			Dictionary<ItemRarity, float> dictionary = ((smithingLevel >= 100f) ? MasterWeights : null);
			float num = 0f;
			foreach (KeyValuePair<ItemRarity, RarityInfo> item in Info)
			{
				num += dictionary?[item.Key] ?? item.Value.Weight;
			}
			float num2 = Random.Range(0f, num);
			float num3 = 0f;
			foreach (KeyValuePair<ItemRarity, RarityInfo> item2 in Info)
			{
				num3 += dictionary?[item2.Key] ?? item2.Value.Weight;
				if (num2 < num3)
				{
					return item2.Key;
				}
			}
			return ItemRarity.Common;
		}
	}
	public class RarityInfo
	{
		public string Name;

		public Color Color;

		public float StatBonus;

		public int SlotCount;

		public float Weight;
	}
	public class RarityItemData
	{
		public ItemRarity Rarity;

		public int SlotCount;

		public List<string> InsertedScrollIds;

		public float BasePierce;

		public float BaseBlunt;

		public float BaseSlash;

		public float BaseFire;

		public float BaseFrost;

		public float BaseLightning;

		public float BaseSpirit;

		public float BasePoison;

		public float BaseArmor;

		public float BaseBlockPower;

		private static readonly CultureInfo Inv = CultureInfo.InvariantCulture;

		public int FilledSlots => InsertedScrollIds.FindAll((string s) => !string.IsNullOrEmpty(s)).Count;

		public int EmptySlots => SlotCount - FilledSlots;

		public bool HasFreeSlot => EmptySlots > 0;

		public bool HasBaseDamages => BasePierce > 0f || BaseBlunt > 0f || BaseSlash > 0f || BaseFire > 0f || BaseFrost > 0f || BaseLightning > 0f || BaseSpirit > 0f || BasePoison > 0f;

		public RarityItemData()
		{
		}

		public RarityItemData(ItemRarity rarity)
		{
			Rarity = rarity;
			SlotCount = RarityData.Info[rarity].SlotCount;
			InsertedScrollIds = new List<string>();
			for (int i = 0; i < SlotCount; i++)
			{
				InsertedScrollIds.Add(string.Empty);
			}
		}

		public void SaveBaseDamages(ItemData item)
		{
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Invalid comparison between Unknown and I4
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Invalid comparison between Unknown and I4
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Invalid comparison between Unknown and I4
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Invalid comparison between Unknown and I4
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Invalid comparison between Unknown and I4
			ObjectDB instance = ObjectDB.instance;
			object obj;
			if (instance == null)
			{
				obj = null;
			}
			else
			{
				GameObject dropPrefab = item.m_dropPrefab;
				obj = instance.GetItemPrefab(((dropPrefab != null) ? ((Object)dropPrefab).name : null) ?? "");
			}
			GameObject val = (GameObject)obj;
			ItemData val2 = ((val == null) ? null : val.GetComponent<ItemDrop>()?.m_itemData);
			if (val2 != null)
			{
				DamageTypes damages = val2.m_shared.m_damages;
				DamageTypes damagesPerLevel = val2.m_shared.m_damagesPerLevel;
				int num = item.m_quality - 1;
				BasePierce = damages.m_pierce + damagesPerLevel.m_pierce * (float)num;
				BaseBlunt = damages.m_blunt + damagesPerLevel.m_blunt * (float)num;
				BaseSlash = damages.m_slash + damagesPerLevel.m_slash * (float)num;
				BaseFire = damages.m_fire + damagesPerLevel.m_fire * (float)num;
				BaseFrost = damages.m_frost + damagesPerLevel.m_frost * (float)num;
				BaseLightning = damages.m_lightning + damagesPerLevel.m_lightning * (float)num;
				BaseSpirit = damages.m_spirit + damagesPerLevel.m_spirit * (float)num;
				BasePoison = damages.m_poison + damagesPerLevel.m_poison * (float)num;
				ItemType itemType = item.m_shared.m_itemType;
				bool flag = (int)itemType == 6 || (int)itemType == 7 || (int)itemType == 11 || (int)itemType == 17;
				bool flag2 = (int)itemType == 5;
				BaseArmor = (flag ? (val2.m_shared.m_armor + val2.m_shared.m_armorPerLevel * (float)num) : 0f);
				BaseBlockPower = (flag2 ? (val2.m_shared.m_blockPower + val2.m_shared.m_blockPowerPerLevel * (float)num) : 0f);
				Logger.LogInfo((object)($"[SaveBase] {item.m_shared.m_name} q={item.m_quality} FROM_PREFAB " + $"pierce={BasePierce:0.##} slash={BaseSlash:0.##} blunt={BaseBlunt:0.##} " + $"armor={BaseArmor:0.##} block={BaseBlockPower:0.##}"));
			}
			else
			{
				Logger.LogWarning((object)("[SaveBase] " + item.m_shared.m_name + " prefab no encontrado, usando item actual"));
				DamageTypes damages2 = item.m_shared.m_damages;
				BasePierce = damages2.m_pierce;
				BaseBlunt = damages2.m_blunt;
				BaseSlash = damages2.m_slash;
				BaseFire = damages2.m_fire;
				BaseFrost = damages2.m_frost;
				BaseLightning = damages2.m_lightning;
				BaseSpirit = damages2.m_spirit;
				BasePoison = damages2.m_poison;
				BaseArmor = item.m_shared.m_armor;
				BaseBlockPower = item.m_shared.m_blockPower;
			}
		}

		public void RestoreBaseDamages(ItemData item)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			DamageTypes damages = item.m_shared.m_damages;
			damages.m_pierce = BasePierce;
			damages.m_blunt = BaseBlunt;
			damages.m_slash = BaseSlash;
			damages.m_fire = BaseFire;
			damages.m_frost = BaseFrost;
			damages.m_lightning = BaseLightning;
			damages.m_spirit = BaseSpirit;
			damages.m_poison = BasePoison;
			item.m_shared.m_damages = damages;
		}

		public bool InsertScroll(string scrollPerkId)
		{
			for (int i = 0; i < InsertedScrollIds.Count; i++)
			{
				if (string.IsNullOrEmpty(InsertedScrollIds[i]))
				{
					InsertedScrollIds[i] = scrollPerkId;
					return true;
				}
			}
			return false;
		}

		public string RemoveScroll(int slotIndex)
		{
			if (slotIndex < 0 || slotIndex >= InsertedScrollIds.Count)
			{
				return string.Empty;
			}
			string result = InsertedScrollIds[slotIndex];
			InsertedScrollIds[slotIndex] = string.Empty;
			return result;
		}

		public string Serialize()
		{
			string text = string.Join(",", InsertedScrollIds);
			string text2 = string.Join(";", BasePierce.ToString("F4", Inv), BaseBlunt.ToString("F4", Inv), BaseSlash.ToString("F4", Inv), BaseFire.ToString("F4", Inv), BaseFrost.ToString("F4", Inv), BaseLightning.ToString("F4", Inv), BaseSpirit.ToString("F4", Inv), BasePoison.ToString("F4", Inv), BaseArmor.ToString("F4", Inv), BaseBlockPower.ToString("F4", Inv));
			return $"{(int)Rarity}|{SlotCount}|{text}|{text2}";
		}

		public static RarityItemData Deserialize(string raw)
		{
			if (string.IsNullOrEmpty(raw))
			{
				return null;
			}
			string[] array = raw.Split(new char[1] { '|' });
			if (array.Length < 1)
			{
				return null;
			}
			RarityItemData rarityItemData = new RarityItemData();
			if (int.TryParse(array[0], out var result))
			{
				rarityItemData.Rarity = (ItemRarity)result;
			}
			if (array.Length > 1 && int.TryParse(array[1], out var result2))
			{
				rarityItemData.SlotCount = result2;
			}
			else
			{
				rarityItemData.SlotCount = RarityData.Info[rarityItemData.Rarity].SlotCount;
			}
			rarityItemData.InsertedScrollIds = new List<string>();
			if (array.Length > 2 && !string.IsNullOrEmpty(array[2]))
			{
				string[] array2 = array[2].Split(new char[1] { ',' });
				foreach (string item in array2)
				{
					rarityItemData.InsertedScrollIds.Add(item);
				}
			}
			while (rarityItemData.InsertedScrollIds.Count < rarityItemData.SlotCount)
			{
				rarityItemData.InsertedScrollIds.Add(string.Empty);
			}
			string[] d;
			if (array.Length > 3 && !string.IsNullOrEmpty(array[3]))
			{
				d = array[3].Split(new char[1] { ';' });
				rarityItemData.BasePierce = F(0);
				rarityItemData.BaseBlunt = F(1);
				rarityItemData.BaseSlash = F(2);
				rarityItemData.BaseFire = F(3);
				rarityItemData.BaseFrost = F(4);
				rarityItemData.BaseLightning = F(5);
				rarityItemData.BaseSpirit = F(6);
				rarityItemData.BasePoison = F(7);
				rarityItemData.BaseArmor = F(8);
				rarityItemData.BaseBlockPower = F(9);
			}
			return rarityItemData;
			float F(int num)
			{
				float result3;
				return (d.Length > num && float.TryParse(d[num], NumberStyles.Float, Inv, out result3)) ? result3 : 0f;
			}
		}
	}
	[HarmonyPatch(typeof(ZNetScene), "RemoveObjects")]
	public static class ZNetScene_RemoveObjects_NullSafePatch
	{
		[HarmonyPrefix]
		public static void Prefix(ZNetScene __instance)
		{
			List<ZDO> list = new List<ZDO>();
			foreach (KeyValuePair<ZDO, ZNetView> instance in __instance.m_instances)
			{
				if ((Object)(object)instance.Value == (Object)null || (Object)(object)((Component)instance.Value).gameObject == (Object)null)
				{
					list.Add(instance.Key);
				}
			}
			foreach (ZDO item in list)
			{
				__instance.m_instances.Remove(item);
			}
		}
	}
	[HarmonyPatch(typeof(ZNetScene), "Shutdown")]
	public static class ZNetScene_Shutdown_NullSafePatch
	{
		[HarmonyPrefix]
		public static void Prefix(ZNetScene __instance)
		{
			List<ZDO> list = new List<ZDO>();
			foreach (KeyValuePair<ZDO, ZNetView> instance in __instance.m_instances)
			{
				if ((Object)(object)instance.Value == (Object)null || (Object)(object)((Component)instance.Value).gameObject == (Object)null)
				{
					list.Add(instance.Key);
				}
			}
			foreach (ZDO item in list)
			{
				__instance.m_instances.Remove(item);
			}
		}
	}
	[HarmonyPatch]
	public static class RarityItemVFX
	{
		private const string VFX_CHILD_NAME = "RarityVFX";

		[HarmonyPatch(typeof(ItemDrop), "Start")]
		[HarmonyPostfix]
		public static void ItemDrop_Start_Postfix(ItemDrop __instance)
		{
			((MonoBehaviour)__instance).StartCoroutine(ApplyVFXNextFrame(__instance));
		}

		private static IEnumerator ApplyVFXNextFrame(ItemDrop drop)
		{
			yield return null;
			if (!((Object)(object)drop == (Object)null) && !((Object)(object)((Component)drop).gameObject == (Object)null))
			{
				float timeout = 5f;
				while (timeout > 0f && ((Object)(object)Player.m_localPlayer == (Object)null || ((Character)Player.m_localPlayer).IsTeleporting()))
				{
					yield return (object)new WaitForSeconds(0.2f);
					timeout -= 0.2f;
				}
				yield return null;
				if (!((Object)(object)drop == (Object)null) && !((Object)(object)((Component)drop).gameObject == (Object)null))
				{
					ApplyVFX(drop);
				}
			}
		}

		public static void ApplyVFX(ItemDrop drop)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: 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_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: 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_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: 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)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Expected O, but got Unknown
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Expected O, but got Unknown
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)drop == (Object)null)
			{
				return;
			}
			ItemData itemData = drop.m_itemData;
			if (itemData == null)
			{
				return;
			}
			Color color;
			if (ScrollItem.IsEnchantScroll(itemData))
			{
				ScrollItem.TryGetScrollTier(itemData, out var rarity);
				if (rarity == ItemRarity.Common)
				{
					return;
				}
				color = RarityData.Info[rarity].Color;
			}
			else
			{
				if (!RarityPatches.IsWeaponOrArmor(itemData))
				{
					return;
				}
				RarityItemData rarityItemData = RarityTooltip.Get(itemData);
				if (rarityItemData == null || rarityItemData.Rarity == ItemRarity.Common)
				{
					return;
				}
				color = RarityData.Info[rarityItemData.Rarity].Color;
			}
			Transform val = FindDeep(((Component)drop).transform, "fx_ItemSparkles");
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogWarning((object)("[Rarity VFX] No se encontró fx_ItemSparkles en " + ((Object)drop).name));
				return;
			}
			ParticleSystem[] componentsInChildren = ((Component)val).GetComponentsInChildren<ParticleSystem>(true);
			foreach (ParticleSystem val2 in componentsInChildren)
			{
				MainModule main = val2.main;
				((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(color.r, color.g, color.b, 1f), new Color(color.r, color.g, color.b, 0.4f));
				((MainModule)(ref main)).maxParticles = 100;
				((MainModule)(ref main)).simulationSpeed = 1f;
				EmissionModule emission = val2.emission;
				((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(50f);
				ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
				if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled)
				{
					Gradient val3 = new Gradient();
					val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
					{
						new GradientColorKey(color, 0f),
						new GradientColorKey(color, 1f)
					}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
					{
						new GradientAlphaKey(1f, 0f),
						new GradientAlphaKey(0f, 1f)
					});
					((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val3);
				}
				ParticleSystemRenderer component = ((Component)val2).GetComponent<ParticleSystemRenderer>();
				if ((Object)(object)component != (Object)null && (Object)(object)((Renderer)component).material != (Object)null)
				{
					Material val4 = new Material(((Renderer)component).material);
					if (val4.HasProperty("_Color"))
					{
						val4.SetColor("_Color", color);
					}
					if (val4.HasProperty("_TintColor"))
					{
						val4.SetColor("_TintColor", color);
					}
					if (val4.HasProperty("_EmissionColor"))
					{
						val4.SetColor("_EmissionColor", color * 2f);
					}
					((Renderer)component).material = val4;
				}
			}
			val.localScale = new Vector3(1f, 4f, 1f);
			Logger.LogInfo((object)("[Rarity VFX] " + ((Object)drop).name + " recoloreado | color #" + ColorUtility.ToHtmlStringRGB(color)));
		}

		private static Transform FindDeep(Transform parent, string name)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			foreach (Transform item in parent)
			{
				Transform val = item;
				if (((Object)val).name == name)
				{
					return val;
				}
				Transform val2 = FindDeep(val, name);
				if ((Object)(object)val2 != (Object)null)
				{
					return val2;
				}
			}
			return null;
		}
	}
	[HarmonyPatch]
	public static class RarityPatches
	{
		private static bool _addItemProcessing;

		private const string BORDER_CHILD_NAME = "RarityBorder";

		private const float BORDER_THICKNESS = 2f;

		private const float LINE_HEIGHT = 3f;

		[HarmonyPatch(typeof(InventoryGui), "DoCrafting")]
		[HarmonyPostfix]
		public static void DoCrafting_Postfix(InventoryGui __instance, Player player)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			Inventory inventory = ((Humanoid)player).GetInventory();
			float num = 0f;
			bool flag = false;
			bool flag2 = false;
			if ((Object)(object)player == (Object)(object)Player.m_localPlayer)
			{
				SkillType val = (SkillType)StringExtensionMethods.GetStableHashCode("nazhi.blacksmithing.skill");
				num = Mathf.Clamp(((Character)player).GetSkillLevel(val), 0f, 100f);
				if (player.m_customData.TryGetValue("nazhi_specialization", out var value) && int.TryParse(value, out var result))
				{
					flag2 = result == 2;
					flag = flag2 && num >= 50f;
				}
			}
			float smithingLevel = (flag ? 100f : num);
			foreach (ItemData allItem in inventory.GetAllItems())
			{
				if (!allItem.m_customData.ContainsKey("RarityData") && IsWeaponOrArmor(allItem))
				{
					RarityItemData orCreate = RarityTooltip.GetOrCreate(allItem, smithingLevel);
					orCreate.SaveBaseDamages(allItem);
					ApplyStatBonusToDamages(allItem, orCreate);
					ApplyStatBonusToArmor(allItem, orCreate);
					RarityTooltip.Save(allItem, orCreate);
					string arg = (flag ? " [Maestro Herrero ✓]" : (flag2 ? " [Maestro Herrero — nivel insuficiente]" : ""));
					Logger.LogInfo((object)("[Rarity] Crafteado: " + allItem.m_shared.m_name + " " + $"-> {orCreate.Rarity} ({orCreate.SlotCount} slots) " + $"| StatBonus +{RarityData.Info[orCreate.Rarity].StatBonus * 100f:0}%" + $"| Herrería lv{num:0}{arg}"));
				}
			}
		}

		[HarmonyPatch(typeof(Inventory), "AddItem", new Type[]
		{
			typeof(string),
			typeof(int),
			typeof(int),
			typeof(int),
			typeof(long),
			typeof(string),
			typeof(Vector2i),
			typeof(bool)
		})]
		[HarmonyPostfix]
		public static void AddItem_Postfix(ref ItemData __result)
		{
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			if (__result == null || !IsWeaponOrArmor(__result))
			{
				return;
			}
			RarityItemData rarityItemData = RarityTooltip.Get(__result);
			if (rarityItemData == null || __result.m_quality <= 1 || _addItemProcessing)
			{
				return;
			}
			_addItemProcessing = true;
			try
			{
				Logger.LogInfo((object)($"[Upgrade:START] {__result.m_shared.m_name} q={__result.m_quality} " + $"| m_armor={__result.m_shared.m_armor:0.##} " + $"| BaseArmor_guardado={rarityItemData.BaseArmor:0.##} " + $"| Rarity={rarityItemData.Rarity} mult={1f + RarityData.Info[rarityItemData.Rarity].StatBonus:0.##}"));
				ObjectDB instance = ObjectDB.instance;
				object obj;
				if (instance == null)
				{
					obj = null;
				}
				else
				{
					GameObject dropPrefab = __result.m_dropPrefab;
					obj = instance.GetItemPrefab(((dropPrefab != null) ? ((Object)dropPrefab).name : null) ?? "");
				}
				GameObject val = (GameObject)obj;
				ItemData val2 = ((val == null) ? null : val.GetComponent<ItemDrop>()?.m_itemData);
				if (val2 == null && (Object)(object)ObjectDB.instance != (Object)null)
				{
					foreach (GameObject item in ObjectDB.instance.m_items)
					{
						ItemDrop val3 = ((item != null) ? item.GetComponent<ItemDrop>() : null);
						if (val3?.m_itemData?.m_shared?.m_name == __result.m_shared.m_name)
						{
							val2 = val3.m_itemData;
							break;
						}
					}
				}
				string text = $"[Upgrade:PREFAB] encontrado={val2 != null} ";
				string text2;
				if (val2 == null)
				{
					GameObject dropPrefab2 = __result.m_dropPrefab;
					text2 = "| m_dropPrefab.name='" + (((dropPrefab2 != null) ? ((Object)dropPrefab2).name : null) ?? "NULL") + "'";
				}
				else
				{
					text2 = $"| prefab.m_armor={val2.m_shared.m_armor:0.##} " + $"| prefab.m_armorPerLevel={val2.m_shared.m_armorPerLevel:0.##} " + $"| vanillaArmor_calculado={val2.m_shared.m_armor + val2.m_shared.m_armorPerLevel * (float)(__result.m_quality - 1):0.##}";
				}
				Logger.LogInfo((object)(text + text2));
				if (val2 != null)
				{
					float num = val2.m_shared.m_armor + val2.m_shared.m_armorPerLevel * (float)(__result.m_quality - 1);
					float num2 = val2.m_shared.m_blockPower + val2.m_shared.m_blockPowerPerLevel * (float)(__result.m_quality - 1);
					Logger.LogInfo((object)($"[Upgrade:BASE] via prefab — BaseArmor anterior={rarityItemData.BaseArmor:0.##} → nuevo={num:0.##} " + $"| BaseBlockPower anterior={rarityItemData.BaseBlockPower:0.##} → nuevo={num2:0.##}"));
					rarityItemData.BaseArmor = num;
					rarityItemData.BaseBlockPower = num2;
					if (!rarityItemData.HasBaseDamages)
					{
						DamageTypes damages = val2.m_shared.m_damages;
						rarityItemData.BasePierce = damages.m_pierce;
						rarityItemData.BaseBlunt = damages.m_blunt;
						rarityItemData.BaseSlash = damages.m_slash;
						rarityItemData.BaseFire = damages.m_fire;
						rarityItemData.BaseFrost = damages.m_frost;
						rarityItemData.BaseLightning = damages.m_lightning;
						rarityItemData.BaseSpirit = damages.m_spirit;
						rarityItemData.BasePoison = damages.m_poison;
						Logger.LogInfo((object)"[Upgrade:BASE] BaseDamages inicializados desde prefab");
					}
				}
				else
				{
					float num3 = 1f + RarityData.Info[rarityItemData.Rarity].StatBonus;
					float num4 = rarityItemData.BaseArmor * num3;
					bool flag = Mathf.Abs(__result.m_shared.m_armor - num4) < 0.2f;
					Logger.LogInfo((object)($"[Upgrade:BASE] sin prefab — rarityMult={num3:0.##} " + $"expectedWithRarity={num4:0.##} " + $"m_armor={__result.m_shared.m_armor:0.##} " + $"alreadyApplied={flag}"));
					if (rarityItemData.BaseArmor > 0f && flag)
					{
						float num5 = __result.m_shared.m_armor / num3;
						Logger.LogInfo((object)$"[Upgrade:BASE] rarity ya aplicada — BaseArmor inferido={num5:0.##} (anterior={rarityItemData.BaseArmor:0.##})");
						rarityItemData.BaseArmor = num5;
					}
					else if (rarityItemData.BaseArmor <= 0f)
					{
						Logger.LogWarning((object)"[Upgrade:BASE] sin BaseArmor previo — forzando SaveBaseDamages (último recurso)");
						rarityItemData.SaveBaseDamages(__result);
					}
					else
					{
						Logger.LogInfo((object)$"[Upgrade:BASE] BaseArmor={rarityItemData.BaseArmor:0.##} parece correcto, no se toca");
					}
				}
				Logger.LogInfo((object)($"[Upgrade:APPLY] BaseArmor={rarityItemData.BaseArmor:0.##} " + $"mult={1f + RarityData.Info[rarityItemData.Rarity].StatBonus:0.##} " + $"→ m_armor esperado={rarityItemData.BaseArmor * (1f + RarityData.Info[rarityItemData.Rarity].StatBonus):0.##}"));
				ApplyStatBonusToDamages(__result, rarityItemData);
				ApplyStatBonusToArmor(__result, rarityItemData);
				EnchantBonusManager.RefreshSingleItem(__result);
				RarityTooltip.Save(__result, rarityItemData);
				Logger.LogInfo((object)($"[Upgrade:END] {__result.m_shared.m_name} q={__result.m_quality} " + $"BaseArmor={rarityItemData.BaseArmor:0.##} m_armor_final={__result.m_shared.m_armor:0.##}"));
			}
			finally
			{
				_addItemProcessing = false;
			}
		}

		[HarmonyPatch(typeof(InventoryGrid), "UpdateGui")]
		[HarmonyPostfix]
		public static void UpdateGui_Postfix(InventoryGrid __instance)
		{
			//IL_0046: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: 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)
			Inventory inventory = __instance.m_inventory;
			if (inventory == null)
			{
				return;
			}
			foreach (Element element in __instance.m_elements)
			{
				if (!element.m_used)
				{
					SetBorderColor(element.m_go, Color.clear);
					continue;
				}
				ItemData itemAt = inventory.GetItemAt(element.m_pos.x, element.m_pos.y);
				if (itemAt == null)
				{
					SetBorderColor(element.m_go, Color.clear);
					continue;
				}
				if (ScrollItem.IsEnchantScroll(itemAt))
				{
					ScrollItem.TryGetScrollTier(itemAt, out var rarity);
					Color color = RarityData.Info[rarity].Color;
					string text = ColorUtility.ToHtmlStringRGB(color);
					element.m_tooltip.m_topic = "<color=#" + text + ">" + itemAt.m_shared.m_name + "</color>";
					SetBorderColor(element.m_go, color, rarity);
					continue;
				}
				RarityItemData rarityItemData = RarityTooltip.Get(itemAt);
				if (rarityItemData == null || rarityItemData.Rarity == ItemRarity.Common)
				{
					element.m_tooltip.m_topic = itemAt.m_shared.m_name;
					SetBorderColor(element.m_go, Color.clear);
					continue;
				}
				Color color2 = RarityData.Info[rarityItemData.Rarity].Color;
				string text2 = ColorUtility.ToHtmlStringRGB(color2);
				element.m_tooltip.m_topic = "<color=#" + text2 + ">" + itemAt.m_shared.m_name + "</color>";
				SetBorderColor(element.m_go, color2, rarityItemData.Rarity);
			}
		}

		[HarmonyPatch(typeof(HotkeyBar), "UpdateIcons")]
		[HarmonyPostfix]
		public static void UpdateIcons_Postfix(HotkeyBar __instance, Player player)
		{
			//IL_0059: 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_0119: 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_0150: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			Inventory inventory = ((Humanoid)player).GetInventory();
			if (inventory == null)
			{
				return;
			}
			foreach (ElementData element in __instance.m_elements)
			{
				if (!element.m_used)
				{
					SetBorderColor(element.m_go, Color.clear);
					continue;
				}
				ItemData val = null;
				foreach (ItemData item in __instance.m_items)
				{
					if (item.m_gridPos.x == __instance.m_elements.IndexOf(element))
					{
						val = item;
						break;
					}
				}
				if (val == null)
				{
					SetBorderColor(element.m_go, Color.clear);
					continue;
				}
				if (ScrollItem.IsEnchantScroll(val))
				{
					ScrollItem.TryGetScrollTier(val, out var rarity);
					SetBorderColor(element.m_go, RarityData.Info[rarity].Color, rarity);
					continue;
				}
				RarityItemData rarityItemData = RarityTooltip.Get(val);
				if (rarityItemData == null || rarityItemData.Rarity == ItemRarity.Common)
				{
					SetBorderColor(element.m_go, Color.clear);
				}
				else
				{
					SetBorderColor(element.m_go, RarityData.Info[rarityItemData.Rarity].Color, rarityItemData.Rarity);
				}
			}
		}

		private static void SetBorderColor(GameObject slotGo, Color color, ItemRarity rarity = ItemRarity.Common)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_004b: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Expected O, but got Unknown
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: 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_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: 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_0146: 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_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: 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_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Expected O, but got Unknown
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0451: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: 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_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_0490: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_058f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0596: Expected O, but got Unknown
			//IL_051b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0522: Expected O, but got Unknown
			//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f6: 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_0615: Unknown result type (might be due to invalid IL or missing references)
			//IL_0617: Unknown result type (might be due to invalid IL or missing references)
			//IL_053c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)slotGo == (Object)null)
			{
				return;
			}
			Transform obj = slotGo.transform.Find("icon");
			RectTransform val = (RectTransform)(object)((obj is RectTransform) ? obj : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Rect rect = val.rect;
			Vector2 size = ((Rect)(ref rect)).size;
			if (size.x <= 0f)
			{
				((Vector2)(ref size))..ctor(64f, 64f);
			}
			bool flag = color.a > 0f;
			Transform val2 = slotGo.transform.Find("RarityLetter");
			if ((Object)(object)val2 == (Object)null)
			{
				GameObject val3 = new GameObject("RarityLetter", new Type[2]
				{
					typeof(RectTransform),
					typeof(Image)
				});
				val3.transform.SetParent(slotGo.transform, false);
				Transform obj2 = slotGo.transform.Find("icon");
				int num = ((obj2 != null) ? obj2.GetSiblingIndex() : 0);
				val3.transform.SetSiblingIndex(Mathf.Max(0, num));
				RectTransform component = val3.GetComponent<RectTransform>();
				component.anchorMin = Vector2.zero;
				component.anchorMax = Vector2.one;
				component.offsetMin = new Vector2(size.x * 0.15f, size.y * 0.15f);
				component.offsetMax = new Vector2((0f - size.x) * 0.15f, (0f - size.y) * 0.15f);
				((Transform)component).localScale = Vector3.one;
				Image component2 = val3.GetComponent<Image>();
				((Graphic)component2).raycastTarget = false;
				((Graphic)component2).color = Color.clear;
				val2 = val3.transform;
			}
			Image component3 = ((Component)val2).GetComponent<Image>();
			if ((Object)(object)component3 != (Object)null)
			{
				if (!flag)
				{
					((Graphic)component3).color = Color.clear;
					component3.sprite = null;
				}
				else
				{
					component3.sprite = VegvisirSprites.GetForRarity(rarity);
					((Graphic)component3).color = new Color(1f, 1f, 1f, 0.2f);
				}
			}
			Transform val4 = slotGo.transform.Find("RarityBg");
			if ((Object)(object)val4 == (Object)null)
			{
				GameObject val5 = new GameObject("RarityBg", new Type[2]
				{
					typeof(RectTransform),
					typeof(Image)
				});
				val5.transform.SetParent(slotGo.transform, false);
				val5.transform.SetAsFirstSibling();
				RectTransform component4 = val5.GetComponent<RectTransform>();
				component4.anchorMin = Vector2.zero;
				component4.anchorMax = Vector2.one;
				component4.offsetMin = Vector2.zero;
				component4.offsetMax = Vector2.zero;
				((Transform)component4).localScale = Vector3.one;
				Image component5 = val5.GetComponent<Image>();
				((Graphic)component5).raycastTarget = false;
				val5.AddComponent<RarityBgPulse>();
				val4 = val5.transform;
			}
			Transform val6 = slotGo.transform.Find("RarityBorder");
			GameObject val7;
			if ((Object)(object)val6 == (Object)null)
			{
				val7 = new GameObject("RarityBorder", new Type[1] { typeof(RectTransform) });
				val7.transform.SetParent(slotGo.transform, false);
				val7.transform.SetAsLastSibling();
				RectTransform component6 = val7.GetComponent<RectTransform>();
				component6.anchorMin = new Vector2(0.5f, 0.5f);
				component6.anchorMax = new Vector2(0.5f, 0.5f);
				component6.pivot = new Vector2(0.5f, 0.5f);
				component6.sizeDelta = size;
				((Transform)component6).localScale = Vector3.one;
				CreateRect(val7, "Top", new Vector2(0f, size.y * 0.5f - 1f), new Vector2(size.x, 2f), 1f);
				CreateRect(val7, "Bottom", new Vector2(0f, (0f - size.y) * 0.5f + 1f), new Vector2(size.x, 2f), 1f);
				CreateRect(val7, "Left", new Vector2((0f - size.x) * 0.5f + 1f, 0f), new Vector2(2f, size.y), 1f);
				CreateRect(val7, "Right", new Vector2(size.x * 0.5f - 1f, 0f), new Vector2(2f, size.y), 1f);
			}
			else
			{
				val7 = ((Component)val6).gameObject;
			}
			RarityBgPulse component7 = ((Component)val4).GetComponent<RarityBgPulse>();
			if (!((Object)(object)component7 != (Object)null))
			{
				return;
			}
			if (!flag)
			{
				component7.Hide();
				{
					foreach (Transform item in val7.transform)
					{
						Transform val8 = item;
						Image component8 = ((Component)val8).GetComponent<Image>();
						if ((Object)(object)component8 != (Object)null)
						{
							((Graphic)component8).color = Color.clear;
						}
					}
					return;
				}
			}
			List<Image> list = new List<Image>();
			foreach (Transform item2 in val7.transform)
			{
				Transform val9 = item2;
				Image component9 = ((Component)val9).GetComponent<Image>();
				if ((Object)(object)component9 != (Object)null)
				{
					list.Add(component9);
				}
			}
			component7.BorderImages = list.ToArray();
			Color darkColor = default(Color);
			((Color)(ref darkColor))..ctor(color.r * 0.3f, color.g * 0.3f, color.b * 0.3f);
			component7.SetRarity(darkColor, color, rarity);
		}

		private static void CreateRect(GameObject parent, string name, Vector2 anchoredPos, Vector2 size, float alpha)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val.transform.SetParent(parent.transform, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(0.5f, 0.5f);
			component.anchoredPosition = anchoredPos;
			component.sizeDelta = size;
			((Transform)component).localScale = Vector3.one;
			Image component2 = val.GetComponent<Image>();
			((Graphic)component2).raycastTarget = false;
			((Graphic)component2).color = new Color(1f, 1f, 1f, alpha);
		}

		public static bool IsWeaponOrArmor(ItemData item)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Invalid comparison between Unknown and I4
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Invalid comparison between Unknown and I4
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Invalid comparison between Unknown and I4
			ItemType itemType = item.m_shared.m_itemType;
			return (int)itemType == 3 || (int)itemType == 14 || (int)itemType == 4 || (int)itemType == 5 || (int)itemType == 6 || (int)itemType == 7 || (int)itemType == 11 || (int)itemType == 17 || (int)itemType == 18;
		}

		public static void ApplyStatBonusToDamages(ItemData item, RarityItemData data)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			if (data.Rarity != ItemRarity.Common && data.HasBaseDamages)
			{
				float num = 1f + RarityData.Info[data.Rarity].StatBonus;
				DamageTypes damages = item.m_shared.m_damages;
				if (data.BasePierce > 0f)
				{
					damages.m_pierce = data.BasePierce * num;
				}
				if (data.BaseBlunt > 0f)
				{
					damages.m_blunt = data.BaseBlunt * num;
				}
				if (data.BaseSlash > 0f)
				{
					damages.m_slash = data.BaseSlash * num;
				}
				if (data.BaseFire > 0f)
				{
					damages.m_fire = data.BaseFire * num;
				}
				if (data.BaseFrost > 0f)
				{
					damages.m_frost = data.BaseFrost * num;
				}
				if (data.BaseLightning > 0f)
				{
					damages.m_lightning = data.BaseLightning * num;
				}
				if (data.BaseSpirit > 0f)
				{
					damages.m_spirit = data.BaseSpirit * num;
				}
				if (data.BasePoison > 0f)
				{
					damages.m_poison = data.BasePoison * num;
				}
				item.m_shared.m_damages = damages;
			}
		}

		public static void ApplyStatBonusToArmor(ItemData item, RarityItemData data)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Invalid comparison between Unknown and I4
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Invalid comparison between Unknown and I4
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Invalid comparison between Unknown and I4
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Invalid comparison between Unknown and I4
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Invalid comparison between Unknown and I4
			if (data.Rarity != ItemRarity.Common)
			{
				float num = 1f + RarityData.Info[data.Rarity].StatBonus;
				ItemType itemType = item.m_shared.m_itemType;
				if (((int)itemType == 6 || (int)itemType == 7 || (int)itemType == 11 || (int)itemType == 17) && data.BaseArmor > 0f)
				{
					float num2 = item.m_shared.m_armorPerLevel * (float)(item.m_quality - 1);
					item.m_shared.m_armor = data.BaseArmor * num - num2;
					Logger.LogInfo((object)($"[ApplyArmor] {item.m_shared.m_name} q={item.m_quality} " + $"base={data.BaseArmor:0.##} mult={num:0.##} " + $"qualityBonus={num2:0.##} " + $"m_armor_escrito={item.m_shared.m_armor:0.##} " + $"GetArmor_esperado={data.BaseArmor * num:0.##}"));
				}
				if ((int)itemType == 5 && data.BaseBlockPower > 0f)
				{
					float num3 = item.m_shared.m_blockPowerPerLevel * (float)(item.m_quality - 1);
					item.m_shared.m_blockPower = data.BaseBlockPower * num - num3;
					Logger.LogInfo((object)($"[ApplyBlock] {item.m_shared.m_name} q={item.m_quality} " + $"baseBlock={data.BaseBlockPower:0.##} mult={num:0.##} " + $"qualityBonus={num3:0.##} " + $"m_blockPower_escrito={item.m_shared.m_blockPower:0.##} " + $"GetBlockPower_esperado={data.BaseBlockPower * num:0.##}"));
				}
			}
		}
	}
	[HarmonyPatch]
	public static class GetTooltip_Patch
	{
		private static MethodBase TargetMethod()
		{
			MethodInfo[] methods = typeof(ItemData).GetMethods(BindingFlags.Static | BindingFlags.Public);
			foreach (MethodInfo methodInfo in methods)
			{
				if (methodInfo.Name == "GetTooltip")
				{
					ParameterInfo[] parameters = methodInfo.GetParameters();
					if (parameters.Length != 0 && parameters[0].ParameterType == typeof(ItemData))
					{
						return methodInfo;
					}
				}
			}
			return null;
		}

		[HarmonyPostfix]
		public static void Postfix(ItemData item, ref string __result)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (item == null)
			{
				return;
			}
			if (ScrollItem.IsEnchantScroll(item))
			{
				ScrollItem.TryGetScrollTier(item, out var rarity);
				RarityInfo rarityInfo = RarityData.Info[rarity];
				string text = ColorUtility.ToHtmlStringRGB(rarityInfo.Color);
				string text2 = "";
				if (item.m_customData.TryGetValue("ScrollPerk", out var value) && !string.IsNullOrEmpty(value))
				{
					string[] array = value.Split(new char[1] { ':' });
					ScrollPerkDef byName = ScrollPerkRegistry.GetByName(array[0]);
					if (byName != null)
					{
						string text3 = ((array.Length == 2) ? (byName.GetDisplayText(rarity) + " vs " + array[1]) : byName.GetDisplayText(rarity));
						text2 = "\n<color=#" + text + ">" + text3 + "</color>";
					}
				}
				__result = "<color=#" + text + "><b>Pergamino " + rarityInfo.Name + "</b></color>" + text2 + "\nClick derecho para encantar.\n\n<color=#" + text + ">Rareza: " + rarityInfo.Name + "</color>";
				return;
			}
			RarityItemData rarityItemData = RarityTooltip.Get(item);
			if (rarityItemData != null && rarityItemData.Rarity != ItemRarity.Common && (__result == null || !__result.Contains("Tier: " + RarityData.Info[rarityItemData.Rarity].Name)))
			{
				__result = RarityTooltip.ColorizeHeader(__result, rarityItemData);
				__result = RarityTooltip.StripExistingPerkLines(__result, rarityItemData);
				__result = RarityTooltip.ReplaceDamageLines(__result, rarityItemData, item);
				__result = RarityTooltip.ReplaceArmorLine(__result, rarityItemData, item);
				__result = RarityTooltip.ReplaceBlockLine(__result, rarityItemData, item);
				string text4 = RarityTooltip.BuildTooltipAddition(rarityItemData, item);
				if (!string.IsNullOrEmpty(text4))
				{
					__result = __result + "\n" + text4;
				}
			}
		}
	}
	public class RarityBgPulse : MonoBehaviour
	{
		private Image _bgImg;

		public float BgAlphaMin = 0.35f;

		public float BgAlphaMax = 0.7f;

		public float BorderAlphaMin = 0.6f;

		public float BorderAlphaMax = 1f;

		public float Speed = 0.9f;

		public Color BaseColor = Color.white;

		private Color _borderColor = Color.white;

		public Image[] BorderImages;

		private float _t = 0f;

		private const float BG_DARK_MIX_INV = 0.35f;

		private void Awake()
		{
			_bgImg = ((Component)this).GetComponent<Image>();
		}

		private void Update()
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_bgImg == (Object)null)
			{
				return;
			}
			_t += Time.deltaTime * Speed;
			float num = (Mathf.Sin(_t * (float)Math.PI * 2f) + 1f) * 0.5f;
			float num2 = Mathf.Lerp(BgAlphaMin, BgAlphaMax, num);
			((Graphic)_bgImg).color = new Color(BaseColor.r, BaseColor.g, BaseColor.b, num2);
			if (BorderImages == null)
			{
				return;
			}
			float num3 = Mathf.Lerp(BorderAlphaMin, BorderAlphaMax, num);
			Color color = default(Color);
			((Color)(ref color))..ctor(_borderColor.r, _borderColor.g, _borderColor.b, num3);
			Image[] borderImages = BorderImages;
			foreach (Image val in borderImages)
			{
				if ((Object)(object)val != (Object)null)
				{
					((Graphic)val).color = color;
				}
			}
		}

		public void SetRarity(Color darkColor, Color borderColor, ItemRarity rarity)
		{
			//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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			BaseColor = darkColor;
			_borderColor = borderColor;
			Speed = 0.8f;
			((Behaviour)this).enabled = true;
		}

		public void Hide()
		{
			//IL_0017: 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)(object)_bgImg != (Object)null)
			{
				((Graphic)_bgImg).color = Color.clear;
			}
			if (BorderImages != null)
			{
				Image[] borderImages = BorderImages;
				foreach (Image val in borderImages)
				{
					if ((Object)(object)val != (Object)null)
					{
						((Graphic)val).color = Color.clear;
					}
				}
			}
			((Behaviour)this).enabled = false;
		}
	}
	public class RarityIconPulse : MonoBehaviour
	{
		private Shadow _shadow;

		public float AlphaMin = 0.5f;

		public float AlphaMax = 1f;

		public float Speed = 0.8f;

		public Color BaseColor = Color.white;

		private float _t = 0f;

		private void Awake()
		{
			_shadow = ((Component)this).GetComponent<Shadow>();
		}

		private void Update()
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_shadow == (Object)null) && ((Behaviour)_shadow).enabled)
			{
				_t += Time.deltaTime * Speed;
				float num = (Mathf.Sin(_t * (float)Math.PI * 2f) + 1f) * 0.5f;
				float num2 = Mathf.Lerp(AlphaMin, AlphaMax, num);
				_shadow.effectColor = new Color(BaseColor.r, BaseColor.g, BaseColor.b, num2);
			}
		}

		public void SetColor(Color color)
		{
			//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)
			BaseColor = color;
			_t = 0f;
			((Behaviour)this).enabled = true;
		}

		public void Hide()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_shadow != (Object)null)
			{
				_shadow.effectColor = Color.clear;
			}
			((Behaviour)this).enabled = false;
		}
	}
	public class RarityDesignBPulse : MonoBehaviour
	{
		private GameObject _container;

		private Color _color;

		private float _t = 0f;

		private const float SPEED = 0.8f;

		private const float ALPHA_MIN = 0.3f;

		private const float ALPHA_MAX = 1f;

		private void Update()
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_container == (Object)null)
			{
				return;
			}
			_t += Time.deltaTime * 0.8f;
			float num = (Mathf.Sin(_t * (float)Math.PI * 2f) + 1f) * 0.5f;
			float num2 = Mathf.Lerp(0.3f, 1f, num);
			foreach (Transform item in _container.transform)
			{
				Transform val = item;
				Image component = ((Component)val).GetComponent<Image>();
				if ((Object)(object)component != (Object)null)
				{
					((Graphic)component).color = new Color(_color.r, _color.g, _color.b, num2);
				}
			}
		}

		public void Activate(Color borderColor, Color bgColor, GameObject container)
		{
			//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)
			_color = borderColor;
			_container = container;
			_t = 0f;
			((Behaviour)this).enabled = true;
		}

		public void Hide(GameObject container)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			_container = container;
			if ((Object)(object)container != (Object)null)
			{
				foreach (Transform item in container.transform)
				{
					Transform val = item;
					Image component = ((Component)val).GetComponent<Image>();
					if ((Object)(object)component != (Object)null)
					{
						((Graphic)component).color = Color.clear;
					}
				}
			}
			((Behaviour)this).enabled = false;
		}
	}
	public static class VegvisirSprites
	{
		public static Sprite Uncommon;

		public static Sprite Rare;

		public static Sprite Epic;

		public static Sprite Legendary;

		public static void Load()
		{
			string path = Path.Combine(Paths.PluginPath, "Rarity", "Assets");
			Uncommon = LoadSprite(Path.Combine(path, "logoverde.png"));
			Rare = LoadSprite(Path.Combine(path, "logoazul.png"));
			Epic = LoadSprite(Path.Combine(path, "logomorado.png"));
			Legendary = LoadSprite(Path.Combine(path, "logoamarillo.png"));
		}

		private static Sprite LoadSprite(string fullPath)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			if (!File.Exists(fullPath))
			{
				Logger.LogWarning((object)("[Vegvisir] PNG no encontrado: " + fullPath));
				return null;
			}
			byte[] array = File.ReadAllBytes(fullPath);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			try
			{
				MethodInfo methodInfo = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule")?.GetMethod("LoadImage", new Type[3]
				{
					typeof(Texture2D),
					typeof(byte[]),
					typeof(bool)
				});
				if (methodInfo != null && !(bool)methodInfo.Invoke(null, new object[3] { val, array, false }))
				{
					Logger.LogWarning((object)("[Vegvisir] LoadImage falló: " + fullPath));
					return null;
				}
			}
			catch (Exception ex)
			{
				Logger.LogWarning((object)("[Vegvisir] Excepción cargando " + fullPath + ": " + ex.Message));
				return null;
			}
			((Texture)val).filterMode = (FilterMode)1;
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.one * 0.5f);
		}

		public static Sprite GetForRarity(ItemRarity rarity)
		{
			if (1 == 0)
			{
			}
			Sprite result = (Sprite)(rarity switch
			{
				ItemRarity.Uncommon => Uncommon, 
				ItemRarity.Rare => Rare, 
				ItemRarity.Epic => Epic, 
				ItemRarity.Legendary => Legendary, 
				_ => null, 
			});
			if (1 == 0)
			{
			}
			return result;
		}
	}
	[BepInPlugin("com.tuusuario.valheim.rarity", "ItemRaritySystem", "0.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class RarityPlugin : BaseUnityPlugin
	{
		public const string ModGUID = "com.tuusuario.valheim.rarity";

		public const string ModName = "ItemRaritySystem";

		public const string ModVersion = "0.2.0";

		private Harmony _harmony;

		public static RarityPlugin Instance { get; private set; }

		private void Awake()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			Instance = this;
			Logger.LogInfo((object)"[ItemRaritySystem] Cargando sistema de rareza v0.2.0...");
			_harmony = new Harmony("com.tuusuario.valheim.rarity");
			_harmony.PatchAll();
			VegvisirSprites.Load();
			ScrollItem.Register();
			FixItemCommand.Register();
			GUIManager.OnCustomGUIAvailable += CreateScrollUI;
			Logger.LogInfo((object)"[ItemRaritySystem] ¡Listo! Patches aplicados.");
		}

		private void CreateScrollUI()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			if (!((Object)(object)ScrollEnchantUI.Instance != (Object)null))
			{
				GameObject val = new GameObject("ScrollEnchantUI");
				Object.DontDestroyOnLoad((Object)(object)val);
				val.AddComponent<ScrollEnchantUI>();
			}
		}

		private void OnDestroy()
		{
			Instance = null;
			GUIManager.OnCustomGUIAvailable -= CreateScrollUI;
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	public static class RarityTooltip
	{
		private const string CUSTOM_DATA_KEY = "RarityData";

		private const string SMITH_LEVEL_KEY = "nazhi_blacksmith_lvl";

		private const float SMITH_WEAPON_MAX = 0.5f;

		private const float SMITH_ARMOR_MAX = 0.5f;

		private static readonly Dictionary<ItemRarity, string> SlotFilledChar = new Dictionary<ItemRarity, string>
		{
			{
				ItemRarity.Common,
				"\ud83d\udc8e"
			},
			{
				ItemRarity.Uncommon,
				"\ud83d\udc8e"
			},
			{
				ItemRarity.Rare,
				"\ud83d\udc8e"
			},
			{
				ItemRarity.Epic,
				"\ud83d\udc8e"
			},
			{
				ItemRarity.Legendary,
				"\ud83d\udc8e"
			}
		};

		private const string SLOT_EMPTY = "\ud83d\udd28";

		private const string SEP = "━━━━━━━━━━━━━━━━";

		private static readonly string[] ItemTypeKeys = new string[14]
		{
			"$item_onehanded", "$item_twohanded", "$item_bow", "$item_shield", "$item_helmet", "$item_chest", "$item_legs", "$item_shoulder", "$item_utility", "$item_tool",
			"$item_ammo", "$item_trophy", "$item_consumable", "$item_material"
		};

		public static string ColorizeHeader(string tooltip, RarityItemData data)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(tooltip) || data == null || data.Rarity == ItemRarity.Common)
			{
				return tooltip;
			}
			RarityInfo rarityInfo = RarityData.Info[data.Rarity];
			string text = ColorUtility.ToHtmlStringRGB(rarityInfo.Color);
			string text2 = null;
			string[] itemTypeKeys = ItemTypeKeys;
			foreach (string text3 in itemTypeKeys)
			{
				if (tooltip.Contains(text3))
				{
					text2 = text3;
					break;
				}
			}
			if (text2 == null)
			{
				return tooltip;
			}
			int num = tooltip.IndexOf(text2, StringComparison.OrdinalIgnoreCase);
			if (num < 0)
			{
				return tooltip;
			}
			string text4 = tooltip.Substring(0, num).TrimEnd('\n', '\r');
			string text5 = tooltip.Substring(num);
			string[] array = text4.Split(new char[1] { '\n' });
			StringBuilder stringBuilder = new StringBuilder();
			string[] array2 = array;
			foreach (string text6 in array2)
			{
				string text7 = text6.TrimEnd(new char[1] { '\r' });
				if (string.IsNullOrWhiteSpace(text7))
				{
					stringBuilder.AppendLine();
					continue;
				}
				stringBuilder.AppendLine("<color=#" + text + ">" + text7 + "</color>");
			}
			stringBuilder.AppendLine("<color=#" + text + ">Tier: " + rarityInfo.Name + "</color>");
			stringBuilder.AppendLine("<color=#" + text + ">━━━━━━━━━━━━━━━━</color>");
			return stringBuilder.ToString() + text5;
		}

		public static string ReplaceDamageLines(string tooltip, RarityItemData data, ItemData item)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_007b: 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_00a9: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: 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_015b: 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_0189: 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_01b7: 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)
			if (string.IsNullOrEmpty(tooltip) || item == null)
			{
				return tooltip;
			}
			RarityInfo rarityInfo = RarityData.Info[data.Rarity];
			string arg = ColorUtility.ToHtmlStringRGB(rarityInfo.Color);
			float smithWeaponFactor = GetSmithWeaponFactor(GetSmithLevel(item));
			DamageTypes damages = item.m_shared.m_damages;
			DamageTypes damagesPerLevel = item.m_shared.m_damagesPerLevel;
			int num = item.m_quality - 1;
			Dictionary<string, (float, float, string)> dictionary = new Dictionary<string, (float, float, string)>
			{
				{
					"pierce",
					(damages.m_pierce + damagesPerLevel.m_pierce * (float)num, data.BasePierce, "Perforante")
				},
				{
					"blunt",
					(damages.m_blunt + damagesPerLevel.m_blunt * (float)num, data.BaseBlunt, "Contundente")
				},
				{
					"slash",
					(damages.m_slash + damagesPerLevel.m_slash * (float)num, data.BaseSlash, "Cortante")
				},
				{
					"fire",
					(damages.m_fire + damagesPerLevel.m_fire * (float)num, data.BaseFire, "Fuego")
				},
				{
					"frost",
					(damages.m_frost + damagesPerLevel.m_frost * (float)num, data.BaseFrost, "Escarcha")
				},
				{
					"lightning",
					(damages.m_lightning + damagesPerLevel.m_lightning * (float)num, data.BaseLightning, "Rayo")
				},
				{
					"spirit",
					(damages.m_spirit + damagesPerLevel.m_spirit * (float)num, data.BaseSpirit, "Espíritu")
				},
				{
					"poison",
					(damages.m_poison + damagesPerLevel.m_poison * (float)num, data.BasePoison, "Veneno")
				}
			};
			foreach (KeyValuePair<string, (float, float, string)> item2 in dictionary)
			{
				string pattern = "^\\$inventory_" + item2.Key + "\\s*:.*$";
				var (num2, num3, arg2) = item2.Value;
				if (num2 <= 0f)
				{
					tooltip = Regex.Replace(tooltip, pattern, string.Empty, RegexOptions.IgnoreCase | RegexOptions.Multiline);
					continue;
				}
				float num4 = num2 * smithWeaponFactor;
				string text = ((num3 > 0f) ? FormatStatDiff(num4, num3) : string.Empty);
				string replacement = $"<color=#{arg}>{arg2}: {num4:0.#}" + ((text.Length > 0) ? ("  " + text) : string.Empty) + "</color>";
				tooltip = Regex.Replace(tooltip, pattern, replacement, RegexOptions.IgnoreCase | RegexOptions.Multiline);
			}
			return tooltip;
		}

		public static string ReplaceArmorLine(string tooltip, RarityItemData data, ItemData item)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Invalid comparison between Unknown and I4
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Invalid comparison between Unknown and I4
			//IL_0080: 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_0056: Invalid comparison between Unknown and I4
			if (string.IsNullOrEmpty(tooltip) || item == null)
			{
				return tooltip;
			}
			if ((int)item.m_shared.m_itemType != 6 && (int)item.m_shared.m_itemType != 7 && (int)item.m_shared.m_itemType != 11 && (int)item.m_shared.m_itemType != 17)
			{
				return tooltip;
			}
			RarityInfo rarityInfo = RarityData.Info[data.Rarity];
			string arg = ColorUtility.ToHtmlStringRGB(rarityInfo.Color);
			float smithArmorFactor = GetSmithArmorFactor(GetSmithLevel(item));
			float num = 0f;
			foreach (string insertedScrollId in data.InsertedScrollIds)
			{
				if (!string.IsNullOrEmpty(insertedScrollId))
				{
					ScrollPerkDef byName = ScrollPerkRegistry.GetByName(insertedScrollId.Split(new char[1] { ':' })[0]);
					if (byName != null && byName.Type == ScrollPerkType.Armadura)
					{
						num += byName.GetValue(data.Rarity);
					}
				}
			}
			float num2 = data.BaseArmor * (1f + rarityInfo.StatBonus);
			float num3 = num2 * smithArmorFactor;
			float num4 = num3 + num;
			string text = ((data.BaseArmor > 0f) ? FormatStatDiff(num4, data.BaseArmor) : string.Empty);
			Logger.LogInfo((object)($"[ArmorDebug] base={data.BaseArmor:0.##} " + $"afterRarity={num2:0.##} " + $"afterSmith={num3:0.##} " + $"perk={num:0.##} " + $"total={num4:0.##}"));
			string replacement = $"<color=#{arg}>Armadura: {num4:0.#}" + ((text.Length > 0) ? ("  " + text) : string.Empty) + "</color>";
			tooltip = Regex.Replace(tooltip, "^\\$item_armor\\s*:.*$", replacement, RegexOptions.IgnoreCase | RegexOptions.Multiline);
			return tooltip;
		}

		public static string ReplaceBlockLine(string tooltip, RarityItemData data, ItemData item)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(tooltip) || item == null)
			{
				return tooltip;
			}
			if ((int)item.m_shared.m_itemType != 5)
			{
				return tooltip;
			}
			RarityInfo rarityInfo = RarityData.Info[data.Rarity];
			string arg = ColorUtility.ToHtmlStringRGB(rarityInfo.Color);
			float num = 0f;
			foreach (string insertedScrollId in data.InsertedScrollIds)
			{
				if (!string.IsNullOrEmpty(insertedScrollId))
				{
					ScrollPerkDef byName = ScrollPerkRegistry.GetByName(insertedScrollId.Split(new char[1] { ':' })[0]);
					if (byName != null && byName.Type == ScrollPerkType.Bloqueo)
					{
						num += byName.GetValue(data.Rarity);
					}
				}
			}
			float num2 = data.BaseBlockPower * (1f + rarityInfo.StatBonus);
			float num3 = num2 + num;
			string text = ((data.BaseBlockPower > 0f) ? FormatStatDiff(num3, data.BaseBlockPower) : string.Empty);
			string replacement = $"<color=#{arg}>Bloqueo: {num3:0.#}" + ((text.Length > 0) ? ("  " + text) : string.Empty) + "</color>";
			tooltip = Regex.Replace(tooltip, "^\\$item_blockarmor\\s*:.*$", replacement, RegexOptions.IgnoreCase | RegexOptions.Multiline);
			return tooltip;
		}

		public static string StripExistingPerkLines(string tooltip, RarityItemData data)
		{
			if (string.IsNullOrEmpty(tooltip) || data == null)
			{
				return tooltip;
			}
			if (data.InsertedScrollIds == null || data.InsertedScrollIds.Count == 0)
			{
				return tooltip;
			}
			List<string> list = new List<string>();
			foreach (string insertedScrollId in data.InsertedScrollIds)
			{
				if (!string.IsNullOrEmpty(insertedScrollId))
				{
					list.Add(insertedScrollId.Split(new char[1] { ':' })[0]);
				}
			}
			if (list.Count == 0)
			{
				return tooltip;
			}
			string[] array = tooltip.Split(new char[1] { '\n' });
			StringBuilder stringBuilder = new StringBuilder();
			string[] array2 = array;
			foreach (string text in array2)
			{
				bool flag = text.Contains("━━━━━━━━━━━━━━━━");
				if (!flag)
				{
					foreach (string item in list)
					{
						if (text.Contains(item))
						{
							flag = true;
							break;
						}
					}
				}
				if (!flag && (text.Contains("\ud83d\udd28") || text.Contains("\ud83d\udc8e")))
				{
					flag = true;
				}
				if (!flag)
				{
					stringBuilder.AppendLine(text.TrimEnd(new char[1] { '\r' }));
				}
			}
			return stringBuilder.ToString().TrimEnd('\n', '\r');
		}

		public static string BuildTooltipAddition(RarityItemData data, ItemData item = null)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (data == null || data.Rarity == ItemRarity.Common)
			{
				return string.Empty;
			}
			RarityInfo rarityInfo = RarityData.Info[data.Rarity];
			string text = ColorUtility.ToHtmlStringRGB(rarityInfo.Color);
			string filledChar = SlotFilledChar[data.Rarity];
			StringBuilder stringBuilder = new StringBuilder();
			if (data.SlotCount > 0)
			{
				stringBuilder.AppendLine();
				for (int i = 0; i < data.SlotCount; i++)
				{
					string text2 = ((i < data.InsertedScrollIds.Count) ? data.InsertedScrollIds[i] : string.Empty);
					if (string.IsNullOrEmpty(text2))
					{
						stringBuilder.AppendLine("\ud83d\udd28 <color=#888888>Slot vacío</color>");
					}
					else
					{
						stringBuilder.AppendLine(BuildPerkDescription(text2, data.Rarity, text, filledChar));
					}
				}
			}
			stringBuilder.AppendLine();
			stringBuilder.Append("<color=#" + text + ">━━━━━━━━━━━━━━━━</color>");
			return stringBuilder.ToString();
		}

		public static RarityItemData GetOrCreate(ItemData itemData, float smithingLevel = 0f)
		{
			if (itemData.m_customData.TryGetValue("RarityData", out var value))
			{
				RarityItemData rarityItemData = RarityItemData.Deserialize(value);
				if (rarityItemData != null)
				{
					return rarityItemData;
				}
			}
			ItemRarity rarity = RarityData.RollRarity(smithingLevel);
			RarityItemData rarityItemData2 = new RarityItemData(rarity);
			itemData.m_customData["RarityData"] = rarityItemData2.Serialize();
			return rarityItemData2;
		}

		public static RarityItemData Get(ItemData itemData)
		{
			if (itemData.m_customData.TryGetValue("RarityData", out var value))
			{
				return RarityItemData.Deserialize(value);
			}
			return null;
		}

		public static void Save(ItemData itemData, RarityItemData data)
		{
			itemData.m_customData["RarityData"] = data.Serialize();
		}

		public static string GetRarityHex(RarityItemData data)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (data == null)
			{
				return "ffffff";
			}
			return ColorUtility.ToHtmlStringRGB(RarityData.Info[data.Rarity].Color);
		}

		private static int GetSmithLevel(ItemData item)
		{
			if (item?.m_customData == null)
			{
				return 0;
			}
			if (!item.m_customData.TryGetValue("nazhi_blacksmith_lvl", out var value))
			{
				return 0;
			}
			int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result);
			return result;
		}

		private static float GetSmithWeaponFactor(int smithLvl)
		{
			if (smithLvl <= 0)
			{
				return 1f;
			}
			return 1f + 0.5f * Mathf.Clamp01((float)smithLvl / 100f);
		}

		private static float GetSmithArmorFactor(int smithLvl)
		{
			if (smithLvl <= 0)
			{
				return 1f;
			}
			return 1f + 0.5f * Mathf.Clamp01((float)smithLvl / 100f);
		}

		private static string FormatStatDiff(float current, float vanillaBase)
		{
			if (vanillaBase <= 0f)
			{
				return string.Empty;
			}
			float num = current - vanillaBase;
			float num2 = num / vanillaBase * 100f;
			if (Mathf.Abs(num) < 0.05f)
			{
				return string.Empty;
			}
			bool flag = num >= 0f;
			string text = (flag ? "00e676" : "ff5252");
			string arg = (flag ? "+" : "");
			string text2 = $"{arg}{num:0.#}";
			string text3 = $"{arg}{num2:0.#}%";
			return "<color=#" + text + "><size=93%>↑</size>" + text2 + " (" + text3 + ")</color>";
		}

		private static string BuildPerkDescription(string scrollId, ItemRarity rarity, string hex, string filledChar)
		{
			string[] array = scrollId.Split(new char[1] { ':' });
			string displayName = array[0];
			string text = ((array.Length == 2) ? array[1] : null);
			ScrollPerkDef byName = ScrollPerkRegistry.GetByName(displayName);
			if (byName == null)
			{
				return filledChar + " <color=#" + hex + ">" + scrollId + "</color>";
			}
			float value = byName.GetValue(rarity);
			bool flag = byName.Type == ScrollPerkType.Vida || byName.Type == ScrollPerkType.Armadura || byName.Type == ScrollPerkType.Durabilidad;
			string text2 = ((byName.Type == ScrollPerkType.NoMovPen) ? "Activado" : (flag ? $"{value:0}" : $"{value:0.##}%"));
			ScrollPerkType type = byName.Type;
			if (1 == 0)
			{
			}
			string text3 = type switch
			{
				ScrollPerkType.Pierce => "Perforante: Aumenta en " + text2 + " el daño perforante", 
				ScrollPerkType.Blunt => "Contundente: Aumenta en " + text2 + " el daño contundente", 
				ScrollPerkType.Slash => "Cortante: Aumenta en " + text2 + " el daño cortante", 
				ScrollPerkType.DmgMagico => "Dominio Elemental: Aumenta en " + text2 + " el daño mágico", 
				ScrollPerkType.VelocidadAtk => "Frenesí: Aumenta en " + text2 + " la velocidad de ataque", 
				ScrollPerkType.DmgFaccion => "Oportunista: Aumenta en " + text2 + " el daño vs " + TranslateFaction(text ?? "enemigos"), 
				ScrollPerkType.ReduccionDmg => "Piel de Hierro: Reduce en " + text2 + " el daño recibido", 
				ScrollPerkType.Armadura => "Bastión: Aumenta en " + text2 + " la armadura", 
				ScrollPerkType.Vida => "Vitalidad: Aumenta en " + text2 + " el HP máximo", 
				ScrollPerkType.RegHP => "Vitalis: Aumenta en " + text2 + " la regeneración de HP", 
				ScrollPerkType.RegStamina => "Segundo Aliento: Aumenta en " + text2 + " la regen. de Stamina", 
				ScrollPerkType.RegEitr => "Eco de Eitr: Aumenta en " + text2 + " la regeneración de Eitr", 
				ScrollPerkType.Durabilidad => "Temple Reforjado: Aumenta en " + text2 + " la durabilidad", 
				ScrollPerkType.Healing => "Sagrado: Aumenta en " + text2 + " el poder de curación", 
				ScrollPerkType.ResistPierce => "Escudo Perforante: Reduce en " + text2 + " el daño perforante recibido", 
				ScrollPerkType.ResistBlunt => "Escudo Contundente: Reduce en " + text2 + " el daño contundente recibido", 
				ScrollPerkType.ResistSlash => "Escudo Cortante: Reduce en " + text2 + " el daño cortante recibido", 
				ScrollPerkType.Bloqueo => "Aegis: Aumenta en " + text2 + " el valor de bloqueo", 
				ScrollPerkType.Parry => "Contraataque: Aumenta en " + text2 + " el multiplicador de parry", 
				ScrollPerkType.NoMovPen => "Sin Límites: Elimina la penalización de movimiento", 
				ScrollPerkType.WeapSkill => "Destreza: Aumenta en " + text2 + " puntos la skill del arma", 
				ScrollPerkType.Weight => "Sobrecarga: Aumenta en " + text2 + " puntos el peso máximo", 
				_ => byName.DisplayName + ": +" + text2, 
			};
			if (1 == 0)
			{
			}
			string text4 = text3;
			return filledChar + " <color=#" + hex + ">" + text4 + "</color>";
		}

		private static string TranslateFaction(string faction)
		{
			if (1 == 0)
			{
			}
			string result = faction switch
			{
				"ForestMonsters" => "Monstruos del Bosque", 
				"Undead" => "No Muertos", 
				"Demon" => "Demonios", 
				"MountainMonsters" => "Monstruos de Montaña", 
				"SeaMonsters" => "Monstruos del Mar", 
				"PlainsMonsters" => "Monstruos de Llanos", 
				"Boss" => "Jefes", 
				"MistlandsMonsters" => "Monstruos de Niebla", 
				"Dverger" => "Dverger", 
				_ => faction, 
			};
			if (1 == 0)
			{
			}
			return result;
		}
	}
	[HarmonyPatch]
	public static class ScrollDropPatch
	{
		[HarmonyPatch(typeof(Humanoid), "UseItem")]
		[HarmonyPrefix]
		public static bool UseItem_Prefix(Humanoid __instance, Inventory inventory, ItemData item, bool fromInventoryGui)
		{
			if (item == null)
			{
				return true;
			}
			if (!ScrollItem.IsEnchantScroll(item))
			{
				return true;
			}
			return false;
		}
	}
	public class ScrollEnchantUI : MonoBehaviour
	{
		private ItemData _scrollItem;

		private ItemData _targetItem;

		private bool _isOpen;

		private GameObject _titlePanel;

		private GameObject _leftPanel;

		private GameObject _rightPanel;

		private GameObject _bottomPanel;

		private Image _weaponIcon;

		private Text _weaponHint;

		private Text _weaponLabelText;

		private Image _scrollIcon;

		private Text _scrollPerkText;

		private Text _statusText;

		private Text _itemNameText;

		private Text _slotsAvailText;

		private Text _perksCurrentText;

		private Text _perksNewText;

		private Text _smithLevelText;

		private Button _acceptBtn;

		private Image _coinIcon;

		private Text _coinCostText;

		private const float LeftW = 300f;

		private const float RightW = 460f;

		private const float BodyH = 540f;

		private const float Gap = 10f;

		private const float TotalW = 770f;

		private const float BottomH = 80f;

		private const string COIN_PREFAB_NAME = "Coins";

		private Text _titleText;

		public static ScrollEnchantUI Instance { get; private set; }

		private static int GetSmithLevelRequired(ItemRarity rarity)
		{
			if (1 == 0)
			{
			}
			int result = rarity switch
			{
				ItemRarity.Common => 0, 
				ItemRarity.Uncommon => 5, 
				ItemRarity.Rare => 10, 
				ItemRarity.Epic => 15, 
				ItemRarity.Legendary => 50, 
				_ => 0, 
			};
			if (1 == 0)
			{
			}
			return result;
		}

		private static int GetCoinCost(ItemRarity rarity)
		{
			if (1 == 0)
			{
			}
			int result = rarity switch
			{
				ItemRarity.Common => 0, 
				ItemRarity.Uncommon => 200, 
				ItemRarity.Rare => 300, 
				ItemRarity.Epic => 600, 
				ItemRarity.Legendary => 1500, 
				_ => 0, 
			};
			if (1 == 0)
			{
			}
			return result;
		}

		private void Awake()
		{
			Instance = this;
			GUIManager.OnCustomGUIAvailable += OnGUIAvailable;
		}

		private void OnDestroy()
		{
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
			GUIManager.OnCustomGUIAvailable -= OnGUIAvailable;
		}

		private void OnGUIAvailable()
		{
			Object.Destroy((Object)(object)_titlePanel);
			_titlePanel = null;
			Object.Destroy((Object)(object)_leftPanel);
			_leftPanel = null;
			Object.Destroy((Object)(object)_rightPanel);
			_rightPanel = null;
			Object.Destroy((Object)(object)_bottomPanel);
			_bottomPanel = null;
			EnsurePanel();
		}

		private void Update()
		{
		}

		public void Open(ItemData scrollItem)
		{
			if (scrollItem != null)
			{
				_scrollItem = scrollItem;
				_targetItem = null;
				EnsurePanel();
				if (!((Object)(object)_titlePanel == (Object)null))
				{
					RefreshUI();
					_titlePanel.SetActive(true);
					_leftPanel.SetActive(true);
					_rightPanel.SetActive(true);
					_bottomPanel.SetActive(true);
					_isOpen = true;
				}
			}
		}

		public void Close()
		{
			((MonoBehaviour)this).CancelInvoke("Close");
			_isOpen = false;
			GameObject titlePanel = _titlePanel;
			if (titlePanel != null)
			{
				titlePanel.SetActive(false);
			}
			GameObject leftPanel = _leftPanel;
			if (leftPanel != null)
			{
				leftPanel.SetActive(false);
			}
			GameObject rightPanel = _rightPanel;
			if (rightPanel != null)
			{
				rightPanel.SetActive(false);
			}
			GameObject bottomPanel = _bottomPanel;
			if (bottomPanel != null)
			{
				bottomPanel.SetActive(false);
			}
			_scrollItem = null;
			_targetItem = null;
		}

		public void TrySetTarget(ItemData item)
		{
			if (_isOpen && item != null && RarityPatches.IsWeaponOrArmor(item))
			{
				_targetItem = item;
				RefreshUI();
			}
		}

		private void EnsurePanel()
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: 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)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_0433: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_0485: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0505: Unknown result type (might be due to invalid IL or missing references)
			//IL_0527: Unknown result type (might be due to invalid IL or missing references)
			//IL_0566: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ca: Unknown result type (might be due to invalid IL or missing referenc