Decompiled source of Fenrir Curse v1.2.0

FenrirCurse.dll

Decompiled 2 weeks 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.Permissions;
using BepInEx;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using UnityEngine;
using Valheim.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("FenrirCurseMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FenrirCurseMod")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace FenrirCurseMod;

public static class FenrirCompendium
{
	private const string PageKey = "Fenrir's Curse";

	private const string Common = "You have been bitten, and the beast's blood is now in your veins. You are infected with Fenrir's Curse. It does not wear off by itself, and it will still be there after you die or log out. The beast's blood also leaves you weaker against spirit damage.\n\n";

	private const string Ending = "\n\nThe curse is not a death sentence. Someone may know how to lift it: probably a witch, or somebody who lives with her, will be able to help you. Witches usually live in the swamps.";

	private const string BasicText = "You have been bitten, and the beast's blood is now in your veins. You are infected with Fenrir's Curse. It does not wear off by itself, and it will still be there after you die or log out. The beast's blood also leaves you weaker against spirit damage.\n\nTRANSFORMATIONS\n- G: at night you become a Fenring, fast, light on your feet, immune to fall damage, and you fight with claws instead of weapons. By day the beast rests and G does nothing.\n- H: you become a Wolf, at any hour. Slower than the Fenring, but with the same stamina gains, and good for travelling quietly.\nPress the same key again to return to human form. A form also ends if you die or log out. On a gamepad, both are in the Fenrir Curse group of the emote wheel.\n\nThe curse is not a death sentence. Someone may know how to lift it: probably a witch, or somebody who lives with her, will be able to help you. Witches usually live in the swamps.";

	private const string EnhancedText = "You have been bitten, and the beast's blood is now in your veins. You are infected with Fenrir's Curse. It does not wear off by itself, and it will still be there after you die or log out. The beast's blood also leaves you weaker against spirit damage.\n\nYour curse has been empowered. The beast's blood boils, and it gives you stronger forms.\n\nTRANSFORMATIONS\n- G: at night you become a Cultist, a Fenring that breathes fire (right mouse button), with bonus Eitr while transformed. By day G does nothing.\n- H: you become an Ulv, at any hour, the stronger cousin of the Wolf.\nPress the same key again to return to human form. A form also ends if you die or log out. On a gamepad, both are in the Fenrir Curse group of the emote wheel.\n\nThe curse is not a death sentence. Someone may know how to lift it: probably a witch, or somebody who lives with her, will be able to help you. Witches usually live in the swamps.";

	public static void Refresh(Player player)
	{
		if ((Object)(object)player == (Object)null)
		{
			return;
		}
		Dictionary<string, string> value = Traverse.Create((object)player).Field("m_knownTexts").GetValue<Dictionary<string, string>>();
		if (value != null)
		{
			string value2;
			bool flag = player.m_customData.TryGetValue("EnhancedCurse_Active", out value2) && value2 == "true";
			string value3;
			bool flag2 = !flag && player.m_customData.TryGetValue("FenrirCurse_Active", out value3) && value3 == "true";
			if (!flag && !flag2)
			{
				value.Remove("Fenrir's Curse");
			}
			else
			{
				value["Fenrir's Curse"] = (flag ? "You have been bitten, and the beast's blood is now in your veins. You are infected with Fenrir's Curse. It does not wear off by itself, and it will still be there after you die or log out. The beast's blood also leaves you weaker against spirit damage.\n\nYour curse has been empowered. The beast's blood boils, and it gives you stronger forms.\n\nTRANSFORMATIONS\n- G: at night you become a Cultist, a Fenring that breathes fire (right mouse button), with bonus Eitr while transformed. By day G does nothing.\n- H: you become an Ulv, at any hour, the stronger cousin of the Wolf.\nPress the same key again to return to human form. A form also ends if you die or log out. On a gamepad, both are in the Fenrir Curse group of the emote wheel.\n\nThe curse is not a death sentence. Someone may know how to lift it: probably a witch, or somebody who lives with her, will be able to help you. Witches usually live in the swamps." : "You have been bitten, and the beast's blood is now in your veins. You are infected with Fenrir's Curse. It does not wear off by itself, and it will still be there after you die or log out. The beast's blood also leaves you weaker against spirit damage.\n\nTRANSFORMATIONS\n- G: at night you become a Fenring, fast, light on your feet, immune to fall damage, and you fight with claws instead of weapons. By day the beast rests and G does nothing.\n- H: you become a Wolf, at any hour. Slower than the Fenring, but with the same stamina gains, and good for travelling quietly.\nPress the same key again to return to human form. A form also ends if you die or log out. On a gamepad, both are in the Fenrir Curse group of the emote wheel.\n\nThe curse is not a death sentence. Someone may know how to lift it: probably a witch, or somebody who lives with her, will be able to help you. Witches usually live in the swamps.");
			}
		}
	}
}
[BepInPlugin("com.nandor.fenrircurse", "Fenrir Curse", "1.2.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class FenrirCurseMod : BaseUnityPlugin
{
	public const string PluginGUID = "com.nandor.fenrircurse";

	public const string PluginName = "Fenrir Curse";

	public const string PluginVersion = "1.2.0";

	private readonly Harmony harmony = new Harmony("com.nandor.fenrircurse");

	public static SE_FenrirCurse curseSE;

	public static SE_Stats formBuffSE;

	public static SE_FenrirCure cureSE;

	public static SE_EnhancedCurse enhancedCurseSE;

	public static SE_Stats enhancedFormBuffSE;

	public static SE_CurseBerry curseBerrySE;

	public static SE_Stats wolfFormBuffSE;

	private GameObject currentTransformation;

	private bool isTransformed;

	private bool isTransformingSequence;

	public static FenrirCurseMod Instance;

	private void Awake()
	{
		Instance = this;
		harmony.PatchAll();
		PrefabManager.OnVanillaPrefabsAvailable += CreateAllModAssets;
	}

	private void CreateAllModAssets()
	{
		//IL_0055: 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_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Expected O, but got Unknown
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Expected O, but got Unknown
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Expected O, but got Unknown
		//IL_0228: 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_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c6: Expected O, but got Unknown
		//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_035f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0369: Expected O, but got Unknown
		//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ee: Expected O, but got Unknown
		//IL_0431: Unknown result type (might be due to invalid IL or missing references)
		//IL_043b: Expected O, but got Unknown
		//IL_0446: Unknown result type (might be due to invalid IL or missing references)
		//IL_044c: Expected O, but got Unknown
		//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fc: Expected O, but got Unknown
		//IL_055a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0561: Expected O, but got Unknown
		//IL_058b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0590: Unknown result type (might be due to invalid IL or missing references)
		//IL_059b: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a3: Expected O, but got Unknown
		//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05bd: Expected O, but got Unknown
		//IL_05bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d7: Expected O, but got Unknown
		//IL_05de: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e5: Expected O, but got Unknown
		PrefabManager.OnVanillaPrefabsAvailable -= CreateAllModAssets;
		curseSE = ScriptableObject.CreateInstance<SE_FenrirCurse>();
		((Object)curseSE).name = "SE_FenrirCurse";
		((StatusEffect)curseSE).m_name = "Fenrir's Curse";
		((StatusEffect)curseSE).m_tooltip = "You feel the beast's blood. You can transform at night.";
		((SE_Stats)curseSE).m_mods = new List<DamageModPair>
		{
			new DamageModPair
			{
				m_type = (DamageType)512,
				m_modifier = (DamageModifier)2
			}
		};
		ItemDrop prefab = Cache.GetPrefab<ItemDrop>("TrophyFenring");
		GameObject val = ((prefab != null) ? ((Component)prefab).gameObject : null);
		if ((Object)(object)val != (Object)null)
		{
			ItemDrop component = val.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null && component.m_itemData.m_shared.m_icons.Length != 0)
			{
				((StatusEffect)curseSE).m_icon = component.m_itemData.m_shared.m_icons[0];
			}
		}
		ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)curseSE, false));
		formBuffSE = ScriptableObject.CreateInstance<SE_Stats>();
		((Object)formBuffSE).name = "SE_FenrirForm";
		((StatusEffect)formBuffSE).m_name = "Bestial Fury";
		formBuffSE.m_speedModifier = 1f;
		formBuffSE.m_jumpModifier = new Vector3(0f, 1f, 0f);
		formBuffSE.m_fallDamageModifier = -1f;
		formBuffSE.m_staminaRegenMultiplier = 1.3f;
		formBuffSE.m_runStaminaDrainModifier = -0.2f;
		((StatusEffect)formBuffSE).m_icon = null;
		ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)formBuffSE, false));
		cureSE = ScriptableObject.CreateInstance<SE_FenrirCure>();
		((Object)cureSE).name = "SE_FenrirCure";
		((StatusEffect)cureSE).m_name = "Purification";
		((StatusEffect)cureSE).m_ttl = 1f;
		ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)cureSE, false));
		enhancedCurseSE = ScriptableObject.CreateInstance<SE_EnhancedCurse>();
		((Object)enhancedCurseSE).name = "SE_EnhancedCurse";
		((StatusEffect)enhancedCurseSE).m_name = "Enhanced Curse";
		((StatusEffect)enhancedCurseSE).m_tooltip = "The beast's blood boils. You can transform into a Cultist at night.";
		((SE_Stats)enhancedCurseSE).m_mods = new List<DamageModPair>
		{
			new DamageModPair
			{
				m_type = (DamageType)512,
				m_modifier = (DamageModifier)2
			}
		};
		ItemDrop prefab2 = Cache.GetPrefab<ItemDrop>("TrophyCultist");
		GameObject val2 = ((prefab2 != null) ? ((Component)prefab2).gameObject : null);
		if ((Object)(object)val2 != (Object)null)
		{
			ItemDrop component2 = val2.GetComponent<ItemDrop>();
			if ((Object)(object)component2 != (Object)null && component2.m_itemData.m_shared.m_icons.Length != 0)
			{
				((StatusEffect)enhancedCurseSE).m_icon = component2.m_itemData.m_shared.m_icons[0];
			}
		}
		ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)enhancedCurseSE, false));
		enhancedFormBuffSE = ScriptableObject.CreateInstance<SE_Stats>();
		((Object)enhancedFormBuffSE).name = "SE_EnhancedForm";
		((StatusEffect)enhancedFormBuffSE).m_name = "Cultist Fury";
		enhancedFormBuffSE.m_speedModifier = 1f;
		enhancedFormBuffSE.m_jumpModifier = new Vector3(0f, 1f, 0f);
		enhancedFormBuffSE.m_fallDamageModifier = -1f;
		enhancedFormBuffSE.m_staminaRegenMultiplier = 1.3f;
		enhancedFormBuffSE.m_runStaminaDrainModifier = -0.2f;
		((StatusEffect)enhancedFormBuffSE).m_icon = null;
		ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)enhancedFormBuffSE, false));
		wolfFormBuffSE = ScriptableObject.CreateInstance<SE_Stats>();
		((Object)wolfFormBuffSE).name = "SE_WolfForm";
		((StatusEffect)wolfFormBuffSE).m_name = "Wolf Senses";
		wolfFormBuffSE.m_speedModifier = 0.5f;
		wolfFormBuffSE.m_fallDamageModifier = -0.5f;
		wolfFormBuffSE.m_staminaRegenMultiplier = 1.3f;
		wolfFormBuffSE.m_runStaminaDrainModifier = -0.2f;
		((StatusEffect)wolfFormBuffSE).m_icon = null;
		ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)wolfFormBuffSE, false));
		curseBerrySE = ScriptableObject.CreateInstance<SE_CurseBerry>();
		((Object)curseBerrySE).name = "SE_CurseBerry";
		((StatusEffect)curseBerrySE).m_name = "Curse Infection";
		((StatusEffect)curseBerrySE).m_ttl = 1f;
		ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)curseBerrySE, false));
		CustomItem val3 = new CustomItem("Curseberry", "Raspberry");
		if ((Object)(object)val3.ItemPrefab != (Object)null)
		{
			ItemDrop itemDrop = val3.ItemDrop;
			itemDrop.m_itemData.m_shared.m_name = "Curseberry (TEST)";
			itemDrop.m_itemData.m_shared.m_description = "Infects you with the permanent curse.";
			itemDrop.m_itemData.m_shared.m_food = 0f;
			itemDrop.m_itemData.m_shared.m_foodStamina = 0f;
			itemDrop.m_itemData.m_shared.m_foodEitr = 0f;
			itemDrop.m_itemData.m_shared.m_consumeStatusEffect = (StatusEffect)(object)curseBerrySE;
		}
		ItemManager.Instance.AddItem(val3);
		CustomItem val4 = new CustomItem("Potion_FenrirCure", "MeadFrostResist");
		if ((Object)(object)val4.ItemPrefab != (Object)null)
		{
			ItemDrop itemDrop2 = val4.ItemDrop;
			itemDrop2.m_itemData.m_shared.m_name = "Purifying Potion";
			itemDrop2.m_itemData.m_shared.m_description = "Permanently removes Fenrir's curse.";
			itemDrop2.m_itemData.m_shared.m_consumeStatusEffect = (StatusEffect)(object)cureSE;
		}
		ItemManager.Instance.AddItem(val4);
		RecipeConfig val5 = new RecipeConfig();
		val5.Item = "Potion_FenrirCure";
		val5.CraftingStation = "piece_cauldron";
		val5.Amount = 1;
		val5.Requirements = (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig
			{
				Item = "MeadBaseFrostResist",
				Amount = 1
			},
			new RequirementConfig
			{
				Item = "Onion",
				Amount = 5
			},
			new RequirementConfig
			{
				Item = "Silver",
				Amount = 1
			}
		};
		CustomRecipe val6 = new CustomRecipe(val5);
		ItemManager.Instance.AddRecipe(val6);
		FenrirWhiteberry.Register();
	}

	private void Update()
	{
		if (isTransformed && !isTransformingSequence && (Object)(object)currentTransformation == (Object)null)
		{
			isTransformed = false;
		}
		if (!isTransformingSequence && FenrirInput.KeyDown((KeyCode)103))
		{
			TryTransform(isCanineForm: false);
		}
		if (!isTransformingSequence && FenrirInput.KeyDown((KeyCode)104))
		{
			TryTransform(isCanineForm: true);
		}
	}

	private void TryTransform(bool isCanineForm)
	{
		if ((Object)(object)EnvMan.instance == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		bool num = ((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirCurse"));
		bool flag = ((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_EnhancedCurse"));
		if (!(num || flag))
		{
			return;
		}
		if (isCanineForm)
		{
			if (!isTransformed)
			{
				((MonoBehaviour)this).StartCoroutine(TransformIntoWolfRoutine(isCanineForm: true));
			}
			else
			{
				((MonoBehaviour)this).StartCoroutine(RevertToHumanRoutine());
			}
			return;
		}
		if (EnvMan.IsNight())
		{
			if (!isTransformed)
			{
				((MonoBehaviour)this).StartCoroutine(TransformIntoWolfRoutine());
			}
			else
			{
				((MonoBehaviour)this).StartCoroutine(RevertToHumanRoutine());
			}
			return;
		}
		if (isTransformed)
		{
			((MonoBehaviour)this).StartCoroutine(RevertToHumanRoutine());
		}
		((Character)Player.m_localPlayer).Message((MessageType)2, "The beast rests. You can only transform at night.", 0, (Sprite)null, false);
	}

	public void ForceRevert()
	{
		if (isTransformed && !isTransformingSequence)
		{
			((MonoBehaviour)this).StartCoroutine(RevertToHumanRoutine());
		}
	}

	private IEnumerator TransformIntoWolfRoutine(bool isCanineForm = false)
	{
		isTransformingSequence = true;
		ZSyncAnimation component = ((Component)Player.m_localPlayer).GetComponent<ZSyncAnimation>();
		if ((Object)(object)component != (Object)null)
		{
			FenrirInput.SuppressGuardianPowerBriefly();
			component.SetTrigger("gpower");
		}
		yield return (object)new WaitForSeconds(1.1f);
		SpawnPoofEffect();
		if ((Object)(object)ZNetScene.instance != (Object)null)
		{
			GameObject val = ZNetScene.instance.GetPrefab("sfx_wolf_howl") ?? ZNetScene.instance.GetPrefab("sfx_fenring_idle");
			if ((Object)(object)val != (Object)null)
			{
				Object.Instantiate<GameObject>(val, ((Component)Player.m_localPlayer).transform.position, Quaternion.identity);
			}
		}
		yield return (object)new WaitForSeconds(0.1f);
		ExecuteTransformation(isCanineForm);
		bool flag = ((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_EnhancedCurse"));
		if ((Object)(object)currentTransformation != (Object)null && (Object)(object)currentTransformation.GetComponent<WolfFormBehavior>() == (Object)null && (Object)(object)currentTransformation.GetComponent<UlvFormBehavior>() == (Object)null)
		{
			float elapsed = 0f;
			float duration = 0.5f;
			float num = (flag ? 0.75f : 0.5f);
			Vector3 startScale = Vector3.one * num;
			Vector3 endScale = Vector3.one;
			currentTransformation.transform.localScale = startScale;
			while (elapsed < duration && !((Object)(object)currentTransformation == (Object)null))
			{
				currentTransformation.transform.localScale = Vector3.Lerp(startScale, endScale, elapsed / duration);
				elapsed += Time.deltaTime;
				yield return null;
			}
			if ((Object)(object)currentTransformation != (Object)null)
			{
				currentTransformation.transform.localScale = endScale;
			}
		}
		isTransformingSequence = false;
	}

	private IEnumerator RevertToHumanRoutine()
	{
		isTransformingSequence = true;
		if ((Object)(object)currentTransformation != (Object)null)
		{
			FenrirFormBehavior component = currentTransformation.GetComponent<FenrirFormBehavior>();
			if ((Object)(object)component != (Object)null)
			{
				((Behaviour)component).enabled = false;
			}
			CultistFormBehavior component2 = currentTransformation.GetComponent<CultistFormBehavior>();
			if ((Object)(object)component2 != (Object)null)
			{
				((Behaviour)component2).enabled = false;
			}
			WolfFormBehavior component3 = currentTransformation.GetComponent<WolfFormBehavior>();
			if ((Object)(object)component3 != (Object)null)
			{
				((Behaviour)component3).enabled = false;
			}
			UlvFormBehavior component4 = currentTransformation.GetComponent<UlvFormBehavior>();
			if ((Object)(object)component4 != (Object)null)
			{
				((Behaviour)component4).enabled = false;
			}
			if ((Object)(object)component3 == (Object)null && (Object)(object)component4 == (Object)null)
			{
				float elapsed = 0f;
				float duration = 0.5f;
				Vector3 startScale = currentTransformation.transform.localScale;
				float num = (((Object)(object)component2 != (Object)null) ? 0.75f : 0.5f);
				Vector3 endScale = startScale * num;
				while (elapsed < duration && !((Object)(object)currentTransformation == (Object)null))
				{
					currentTransformation.transform.localScale = Vector3.Lerp(startScale, endScale, elapsed / duration);
					elapsed += Time.deltaTime;
					yield return null;
				}
			}
		}
		SpawnPoofEffect();
		yield return (object)new WaitForSeconds(0.1f);
		ExecuteReversion();
		isTransformingSequence = false;
	}

	private void SpawnPoofEffect()
	{
		//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_0022: 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_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: 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)
		if (!((Object)(object)Player.m_localPlayer == (Object)null))
		{
			Vector3 val = ((Component)Player.m_localPlayer).transform.position + Vector3.up;
			GameObject prefab = Cache.GetPrefab<GameObject>("vfx_corpse_destruction");
			if ((Object)(object)prefab != (Object)null)
			{
				Object.Instantiate<GameObject>(prefab, val, Quaternion.identity);
			}
			GameObject prefab2 = Cache.GetPrefab<GameObject>("vfx_HitSparks");
			if ((Object)(object)prefab2 != (Object)null)
			{
				Object.Instantiate<GameObject>(prefab2, val, Quaternion.identity);
			}
		}
	}

	private void ExecuteTransformation(bool isCanineForm = false)
	{
		//IL_009e: 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_00f8: 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)
		Transform val = ((Component)Player.m_localPlayer).transform.Find("Visual");
		bool flag = ((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_EnhancedCurse"));
		string text = "";
		text = (isCanineForm ? ((!flag) ? "Wolf" : "Ulv") : (flag ? (FenrirWhiteberry.IsActive(Player.m_localPlayer) ? "Fenring_Cultist_Hildir" : "Fenring_Cultist") : ((!EnvMan.IsNight()) ? "Wolf" : "Fenring")));
		GameObject prefab = Cache.GetPrefab<GameObject>(text);
		if (!((Object)(object)prefab != (Object)null) || !((Object)(object)val != (Object)null))
		{
			return;
		}
		val.localScale = Vector3.one * 0.001f;
		Transform val2 = prefab.transform.Find("Visual");
		if ((Object)(object)val2 != (Object)null)
		{
			currentTransformation = Object.Instantiate<GameObject>(((Component)val2).gameObject, ((Component)Player.m_localPlayer).transform);
			currentTransformation.transform.localPosition = Vector3.zero;
			currentTransformation.transform.localRotation = Quaternion.identity;
			Component component = currentTransformation.GetComponent("AnimEvent");
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			if (text == "Ulv")
			{
				currentTransformation.AddComponent<UlvFormBehavior>();
				((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_WolfForm"), true, 0, 0f, (short)(-1));
				((Character)Player.m_localPlayer).Message((MessageType)2, "You are an Ulv!", 0, (Sprite)null, false);
			}
			else if (text == "Wolf")
			{
				currentTransformation.AddComponent<WolfFormBehavior>();
				((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_WolfForm"), true, 0, 0f, (short)(-1));
				((Character)Player.m_localPlayer).Message((MessageType)2, "You are a Wolf!", 0, (Sprite)null, false);
			}
			else if (flag)
			{
				currentTransformation.AddComponent<CultistFormBehavior>();
				((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_EnhancedForm"), true, 0, 0f, (short)(-1));
				((Character)Player.m_localPlayer).Message((MessageType)2, "You are a Cultist!", 0, (Sprite)null, false);
			}
			else
			{
				currentTransformation.AddComponent<FenrirFormBehavior>();
				((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirForm"), true, 0, 0f, (short)(-1));
				((Character)Player.m_localPlayer).Message((MessageType)2, "You are a Fenring!", 0, (Sprite)null, false);
			}
			isTransformed = true;
			FenrirNet.SetForm(text);
		}
	}

	private void ExecuteReversion()
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		Transform val = ((Component)Player.m_localPlayer).transform.Find("Visual");
		if ((Object)(object)currentTransformation != (Object)null)
		{
			Object.Destroy((Object)(object)currentTransformation);
		}
		if ((Object)(object)val != (Object)null)
		{
			val.localScale = Vector3.one;
			((Component)val).gameObject.SetActive(true);
		}
		FenrirNet.SetFire(on: false);
		FenrirNet.SetForm("");
		((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirForm"), false);
		((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_EnhancedForm"), false);
		((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_WolfForm"), false);
		isTransformed = false;
		((Character)Player.m_localPlayer).Message((MessageType)2, "You returned to human form.", 0, (Sprite)null, false);
	}
}
[HarmonyPatch(typeof(Character), "StartAttack")]
public static class BlockPlayerLogicAttackPatch
{
	public static bool Prefix(Character __instance)
	{
		if ((Object)(object)__instance != (Object)null && (Object)(object)__instance == (Object)(object)Player.m_localPlayer && (__instance.GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirForm")) || __instance.GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_EnhancedForm"))))
		{
			return false;
		}
		return true;
	}
}
[HarmonyPatch(typeof(ZSyncAnimation), "SetTrigger")]
public static class BlockPlayerAnimationsPatch
{
	public static bool Prefix(ZSyncAnimation __instance, string name)
	{
		if ((Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)((Component)__instance).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject && (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirForm")) || ((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_EnhancedForm"))))
		{
			string text = name.ToLower();
			if (text.Contains("attack") || text.Contains("swing") || text.Contains("punch"))
			{
				return false;
			}
		}
		return true;
	}
}
public class SE_FenrirCurse : SE_Stats
{
	public override void Setup(Character character)
	{
		((SE_Stats)this).Setup(character);
		if ((Object)(object)character == (Object)(object)Player.m_localPlayer)
		{
			Player.m_localPlayer.m_customData["FenrirCurse_Active"] = "true";
			FenrirCompendium.Refresh(Player.m_localPlayer);
		}
	}
}
public class SE_FenrirCure : StatusEffect
{
	public override void Setup(Character character)
	{
		((StatusEffect)this).Setup(character);
		if ((Object)(object)character == (Object)(object)Player.m_localPlayer)
		{
			Player.m_localPlayer.m_customData.Remove("FenrirCurse_Active");
			Player.m_localPlayer.m_customData.Remove("EnhancedCurse_Active");
			Player.m_localPlayer.m_customData.Remove("WhiteBerry_Active");
			FenrirCompendium.Refresh(Player.m_localPlayer);
			((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirCurse"), false);
			((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_EnhancedCurse"), false);
			((Character)Player.m_localPlayer).Message((MessageType)2, "The curse has been broken.", 0, (Sprite)null, false);
			if ((Object)(object)FenrirCurseMod.Instance != (Object)null)
			{
				FenrirCurseMod.Instance.ForceRevert();
			}
		}
	}
}
public class SE_EnhancedCurse : SE_Stats
{
	public override void Setup(Character character)
	{
		((SE_Stats)this).Setup(character);
		if ((Object)(object)character == (Object)(object)Player.m_localPlayer)
		{
			Player.m_localPlayer.m_customData["EnhancedCurse_Active"] = "true";
			Player.m_localPlayer.m_customData.Remove("FenrirCurse_Active");
			FenrirCompendium.Refresh(Player.m_localPlayer);
		}
	}
}
public class SE_CurseBerry : StatusEffect
{
	public override void Setup(Character character)
	{
		((StatusEffect)this).Setup(character);
		if ((Object)(object)character == (Object)(object)Player.m_localPlayer)
		{
			if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirCurse")))
			{
				((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirCurse"), false);
				((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_EnhancedCurse"), true, 0, 0f, (short)(-1));
				((Character)Player.m_localPlayer).Message((MessageType)2, "Curse Empowered", 0, (Sprite)null, false);
			}
			else if (!((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_EnhancedCurse")))
			{
				((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirCurse"), true, 0, 0f, (short)(-1));
			}
		}
	}
}
[HarmonyPatch(typeof(Player), "OnSpawned")]
public static class PlayerSpawnPatch
{
	public static void Postfix(Player __instance)
	{
		if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer)
		{
			FenrirCompendium.Refresh(__instance);
			if (__instance.m_customData.ContainsKey("FenrirCurse_Active") && __instance.m_customData["FenrirCurse_Active"] == "true")
			{
				((Character)__instance).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirCurse"), true, 0, 0f, (short)(-1));
			}
			if (__instance.m_customData.ContainsKey("EnhancedCurse_Active") && __instance.m_customData["EnhancedCurse_Active"] == "true")
			{
				((Character)__instance).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_EnhancedCurse"), true, 0, 0f, (short)(-1));
			}
		}
	}
}
[HarmonyPatch(typeof(Player), "UpdateHover")]
public static class KvasturInteractPatch
{
	public static void Postfix(Player __instance)
	{
		//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_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		if (!ZInput.GetButtonDown("Use"))
		{
			return;
		}
		GameObject hoverObject = ((Humanoid)__instance).GetHoverObject();
		if ((Object)(object)hoverObject != (Object)null && ((Object)hoverObject).name.Contains("Kvastur") && ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirCurse")))
		{
			__instance.m_customData.TryGetValue("KvasturDialogState", out var value);
			if (string.IsNullOrEmpty(value))
			{
				value = "0";
			}
			if (value == "0")
			{
				Chat.instance.SetNpcText(hoverObject, Vector3.up * 1.5f, 20f, 5f, "Kvastur", "Wait! I've seen this before! You have a curse on yourself!", false);
				__instance.m_customData["KvasturDialogState"] = "1";
			}
			else if (value == "1")
			{
				Chat.instance.SetNpcText(hoverObject, Vector3.up * 1.5f, 20f, 5f, "Kvastur", "Bring me the head of a cultist and i'll unlock your true power!", false);
				__instance.m_customData["KvasturDialogState"] = "0";
			}
		}
	}
}
[HarmonyPatch(typeof(Player), "UseHotbarItem")]
public static class KvasturUseItemPatch
{
	public static bool Prefix(Player __instance, int index)
	{
		ItemData itemAt = ((Humanoid)__instance).GetInventory().GetItemAt(index - 1, 0);
		if (itemAt != null && (Object)(object)itemAt.m_dropPrefab != (Object)null && ((Object)itemAt.m_dropPrefab).name == "TrophyCultist")
		{
			GameObject hoverObject = ((Humanoid)__instance).GetHoverObject();
			if ((Object)(object)hoverObject != (Object)null && ((Object)hoverObject).name.Contains("Kvastur") && ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirCurse")))
			{
				((Humanoid)__instance).GetInventory().RemoveItem(itemAt, 1);
				((Character)__instance).Message((MessageType)2, "Curse Empowered", 0, (Sprite)null, false);
				((Character)__instance).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirCurse"), false);
				((Character)__instance).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_EnhancedCurse"), true, 0, 0f, (short)(-1));
				return false;
			}
		}
		return true;
	}
}
[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
public static class EnhancedFormEitrPatch
{
	public static void Postfix(Player __instance, ref float hp, ref float stamina, ref float eitr)
	{
		if ((Object)(object)__instance != (Object)null && ((Character)__instance).GetSEMan() != null && ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_EnhancedForm")))
		{
			eitr += 50f;
		}
	}
}
public class FenrirFormBehavior : MonoBehaviour
{
	private Animator playerAnim;

	private Animator fenrirAnim;

	private bool isAttacking;

	private void Start()
	{
		playerAnim = ((Component)((Component)Player.m_localPlayer).transform.Find("Visual")).GetComponent<Animator>();
		fenrirAnim = ((Component)this).GetComponent<Animator>();
		if ((Object)(object)fenrirAnim == (Object)null)
		{
			fenrirAnim = ((Component)this).GetComponentInChildren<Animator>();
		}
	}

	private void Update()
	{
		if ((Object)(object)playerAnim == (Object)null || (Object)(object)fenrirAnim == (Object)null || isAttacking)
		{
			return;
		}
		bool flag = playerAnim.GetBool("onGround");
		fenrirAnim.SetBool("onGround", flag);
		fenrirAnim.SetBool("inWater", playerAnim.GetBool("inWater"));
		if (!flag)
		{
			fenrirAnim.SetFloat("forward_speed", 0f);
			fenrirAnim.SetFloat("sideway_speed", 0f);
		}
		else if (((Character)Player.m_localPlayer).IsCrouching())
		{
			fenrirAnim.SetFloat("forward_speed", 0f);
			fenrirAnim.SetFloat("sideway_speed", 0f);
		}
		else
		{
			fenrirAnim.SetFloat("forward_speed", playerAnim.GetFloat("forward_speed"));
			fenrirAnim.SetFloat("sideway_speed", playerAnim.GetFloat("sideway_speed"));
		}
		if (flag)
		{
			if (FenrirInput.KeyDown((KeyCode)111))
			{
				((MonoBehaviour)this).StartCoroutine(HowlRoutine());
			}
			else if (FenrirInput.AttackDown(1))
			{
				((MonoBehaviour)this).StartCoroutine(ClawRoutine("attack_claw1", 110f, 1.2f, 0.5f));
			}
			else if (FenrirInput.AttackDown(0))
			{
				((MonoBehaviour)this).StartCoroutine(ClawRoutine("attack_claw0", 60f, 1f, 0.4f));
			}
			else if (FenrirInput.AttackDown(2))
			{
				((MonoBehaviour)this).StartCoroutine(JumpAttackRoutine());
			}
		}
	}

	private void PlaySFX(params string[] prefabNames)
	{
		if (!FenrirNet.PlayFx(prefabNames))
		{
			Logger.LogWarning((object)("[FenrirForm] Nessun suono trovato tra: " + string.Join(", ", prefabNames)));
		}
	}

	private IEnumerator HowlRoutine()
	{
		isAttacking = true;
		fenrirAnim.SetFloat("forward_speed", 0f);
		fenrirAnim.SetFloat("sideway_speed", 0f);
		FenrirNet.Trigger(fenrirAnim, "attack_taunt");
		PlaySFX("sfx_wolf_howl", "sfx_wolf_alert", "sfx_fenring_idle");
		yield return (object)new WaitForSeconds(2f);
		isAttacking = false;
	}

	private IEnumerator ClawRoutine(string triggerName, float baseDamage, float lockDuration, float dmgDelay)
	{
		isAttacking = true;
		fenrirAnim.SetFloat("forward_speed", 0f);
		fenrirAnim.SetFloat("sideway_speed", 0f);
		FenrirNet.Trigger(fenrirAnim, triggerName);
		PlaySFX("sfx_fenring_attack", "sfx_fenring_attack_claw", "sfx_wolf_attack");
		yield return (object)new WaitForSeconds(dmgDelay);
		FenrirNet.PlayFx("sfx_fenring_attack");
		ExecuteClawDamage(baseDamage);
		float num = lockDuration - dmgDelay;
		if (num > 0f)
		{
			yield return (object)new WaitForSeconds(num);
		}
		fenrirAnim.ResetTrigger(triggerName);
		isAttacking = false;
	}

	private IEnumerator JumpAttackRoutine()
	{
		isAttacking = true;
		fenrirAnim.SetFloat("forward_speed", 0f);
		fenrirAnim.SetFloat("sideway_speed", 0f);
		FenrirNet.Trigger(fenrirAnim, "attack_jump");
		yield return (object)new WaitForSeconds(0.75f);
		FenrirNet.PlayFx("sfx_fenring_attack");
		float dashDuration = 0.2f;
		float elapsedDash = 0f;
		while (elapsedDash < dashDuration)
		{
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				Rigidbody component = ((Component)Player.m_localPlayer).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					Vector3 val = ((Component)Player.m_localPlayer).transform.forward * 31.5f;
					if (elapsedDash < dashDuration / 2f)
					{
						val += Vector3.up * 13.1f;
					}
					component.MovePosition(component.position + val * Time.fixedDeltaTime);
				}
			}
			elapsedDash += Time.fixedDeltaTime;
			yield return (object)new WaitForFixedUpdate();
		}
		ExecuteClawDamage(95f);
		yield return (object)new WaitForSeconds(0.55f);
		fenrirAnim.ResetTrigger("attack_jump");
		isAttacking = false;
	}

	private void ExecuteClawDamage(float baseDamage)
	{
		//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_001e: 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_0033: 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_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_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: 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_01f6: 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_0201: 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_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Expected O, but got Unknown
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: 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_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: 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)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		Vector3 position = ((Component)Player.m_localPlayer).transform.position;
		Vector3 val = position + ((Component)Player.m_localPlayer).transform.forward * 1.5f + Vector3.up * 1f;
		float num = 2.5f;
		float skillLevel = ((Character)Player.m_localPlayer).GetSkillLevel((SkillType)11);
		float slash = baseDamage + skillLevel;
		int mask = LayerMask.GetMask(new string[12]
		{
			"Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox",
			"character_noenv", "vehicle"
		});
		Collider[] array = Physics.OverlapSphere(val, num, mask);
		HashSet<GameObject> hashSet = new HashSet<GameObject>();
		Collider[] array2 = array;
		RaycastHit val6 = default(RaycastHit);
		foreach (Collider val2 in array2)
		{
			if ((Object)(object)((Component)val2).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject || ((Object)(object)val2.attachedRigidbody != (Object)null && (Object)(object)((Component)val2.attachedRigidbody).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject))
			{
				continue;
			}
			IDestructible componentInParent = ((Component)val2).GetComponentInParent<IDestructible>();
			if (componentInParent == null)
			{
				continue;
			}
			Character val3 = (Character)(object)((componentInParent is Character) ? componentInParent : null);
			if ((Object)(object)val3 != (Object)null && (Object)(object)val3 == (Object)(object)Player.m_localPlayer)
			{
				continue;
			}
			IDestructible obj = ((componentInParent is MonoBehaviour) ? componentInParent : null);
			GameObject val4 = ((obj != null) ? ((Component)obj).gameObject : null);
			if ((Object)(object)val4 != (Object)null)
			{
				if (hashSet.Contains(val4))
				{
					continue;
				}
				hashSet.Add(val4);
			}
			Bounds bounds = val2.bounds;
			Vector3 center = ((Bounds)(ref bounds)).center;
			Vector3 val5 = center - position;
			Vector3 normalized = ((Vector3)(ref val5)).normalized;
			if (Vector3.Angle(((Component)Player.m_localPlayer).transform.forward, normalized) < 70f && !Physics.Linecast(position + Vector3.up * 1.5f, center, ref val6, LayerMask.GetMask(new string[4] { "Default", "static_solid", "terrain", "piece" })))
			{
				HitData val7 = new HitData();
				val7.m_damage.m_slash = slash;
				val7.m_pushForce = 30f;
				val7.m_point = center;
				val7.m_dir = ((Component)Player.m_localPlayer).transform.forward;
				val7.m_skill = (SkillType)11;
				val7.m_dodgeable = true;
				val7.m_blockable = true;
				val7.m_hitType = (HitType)2;
				val7.m_toolTier = 0;
				val7.SetAttacker((Character)(object)Player.m_localPlayer);
				componentInParent.Damage(val7);
			}
		}
	}
}
public class CultistFormBehavior : MonoBehaviour
{
	private Animator playerAnim;

	private Animator cultistAnim;

	private bool isAttacking;

	private bool isShootingFire;

	private float fireTimer;

	private GameObject fireEffectInstance;

	private void Start()
	{
		playerAnim = ((Component)((Component)Player.m_localPlayer).transform.Find("Visual")).GetComponent<Animator>();
		cultistAnim = ((Component)this).GetComponent<Animator>();
		if ((Object)(object)cultistAnim == (Object)null)
		{
			cultistAnim = ((Component)this).GetComponentInChildren<Animator>();
		}
	}

	private void Update()
	{
		if ((Object)(object)playerAnim == (Object)null || (Object)(object)cultistAnim == (Object)null || isAttacking)
		{
			return;
		}
		bool flag = playerAnim.GetBool("onGround");
		cultistAnim.SetBool("onGround", flag);
		cultistAnim.SetBool("inWater", playerAnim.GetBool("inWater"));
		if (!flag)
		{
			cultistAnim.SetFloat("forward_speed", 0f);
			cultistAnim.SetFloat("sideway_speed", 0f);
		}
		else if (((Character)Player.m_localPlayer).IsCrouching())
		{
			cultistAnim.SetFloat("forward_speed", 0f);
			cultistAnim.SetFloat("sideway_speed", 0f);
		}
		else
		{
			cultistAnim.SetFloat("forward_speed", playerAnim.GetFloat("forward_speed"));
			cultistAnim.SetFloat("sideway_speed", playerAnim.GetFloat("sideway_speed"));
		}
		if (flag)
		{
			if (FenrirInput.AttackHeld(1))
			{
				if (Player.m_localPlayer.GetEitr() > 0f)
				{
					if (!isShootingFire)
					{
						StartFire();
					}
					else
					{
						UpdateFire();
					}
				}
				else if (isShootingFire)
				{
					StopFire();
				}
			}
			else if (isShootingFire)
			{
				StopFire();
			}
			if (FenrirInput.KeyDown((KeyCode)111))
			{
				((MonoBehaviour)this).StartCoroutine(HowlRoutine());
			}
			if (FenrirInput.AttackDown(0) && !isShootingFire)
			{
				((MonoBehaviour)this).StartCoroutine(ClawRoutine());
			}
			else if (FenrirInput.AttackDown(2) && !isShootingFire)
			{
				((MonoBehaviour)this).StartCoroutine(DoubleClawRoutine());
			}
		}
		else if (isShootingFire)
		{
			StopFire();
		}
	}

	private void PlaySFX(params string[] prefabNames)
	{
		if (!FenrirNet.PlayFx(prefabNames))
		{
			Logger.LogWarning((object)("[CultistForm] Nessun suono trovato tra: " + string.Join(", ", prefabNames)));
		}
	}

	private IEnumerator HowlRoutine()
	{
		isAttacking = true;
		cultistAnim.SetFloat("forward_speed", 0f);
		cultistAnim.SetFloat("sideway_speed", 0f);
		FenrirNet.Trigger(cultistAnim, "attack_taunt");
		PlaySFX("sfx_wolf_howl", "sfx_wolf_alert", "sfx_fenring_idle");
		yield return (object)new WaitForSeconds(2f);
		isAttacking = false;
	}

	private void StartFire()
	{
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null || isShootingFire)
		{
			return;
		}
		isShootingFire = true;
		cultistAnim.SetFloat("forward_speed", 0f);
		cultistAnim.SetFloat("sideway_speed", 0f);
		cultistAnim.SetBool("attack_fire", true);
		PlaySFX("sfx_cultist_attack_fire_start");
		FenrirNet.Trigger(cultistAnim, "attack_flames");
		FenrirNet.SetFire(on: true);
		if (!((Object)(object)ZNetScene.instance != (Object)null) || !((Object)(object)fireEffectInstance == (Object)null))
		{
			return;
		}
		GameObject prefab = ZNetScene.instance.GetPrefab("fx_fenring_flames");
		if ((Object)(object)prefab != (Object)null)
		{
			fireEffectInstance = Object.Instantiate<GameObject>(prefab, ((Component)Player.m_localPlayer).transform.position + Vector3.up * 1.5f + ((Component)Player.m_localPlayer).transform.forward, ((Component)Player.m_localPlayer).transform.rotation, ((Component)Player.m_localPlayer).transform);
			ParticleSystem[] componentsInChildren = fireEffectInstance.GetComponentsInChildren<ParticleSystem>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				MainModule main = componentsInChildren[i].main;
				((MainModule)(ref main)).startLifetimeMultiplier = ((MainModule)(ref main)).startLifetimeMultiplier * 1.2f;
			}
		}
	}

	private void UpdateFire()
	{
		((Character)Player.m_localPlayer).UseEitr(12.5f * Time.deltaTime);
		cultistAnim.SetFloat("forward_speed", 0f);
		cultistAnim.SetFloat("sideway_speed", 0f);
		fireTimer += Time.deltaTime;
		if (fireTimer >= 0.2f)
		{
			fireTimer = 0f;
			ExecuteFireDamage();
		}
	}

	private void OnDisable()
	{
		if (isShootingFire)
		{
			StopFire();
		}
	}

	private void StopFire()
	{
		isShootingFire = false;
		FenrirNet.SetFire(on: false);
		cultistAnim.ResetTrigger("attack_flames");
		if ((Object)(object)fireEffectInstance != (Object)null)
		{
			Object.Destroy((Object)(object)fireEffectInstance);
			fireEffectInstance = null;
		}
	}

	private void ExecuteFireDamage()
	{
		//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_001e: 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_0033: 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_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_00e5: 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_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_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: 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_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: 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_01ef: 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_0217: 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_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_0238: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0294: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		Vector3 position = ((Component)Player.m_localPlayer).transform.position;
		Vector3 val = position + ((Component)Player.m_localPlayer).transform.forward * 2.5f + Vector3.up * 1f;
		float num = 3f;
		float skillLevel = ((Character)Player.m_localPlayer).GetSkillLevel((SkillType)9);
		float fire = 20f + skillLevel * 0.5f;
		int mask = LayerMask.GetMask(new string[12]
		{
			"Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox",
			"character_noenv", "vehicle"
		});
		Collider[] array = Physics.OverlapSphere(val, num, mask);
		HashSet<GameObject> hashSet = new HashSet<GameObject>();
		Collider[] array2 = array;
		foreach (Collider val2 in array2)
		{
			if ((Object)(object)((Component)val2).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject || ((Object)(object)val2.attachedRigidbody != (Object)null && (Object)(object)((Component)val2.attachedRigidbody).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject))
			{
				continue;
			}
			IDestructible componentInParent = ((Component)val2).GetComponentInParent<IDestructible>();
			if (componentInParent == null)
			{
				continue;
			}
			Character val3 = (Character)(object)((componentInParent is Character) ? componentInParent : null);
			if ((Object)(object)val3 != (Object)null && (Object)(object)val3 == (Object)(object)Player.m_localPlayer)
			{
				continue;
			}
			IDestructible obj = ((componentInParent is MonoBehaviour) ? componentInParent : null);
			GameObject val4 = ((obj != null) ? ((Component)obj).gameObject : null);
			if ((Object)(object)val4 != (Object)null)
			{
				if (hashSet.Contains(val4))
				{
					continue;
				}
				hashSet.Add(val4);
			}
			Bounds bounds = val2.bounds;
			Vector3 center = ((Bounds)(ref bounds)).center;
			Vector3 val5 = center - position;
			Vector3 normalized = ((Vector3)(ref val5)).normalized;
			if (!(Vector3.Angle(((Component)Player.m_localPlayer).transform.forward, normalized) < 45f))
			{
				continue;
			}
			HitData val6 = new HitData();
			val6.m_damage.m_fire = fire;
			val6.m_point = center;
			val6.m_dir = ((Component)Player.m_localPlayer).transform.forward;
			val6.m_skill = (SkillType)9;
			val6.m_dodgeable = true;
			val6.m_blockable = true;
			val6.m_hitType = (HitType)2;
			val6.SetAttacker((Character)(object)Player.m_localPlayer);
			componentInParent.Damage(val6);
			if ((Object)(object)ZNetScene.instance != (Object)null)
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("vfx_FireballHit");
				if ((Object)(object)prefab != (Object)null)
				{
					Object.Instantiate<GameObject>(prefab, center, Quaternion.identity);
				}
			}
		}
	}

	private IEnumerator ClawRoutine()
	{
		isAttacking = true;
		cultistAnim.SetFloat("forward_speed", 0f);
		cultistAnim.SetFloat("sideway_speed", 0f);
		FenrirNet.Trigger(cultistAnim, "attack_claw");
		yield return (object)new WaitForSeconds(0.4f);
		PlaySFX("sfx_cultist_attack", "sfx_fenring_attack", "sfx_wolf_attack");
		ExecuteClawDamage(85f);
		float num = 0.099999994f;
		if (num > 0f)
		{
			yield return (object)new WaitForSeconds(num);
		}
		cultistAnim.ResetTrigger("attack_claw");
		isAttacking = false;
	}

	private IEnumerator DoubleClawRoutine()
	{
		isAttacking = true;
		cultistAnim.SetFloat("forward_speed", 0f);
		cultistAnim.SetFloat("sideway_speed", 0f);
		FenrirNet.Trigger(cultistAnim, "attack_claw_double");
		yield return (object)new WaitForSeconds(0.6f);
		PlaySFX("sfx_cultist_attack_double", "sfx_cultist_attack", "sfx_fenring_attack");
		ExecuteClawDamage(140f);
		yield return (object)new WaitForSeconds(1.2f);
		cultistAnim.ResetTrigger("attack_claw_double");
		isAttacking = false;
	}

	private void ExecuteClawDamage(float baseDamage)
	{
		//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_001e: 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_0033: 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_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_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: 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_01f6: 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_0201: 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_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Expected O, but got Unknown
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: 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_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: 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)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		Vector3 position = ((Component)Player.m_localPlayer).transform.position;
		Vector3 val = position + ((Component)Player.m_localPlayer).transform.forward * 1.5f + Vector3.up * 1f;
		float num = 2.5f;
		float skillLevel = ((Character)Player.m_localPlayer).GetSkillLevel((SkillType)11);
		float slash = baseDamage + skillLevel;
		int mask = LayerMask.GetMask(new string[12]
		{
			"Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox",
			"character_noenv", "vehicle"
		});
		Collider[] array = Physics.OverlapSphere(val, num, mask);
		HashSet<GameObject> hashSet = new HashSet<GameObject>();
		Collider[] array2 = array;
		RaycastHit val6 = default(RaycastHit);
		foreach (Collider val2 in array2)
		{
			if ((Object)(object)((Component)val2).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject || ((Object)(object)val2.attachedRigidbody != (Object)null && (Object)(object)((Component)val2.attachedRigidbody).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject))
			{
				continue;
			}
			IDestructible componentInParent = ((Component)val2).GetComponentInParent<IDestructible>();
			if (componentInParent == null)
			{
				continue;
			}
			Character val3 = (Character)(object)((componentInParent is Character) ? componentInParent : null);
			if ((Object)(object)val3 != (Object)null && (Object)(object)val3 == (Object)(object)Player.m_localPlayer)
			{
				continue;
			}
			IDestructible obj = ((componentInParent is MonoBehaviour) ? componentInParent : null);
			GameObject val4 = ((obj != null) ? ((Component)obj).gameObject : null);
			if ((Object)(object)val4 != (Object)null)
			{
				if (hashSet.Contains(val4))
				{
					continue;
				}
				hashSet.Add(val4);
			}
			Bounds bounds = val2.bounds;
			Vector3 center = ((Bounds)(ref bounds)).center;
			Vector3 val5 = center - position;
			Vector3 normalized = ((Vector3)(ref val5)).normalized;
			if (Vector3.Angle(((Component)Player.m_localPlayer).transform.forward, normalized) < 70f && !Physics.Linecast(position + Vector3.up * 1.5f, center, ref val6, LayerMask.GetMask(new string[4] { "Default", "static_solid", "terrain", "piece" })))
			{
				HitData val7 = new HitData();
				val7.m_damage.m_slash = slash;
				val7.m_pushForce = 30f;
				val7.m_point = center;
				val7.m_dir = ((Component)Player.m_localPlayer).transform.forward;
				val7.m_skill = (SkillType)11;
				val7.m_dodgeable = true;
				val7.m_blockable = true;
				val7.m_hitType = (HitType)2;
				val7.m_toolTier = 0;
				val7.SetAttacker((Character)(object)Player.m_localPlayer);
				componentInParent.Damage(val7);
			}
		}
	}
}
public class WolfFormBehavior : MonoBehaviour
{
	private Animator playerAnim;

	private Animator wolfAnim;

	private bool isAttacking;

	private void Start()
	{
		playerAnim = ((Component)((Component)Player.m_localPlayer).transform.Find("Visual")).GetComponent<Animator>();
		wolfAnim = ((Component)this).GetComponent<Animator>();
		if ((Object)(object)wolfAnim == (Object)null)
		{
			wolfAnim = ((Component)this).GetComponentInChildren<Animator>();
		}
	}

	private void Update()
	{
		if ((Object)(object)playerAnim == (Object)null || (Object)(object)wolfAnim == (Object)null || isAttacking)
		{
			return;
		}
		bool flag = playerAnim.GetBool("onGround");
		try
		{
			wolfAnim.SetBool("onGround", flag);
		}
		catch
		{
		}
		try
		{
			wolfAnim.SetBool("inWater", playerAnim.GetBool("inWater"));
		}
		catch
		{
		}
		if (!flag)
		{
			try
			{
				wolfAnim.SetFloat("forward_speed", 0f);
			}
			catch
			{
			}
			try
			{
				wolfAnim.SetFloat("sideway_speed", 0f);
			}
			catch
			{
			}
		}
		else if (((Character)Player.m_localPlayer).IsCrouching())
		{
			try
			{
				wolfAnim.SetFloat("forward_speed", 0f);
			}
			catch
			{
			}
			try
			{
				wolfAnim.SetFloat("sideway_speed", 0f);
			}
			catch
			{
			}
		}
		else
		{
			try
			{
				wolfAnim.SetFloat("forward_speed", playerAnim.GetFloat("forward_speed"));
			}
			catch
			{
			}
			try
			{
				wolfAnim.SetFloat("sideway_speed", playerAnim.GetFloat("sideway_speed"));
			}
			catch
			{
			}
		}
		if (flag)
		{
			if (FenrirInput.AttackDown(0))
			{
				((MonoBehaviour)this).StartCoroutine(WolfAttackRoutine("attack1", 40f, 0.6f, 0.2f));
			}
			else if (FenrirInput.AttackDown(1))
			{
				((MonoBehaviour)this).StartCoroutine(WolfAttackRoutine("attack2", 60f, 0.8f, 0.3f));
			}
			else if (FenrirInput.AttackDown(2))
			{
				((MonoBehaviour)this).StartCoroutine(WolfAttackRoutine("attack3", 80f, 1f, 0.4f));
			}
		}
	}

	private void PlaySFX(params string[] prefabNames)
	{
		FenrirNet.PlayFx(prefabNames);
	}

	private IEnumerator WolfAttackRoutine(string triggerName, float baseDamage, float lockDuration, float dmgDelay)
	{
		isAttacking = true;
		try
		{
			wolfAnim.SetFloat("forward_speed", 0f);
		}
		catch
		{
		}
		try
		{
			wolfAnim.SetFloat("sideway_speed", 0f);
		}
		catch
		{
		}
		FenrirNet.Trigger(wolfAnim, triggerName);
		yield return (object)new WaitForSeconds(dmgDelay);
		FenrirNet.PlayFx("sfx_wolf_attack");
		ExecuteBiteDamage(baseDamage);
		float num = lockDuration - dmgDelay;
		if (num > 0f)
		{
			yield return (object)new WaitForSeconds(num);
		}
		wolfAnim.ResetTrigger(triggerName);
		isAttacking = false;
	}

	private void ExecuteBiteDamage(float baseDamage)
	{
		//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_001e: 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_0033: 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_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_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: 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_01f6: 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_0201: 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_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Expected O, but got Unknown
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: 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_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: 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)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		Vector3 position = ((Component)Player.m_localPlayer).transform.position;
		Vector3 val = position + ((Component)Player.m_localPlayer).transform.forward * 1.5f + Vector3.up * 0.5f;
		float num = 2f;
		float skillLevel = ((Character)Player.m_localPlayer).GetSkillLevel((SkillType)11);
		float slash = baseDamage + skillLevel;
		int mask = LayerMask.GetMask(new string[12]
		{
			"Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox",
			"character_noenv", "vehicle"
		});
		Collider[] array = Physics.OverlapSphere(val, num, mask);
		HashSet<GameObject> hashSet = new HashSet<GameObject>();
		Collider[] array2 = array;
		RaycastHit val6 = default(RaycastHit);
		foreach (Collider val2 in array2)
		{
			if ((Object)(object)((Component)val2).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject || ((Object)(object)val2.attachedRigidbody != (Object)null && (Object)(object)((Component)val2.attachedRigidbody).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject))
			{
				continue;
			}
			IDestructible componentInParent = ((Component)val2).GetComponentInParent<IDestructible>();
			if (componentInParent == null)
			{
				continue;
			}
			Character val3 = (Character)(object)((componentInParent is Character) ? componentInParent : null);
			if ((Object)(object)val3 != (Object)null && (Object)(object)val3 == (Object)(object)Player.m_localPlayer)
			{
				continue;
			}
			IDestructible obj = ((componentInParent is MonoBehaviour) ? componentInParent : null);
			GameObject val4 = ((obj != null) ? ((Component)obj).gameObject : null);
			if ((Object)(object)val4 != (Object)null)
			{
				if (hashSet.Contains(val4))
				{
					continue;
				}
				hashSet.Add(val4);
			}
			Bounds bounds = val2.bounds;
			Vector3 center = ((Bounds)(ref bounds)).center;
			Vector3 val5 = center - position;
			Vector3 normalized = ((Vector3)(ref val5)).normalized;
			if (Vector3.Angle(((Component)Player.m_localPlayer).transform.forward, normalized) < 70f && !Physics.Linecast(position + Vector3.up * 1f, center, ref val6, LayerMask.GetMask(new string[4] { "Default", "static_solid", "terrain", "piece" })))
			{
				HitData val7 = new HitData();
				val7.m_damage.m_slash = slash;
				val7.m_pushForce = 20f;
				val7.m_point = center;
				val7.m_dir = ((Component)Player.m_localPlayer).transform.forward;
				val7.m_skill = (SkillType)11;
				val7.m_dodgeable = true;
				val7.m_blockable = true;
				val7.m_hitType = (HitType)2;
				val7.m_toolTier = 0;
				val7.SetAttacker((Character)(object)Player.m_localPlayer);
				componentInParent.Damage(val7);
			}
		}
	}
}
public class UlvFormBehavior : MonoBehaviour
{
	private Animator playerAnim;

	private Animator ulvAnim;

	private bool isAttacking;

	private void Start()
	{
		playerAnim = ((Component)((Component)Player.m_localPlayer).transform.Find("Visual")).GetComponent<Animator>();
		ulvAnim = ((Component)this).GetComponent<Animator>();
		if ((Object)(object)ulvAnim == (Object)null)
		{
			ulvAnim = ((Component)this).GetComponentInChildren<Animator>();
		}
	}

	private void Update()
	{
		if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)playerAnim == (Object)null || (Object)(object)ulvAnim == (Object)null || isAttacking)
		{
			return;
		}
		bool flag = playerAnim.GetBool("onGround");
		try
		{
			ulvAnim.SetBool("onGround", flag);
		}
		catch
		{
		}
		try
		{
			ulvAnim.SetBool("inWater", playerAnim.GetBool("inWater"));
		}
		catch
		{
		}
		if (!flag)
		{
			try
			{
				ulvAnim.SetFloat("forward_speed", 0f);
			}
			catch
			{
			}
			try
			{
				ulvAnim.SetFloat("sideway_speed", 0f);
			}
			catch
			{
			}
		}
		else if (((Character)Player.m_localPlayer).IsCrouching())
		{
			try
			{
				ulvAnim.SetFloat("forward_speed", 0f);
			}
			catch
			{
			}
			try
			{
				ulvAnim.SetFloat("sideway_speed", 0f);
			}
			catch
			{
			}
		}
		else
		{
			try
			{
				ulvAnim.SetFloat("forward_speed", playerAnim.GetFloat("forward_speed"));
			}
			catch
			{
			}
			try
			{
				ulvAnim.SetFloat("sideway_speed", playerAnim.GetFloat("sideway_speed"));
			}
			catch
			{
			}
		}
		if (flag)
		{
			if (FenrirInput.AttackDown(0))
			{
				((MonoBehaviour)this).StartCoroutine(UlvAttackRoutine("attack_bite", 40f, 0.6f, 0.2f));
			}
			else if (FenrirInput.AttackDown(1))
			{
				((MonoBehaviour)this).StartCoroutine(UlvAttackRoutine("attack_bite", 60f, 0.8f, 0.3f));
			}
			else if (FenrirInput.AttackDown(2))
			{
				((MonoBehaviour)this).StartCoroutine(UlvJumpAttackRoutine());
			}
		}
	}

	private void PlaySFX(params string[] prefabNames)
	{
		FenrirNet.PlayFx(prefabNames);
	}

	private IEnumerator UlvAttackRoutine(string triggerName, float baseDamage, float lockDuration, float dmgDelay)
	{
		isAttacking = true;
		try
		{
			ulvAnim.SetFloat("forward_speed", 0f);
		}
		catch
		{
		}
		try
		{
			ulvAnim.SetFloat("sideway_speed", 0f);
		}
		catch
		{
		}
		try
		{
			FenrirNet.Trigger(ulvAnim, triggerName);
		}
		catch
		{
		}
		if (triggerName == "attack_bite")
		{
			PlaySFX("sfx_ulv_attack", "sfx_wolf_attack", "sfx_fenring_attack");
		}
		else
		{
			PlaySFX("sfx_ulv_attack", "sfx_wolf_attack", "sfx_fenring_attack");
		}
		yield return (object)new WaitForSeconds(dmgDelay);
		FenrirNet.PlayFx("sfx_wood_hit");
		ExecuteBiteDamage(baseDamage);
		float num = lockDuration - dmgDelay;
		if (num > 0f)
		{
			yield return (object)new WaitForSeconds(num);
		}
		try
		{
			ulvAnim.ResetTrigger(triggerName);
		}
		catch
		{
		}
		isAttacking = false;
	}

	private void ExecuteBiteDamage(float baseDamage)
	{
		//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_001e: 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_0033: 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_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_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: 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_01f6: 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_0201: 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_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Expected O, but got Unknown
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: 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_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: 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)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		Vector3 position = ((Component)Player.m_localPlayer).transform.position;
		Vector3 val = position + ((Component)Player.m_localPlayer).transform.forward * 1.5f + Vector3.up * 0.5f;
		float num = 2f;
		float skillLevel = ((Character)Player.m_localPlayer).GetSkillLevel((SkillType)11);
		float slash = baseDamage + skillLevel;
		int mask = LayerMask.GetMask(new string[12]
		{
			"Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox",
			"character_noenv", "vehicle"
		});
		Collider[] array = Physics.OverlapSphere(val, num, mask);
		HashSet<GameObject> hashSet = new HashSet<GameObject>();
		Collider[] array2 = array;
		RaycastHit val6 = default(RaycastHit);
		foreach (Collider val2 in array2)
		{
			if ((Object)(object)((Component)val2).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject || ((Object)(object)val2.attachedRigidbody != (Object)null && (Object)(object)((Component)val2.attachedRigidbody).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject))
			{
				continue;
			}
			IDestructible componentInParent = ((Component)val2).GetComponentInParent<IDestructible>();
			if (componentInParent == null)
			{
				continue;
			}
			Character val3 = (Character)(object)((componentInParent is Character) ? componentInParent : null);
			if ((Object)(object)val3 != (Object)null && (Object)(object)val3 == (Object)(object)Player.m_localPlayer)
			{
				continue;
			}
			IDestructible obj = ((componentInParent is MonoBehaviour) ? componentInParent : null);
			GameObject val4 = ((obj != null) ? ((Component)obj).gameObject : null);
			if ((Object)(object)val4 != (Object)null)
			{
				if (hashSet.Contains(val4))
				{
					continue;
				}
				hashSet.Add(val4);
			}
			Bounds bounds = val2.bounds;
			Vector3 center = ((Bounds)(ref bounds)).center;
			Vector3 val5 = center - position;
			Vector3 normalized = ((Vector3)(ref val5)).normalized;
			if (Vector3.Angle(((Component)Player.m_localPlayer).transform.forward, normalized) < 70f && !Physics.Linecast(position + Vector3.up * 1f, center, ref val6, LayerMask.GetMask(new string[4] { "Default", "static_solid", "terrain", "piece" })))
			{
				HitData val7 = new HitData();
				val7.m_damage.m_slash = slash;
				val7.m_pushForce = 25f;
				val7.m_point = center;
				val7.m_dir = ((Component)Player.m_localPlayer).transform.forward;
				val7.m_skill = (SkillType)11;
				val7.m_dodgeable = true;
				val7.m_blockable = true;
				val7.m_hitType = (HitType)2;
				val7.m_toolTier = 0;
				val7.SetAttacker((Character)(object)Player.m_localPlayer);
				componentInParent.Damage(val7);
			}
		}
	}

	private IEnumerator UlvJumpAttackRoutine()
	{
		isAttacking = true;
		try
		{
			ulvAnim.SetFloat("forward_speed", 0f);
		}
		catch
		{
		}
		try
		{
			ulvAnim.SetFloat("sideway_speed", 0f);
		}
		catch
		{
		}
		try
		{
			FenrirNet.Trigger(ulvAnim, "attack_slash");
		}
		catch
		{
		}
		PlaySFX("sfx_ulv_attack", "sfx_wolf_attack");
		yield return (object)new WaitForSeconds(0.3f);
		float leapDuration = 0.25f;
		float leapSpeed = 18f;
		float elapsed = 0f;
		while (elapsed < leapDuration)
		{
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				Vector3 forward = ((Component)Player.m_localPlayer).transform.forward;
				Transform transform = ((Component)Player.m_localPlayer).transform;
				transform.position += forward * leapSpeed * Time.deltaTime;
			}
			elapsed += Time.deltaTime;
			yield return null;
		}
		FenrirNet.PlayFx("sfx_wood_hit");
		ExecuteBiteDamage(80f);
		yield return (object)new WaitForSeconds(0.4f);
		try
		{
			ulvAnim.ResetTrigger("attack_slash");
		}
		catch
		{
		}
		isAttacking = false;
	}
}
[HarmonyPatch(typeof(Player), "OnDamaged")]
public class FenrirInfectionPatch
{
	private static void Postfix(Player __instance, HitData hit)
	{
		if (((Character)__instance).IsDead() || hit == null || (Object)(object)__instance != (Object)(object)Player.m_localPlayer)
		{
			return;
		}
		Character attacker = hit.GetAttacker();
		if ((Object)(object)attacker != (Object)null)
		{
			string name = ((Object)((Component)attacker).gameObject).name;
			float num = 0f;
			string text = "";
			if (name.Contains("Fenring_Cultist") || name.Contains("Cultist"))
			{
				num = 0.5f;
				text = "Cultist";
			}
			else if (name.Contains("Fenring"))
			{
				num = 0.25f;
				text = "Fenring";
			}
			else if (name.Contains("Ulv"))
			{
				num = 0.25f;
				text = "Ulv";
			}
			else if (name.Contains("Wolf"))
			{
				num = 0.1f;
				text = "Wolf";
			}
			if (num > 0f && Random.value <= num && !((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirCurse")) && !((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_EnhancedCurse")))
			{
				Logger.LogInfo((object)("The player has been infected by a " + text + "!"));
				((Character)__instance).Message((MessageType)2, "The beast's blood enters your veins...", 0, (Sprite)null, false);
				((Character)__instance).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirCurse"), true, 0, 0f, (short)(-1));
			}
		}
	}
}
public static class FenrirInput
{
	private static readonly MethodInfo TakeInputMethod = AccessTools.Method(typeof(Player), "TakeInput", (Type[])null, (Type[])null);

	private static readonly string[] PadAttackButtons = new string[3] { "JoyAttack", "JoyBlock", "JoySecondaryAttack" };

	private const float PressWindow = 0.5f;

	private static KeyCode pressed = (KeyCode)0;

	private static float pressedUntil = -1f;

	public static float SuppressGuardianPowerUntil = -1f;

	public static bool Allowed
	{
		get
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return false;
			}
			if (Hud.IsPieceSelectionVisible())
			{
				return false;
			}
			if (TakeInputMethod == null)
			{
				return true;
			}
			return (bool)TakeInputMethod.Invoke(localPlayer, null);
		}
	}

	public static bool AttackDown(int mouseButton)
	{
		if (!Allowed)
		{
			return false;
		}
		if (!Input.GetMouseButtonDown(mouseButton))
		{
			return ZInput.GetButtonDown(PadAttackButtons[mouseButton]);
		}
		return true;
	}

	public static bool AttackHeld(int mouseButton)
	{
		if (!Allowed)
		{
			return false;
		}
		if (!Input.GetMouseButton(mouseButton))
		{
			return ZInput.GetButton(PadAttackButtons[mouseButton]);
		}
		return true;
	}

	public static void Press(KeyCode key)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		pressed = key;
		pressedUntil = Time.time + 0.5f;
	}

	public static bool KeyDown(KeyCode key)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		if (!Allowed)
		{
			return false;
		}
		if (pressed == key && Time.time <= pressedUntil)
		{
			pressedUntil = -1f;
			return true;
		}
		return Input.GetKeyDown(key);
	}

	public static void SuppressGuardianPowerBriefly(float seconds = 2f)
	{
		SuppressGuardianPowerUntil = Time.time + seconds;
	}
}
[HarmonyPatch(typeof(Player), "ActivateGuardianPower")]
public static class SuppressBorrowedGuardianPowerPatch
{
	public static bool Prefix(Player __instance)
	{
		if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
		{
			return true;
		}
		if (Time.time > FenrirInput.SuppressGuardianPowerUntil)
		{
			return true;
		}
		FenrirInput.SuppressGuardianPowerUntil = -1f;
		return false;
	}
}
public static class FenrirRadial
{
	private class Entry
	{
		public string Label;

		public KeyCode Key;

		public string Icon;
	}

	private class CurseRadialConfig : IRadialConfig
	{
		private readonly List<Entry> m_entries;

		public string LocalizedName => "Fenrir Curse";

		public Sprite Sprite
		{
			get
			{
				if (m_entries.Count <= 0)
				{
					return null;
				}
				return IconOf(m_entries[0].Icon);
			}
		}

		public CurseRadialConfig(List<Entry> entries)
		{
			m_entries = entries;
		}

		public void InitRadialConfig(RadialBase radial)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			List<RadialMenuElement> list = new List<RadialMenuElement>();
			foreach (Entry entry in m_entries)
			{
				RadialMenuElement val = (RadialMenuElement)(object)Object.Instantiate<EmoteElement>(RadialData.SO.EmoteElement);
				Entry captured = entry;
				SetName?.Invoke(val, new object[1] { $"{entry.Label} ({entry.Key})" });
				val.Interact = delegate
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					FenrirInput.Press(captured.Key);
					return true;
				};
				val.CloseOnInteract = () => true;
				Sprite val2 = IconOf(entry.Icon);
				if ((Object)(object)val.Icon != (Object)null)
				{
					((Component)val.Icon).gameObject.SetActive((Object)(object)val2 != (Object)null);
					val.Icon.sprite = val2;
				}
				list.Add(val);
			}
			radial.ConstructRadial(list);
		}
	}

	private static readonly MethodInfo SetName = AccessTools.PropertySetter(typeof(RadialMenuElement), "Name");

	private static bool Has(Player player, string seName)
	{
		if (((Character)player).GetSEMan() != null)
		{
			return ((Character)player).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode(seName));
		}
		return false;
	}

	private static List<Entry> EntriesFor(Player player)
	{
		//IL_0060: 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_00b1: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
		List<Entry> list = new List<Entry>();
		bool num = Has(player, "SE_FenrirCurse");
		bool flag = Has(player, "SE_EnhancedCurse");
		if (!num && !flag)
		{
			return list;
		}
		list.Add(flag ? new Entry
		{
			Label = "Cultist Form",
			Key = (KeyCode)103,
			Icon = "TrophyCultist"
		} : new Entry
		{
			Label = "Fenring Form",
			Key = (KeyCode)103,
			Icon = "TrophyFenring"
		});
		list.Add(flag ? new Entry
		{
			Label = "Ulv Form",
			Key = (KeyCode)104,
			Icon = "TrophyUlv"
		} : new Entry
		{
			Label = "Wolf Form",
			Key = (KeyCode)104,
			Icon = "TrophyWolf"
		});
		if (Has(player, "SE_FenrirForm") || Has(player, "SE_EnhancedForm"))
		{
			list.Add(new Entry
			{
				Label = "Howl",
				Key = (KeyCode)111,
				Icon = "TrophyWolf"
			});
		}
		return list;
	}

	public static void AddGroup(IRadialConfig back, RadialBase radial, List<RadialMenuElement> elements)
	{
		Player localPlayer = Player.m_localPlayer;
		if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)radial == (Object)null) && elements != null && !((Object)(object)RadialData.SO == (Object)null) && !((Object)(object)RadialData.SO.GroupElement == (Object)null))
		{
			List<Entry> list = EntriesFor(localPlayer);
			if (list.Count != 0)
			{
				GroupElement val = Object.Instantiate<GroupElement>(RadialData.SO.GroupElement);
				val.Init((IRadialConfig)(object)new CurseRadialConfig(list), back, radial);
				elements.Add((RadialMenuElement)(object)val);
			}
		}
	}

	private static Sprite IconOf(string prefabName)
	{
		if ((Object)(object)ObjectDB.instance == (Object)null || string.IsNullOrEmpty(prefabName))
		{
			return null;
		}
		GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(prefabName);
		ItemDrop val = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>() : null);
		if ((Object)(object)val == (Object)null || val.m_itemData?.m_shared?.m_icons == null || val.m_itemData.m_shared.m_icons.Length == 0)
		{
			return null;
		}
		return val.m_itemData.GetIcon();
	}
}
[HarmonyPatch(typeof(ValheimRadialConfig), "AddEmoteGroup")]
public static class FenrirRadialAddGroupPatch
{
	public static void Postfix(ValheimRadialConfig __instance, RadialBase radial, List<RadialMenuElement> elements)
	{
		try
		{
			FenrirRadial.AddGroup((IRadialConfig)(object)__instance, radial, elements);
		}
		catch (Exception arg)
		{
			Logger.LogWarning((object)$"[FenrirRadial] Could not add the curse group to the radial menu: {arg}");
		}
	}
}
public static class FenrirNet
{
	public const string RPC_Anim = "FenrirCurse_Anim";

	public static readonly int FormKey = StringExtensionMethods.GetStableHashCode("FenrirCurse_Form");

	public static readonly int FireKey = StringExtensionMethods.GetStableHashCode("FenrirCurse_Fire");

	public static readonly HashSet<string> AllowedForms = new HashSet<string> { "Fenring", "Fenring_Cultist", "Fenring_Cultist_Hildir", "Wolf", "Ulv" };

	private static readonly HashSet<string> AllowedFx = new HashSet<string>
	{
		"sfx_wolf_howl", "sfx_wolf_alert", "sfx_fenring_idle", "sfx_fenring_attack", "sfx_fenring_attack_claw", "sfx_wolf_attack", "sfx_cultist_attack_fire_start", "sfx_cultist_attack", "sfx_cultist_attack_double", "sfx_ulv_attack",
		"sfx_wood_hit"
	};

	public static bool IsAllowedFx(string name)
	{
		return AllowedFx.Contains(name);
	}

	private static ZNetView LocalOwnedView()
	{
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null)
		{
			return null;
		}
		ZNetView component = ((Component)localPlayer).GetComponent<ZNetView>();
		if (!((Object)(object)component != (Object)null) || !component.IsValid() || !component.IsOwner())
		{
			return null;
		}
		return component;
	}

	public static void SetForm(string prefabName)
	{
		ZNetView val = LocalOwnedView();
		if ((Object)(object)val != (Object)null)
		{
			val.GetZDO().Set(FormKey, prefabName ?? "");
		}
	}

	public static void SetFire(bool on)
	{
		ZNetView val = LocalOwnedView();
		if ((Object)(object)val != (Object)null)
		{
			val.GetZDO().Set(FireKey, on);
		}
	}

	public static void Trigger(Animator anim, string trigger)
	{
		if ((Object)(object)anim != (Object)null)
		{
			anim.SetTrigger(trigger);
		}
		Broadcast(trigger, "");
	}

	public static bool PlayFx(params string[] prefabNames)
	{
		//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)
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null)
		{
			return false;
		}
		foreach (string text in prefabNames)
		{
			GameObject prefab = Cache.GetPrefab<GameObject>(text);
			if ((Object)(object)prefab != (Object)null)
			{
				Object.Instantiate<GameObject>(prefab, ((Component)localPlayer).transform.position, Quaternion.identity);
				Broadcast("", text);
				return true;
			}
		}
		return false;
	}

	private static void Broadcast(string trigger, string fx)
	{
		ZNetView val = LocalOwnedView();
		if ((Object)(object)val != (Object)null)
		{
			val.InvokeRPC(ZNetView.Everybody, "FenrirCurse_Anim", new object[2] { trigger, fx });
		}
	}
}
[HarmonyPatch(typeof(Player), "Awake")]
public static class FenrirRemoteFormAttachPatch
{
	public static void Postfix(Player __instance)
	{
		if ((Object)(object)((Component)__instance).GetComponent<FenrirRemoteForm>() == (Object)null)
		{
			((Component)__instance).gameObject.AddComponent<FenrirRemoteForm>();
		}
	}
}
public class FenrirRemoteForm : MonoBehaviour
{
	private static readonly int OnGround = Animator.StringToHash("onGround");

	private static readonly int InWater = Animator.StringToHash("inWater");

	private static readonly int ForwardSpeed = Animator.StringToHash("forward_speed");

	private static readonly int SidewaySpeed = Animator.StringToHash("sideway_speed");

	private static readonly int Crouching = Animator.StringToHash("crouching");

	private Player m_player;

	private ZNetView m_nview;

	private Transform m_playerVisual;

	private Animator m_playerAnim;

	private string m_form = "";

	private GameObject m_formInstance;

	private Animator m_formAnim;

	private readonly HashSet<string> m_formParams = new HashSet<string>();

	private bool m_fire;

	private GameObject m_fireInstance;

	private void Awake()
	{
		m_player = ((Component)this).GetComponent<Player>();
		m_nview = ((Component)this).GetComponent<ZNetView>();
		m_playerVisual = ((Component)this).transform.Find("Visual");
		if ((Object)(object)m_playerVisual != (Object)null)
		{
			m_playerAnim = ((Component)m_playerVisual).GetComponent<Animator>();
		}
		if ((Object)(object)m_nview != (Object)null)
		{
			m_nview.Register<string, string>("FenrirCurse_Anim", (Action<long, string, string>)RPC_Anim);
		}
	}

	private bool IsRemote()
	{
		if ((Object)(object)m_player != (Object)null && (Object)(object)m_player != (Object)(object)Player.m_localPlayer && (Object)(object)m_nview != (Object)null)
		{
			return m_nview.IsValid();
		}
		return false;
	}

	private void Update()
	{
		if (IsRemote())
		{
			ZDO zDO = m_nview.GetZDO();
			string text = (((Character)m_player).IsDead() ? "" : zDO.GetString(FenrirNet.FormKey, ""));
			if (!FenrirNet.AllowedForms.Contains(text))
			{
				text = "";
			}
			if (text != m_form)
			{
				ApplyForm(text);
			}
			bool flag = (Object)(object)m_formInstance != (Object)null && zDO.GetBool(FenrirNet.FireKey, false);
			if (flag != m_fire)
			{
				ApplyFire(flag);
			}
			MirrorMovement();
		}
	}

	private void ApplyForm(string form)
	{
		//IL_0085: 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_0183: 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_01e5: 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)
		bool flag = string.IsNullOrEmpty(m_form);
		m_form = form;
		ClearForm();
		if (!((Character)m_player).IsDead())
		{
			SpawnPoof();
		}
		if (string.IsNullOrEmpty(form))
		{
			return;
		}
		GameObject prefab = Cache.GetPrefab<GameObject>(form);
		Transform val = (((Object)(object)prefab != (Object)null) ? prefab.transform.Find("Visual") : null);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		m_formInstance = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)this).transform);
		m_formInstance.transform.localPosition = Vector3.zero;
		m_formInstance.transform.localRotation = Quaternion.identity;
		CharacterAnimEvent[] componentsInChildren = m_formInstance.GetComponentsInChildren<CharacterAnimEvent>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			Object.Destroy((Object)(object)componentsInChildren[i]);
		}
		Collider[] componentsInChildren2 = m_formInstance.GetComponentsInChildren<Collider>(true);
		for (int i = 0; i < componentsInChildren2.Length; i++)
		{
			Object.Destroy((Object)(object)componentsInChildren2[i]);
		}
		m_formAnim = m_formInstance.GetComponent<Animator>();
		if ((Object)(object)m_formAnim == (Object)null)
		{
			m_formAnim = m_formInstance.GetComponentInChildren<Animator>();
		}
		if ((Object)(object)m_formAnim != (Object)null)
		{
			AnimatorControllerParameter[] parameters = m_formAnim.parameters;
			foreach (AnimatorControllerParameter val2 in parameters)
			{
				m_formParams.Add(val2.name);
			}
		}
		if ((Object)(object)m_playerVisual != (Object)null)
		{
			m_playerVisual.localScale = Vector3.one * 0.001f;
		}
		if (flag && (Object)(object)ZNetScene.instance != (Object)null)
		{
			GameObject prefab2 = ZNetScene.instance.GetPrefab("sfx_wolf_howl");
			if ((Object)(object)prefab2 == (Object)null)
			{
				prefab2 = ZNetScene.instance.GetPrefab("sfx_fenring_idle");
			}
			if ((Object)(object)prefab2 != (Object)null)
			{
				Object.Instantiate<GameObject>(prefab2, ((Component)this).transform.position, Quaternion.identity);
			}
		}
	}

	private void ClearForm()
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		ApplyFire(on: false);
		if ((Object)(object)m_formInstance != (Object)null)
		{
			Object.Destroy((Object)(object)m_formInstance);
		}
		m_formInstance = null;
		m_formAnim = null;
		m_formParams.Clear();
		if ((Object)(object)m_playerVisual != (Object)null)
		{
			m_playerVisual.localScale = Vector3.one;
		}
	}

	private void ApplyFire(bool on)
	{
		//IL_00a8: 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_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_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)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		m_fire = on;
		if ((Object)(object)m_formAnim != (Object)null && m_formParams.Contains("attack_fire"))
		{
			m_formAnim.SetBool("attack_fire", on);
		}
		if (!on)
		{
			if ((Object)(object)m_fireInstance != (Object)null)
			{
				Object.Destroy((Object)(object)m_fireInstance);
			}
			m_fireInstance = null;
		}
		else
		{
			if ((Object)(object)m_fireInstance != (Object)null || (Object)(object)ZNetScene.instance == (Object)null)
			{
				return;
			}
			GameObject prefab = ZNetScene.instance.GetPrefab("fx_fenring_flames");
			if (!((Object)(object)prefab == (Object)null) && !((Object)(object)prefab.GetComponent<ZNetView>() != (Object)null))
			{
				m_fireInstance = Object.Instantiate<GameObject>(prefab, ((Component)this).transform.position + Vector3.up * 1.5f + ((Component)this).transform.forward, ((Component)this).transform.rotation, ((Component)this).transform);
				ParticleSystem[] componentsInChildren = m_fireInstance.GetComponentsInChildren<ParticleSystem>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					MainModule main = componentsInChildren[i].main;
					((MainModule)(ref main)).startLifetimeMultiplier = ((MainModule)(ref main)).startLifetimeMultiplier * 1.2f;
				}
			}
		}
	}

	private void MirrorMovement()
	{
		if (!((Object)(object)m_formAnim == (Object)null) && !((Object)(object)m_playerAnim == (Object)null))
		{
			bool flag = m_playerAnim.GetBool(OnGround);
			bool flag2 = !flag || m_playerAnim.GetBool(Crouching);
			if (m_formParams.Contains("onGround"))
			{
				m_formAnim.SetBool(OnGround, flag);
			}
			if (m_formParams.Contains("inWater"))
			{
				m_formAnim.SetBool(InWater, m_playerAnim.GetBool(InWater));
			}
			if (m_formParams.Contains("forward_speed"))
			{
				m_formAnim.SetFloat(ForwardSpeed, flag2 ? 0f : m_playerAnim.GetFloat(ForwardSpeed));
			}
			if (m_formParams.Contains("sideway_speed"))
			{
				m_formAnim.SetFloat(SidewaySpeed, flag2 ? 0f : m_playerAnim.GetFloat(SidewaySpeed));
			}
		}
	}

	private void SpawnPoof()
	{
		//IL_0006: 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_0010: 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_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_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)
		Vector3 val = ((Component)this).transform.position + Vector3.up;
		GameObject prefab = Cache.GetPrefab<GameObject>("vfx_corpse_destruction");
		if ((Object)(object)prefab != (Object)null)
		{
			Object.Instantiate<GameObject>(prefab, val, Quaternion.identity);
		}
		GameObject prefab2 = Cache.GetPrefab<GameObject>("vfx_HitSparks");
		if ((Object)(object)prefab2 != (Object)null)
		{
			Object.Instantiate<GameObject>(prefab2, val, Quaternion.identity);
		}
	}

	private void RPC_Anim(long sender, string trigger, string fx)
	{
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		if (!IsRemote() || (Object)(object)m_formInstance == (Object)null || sender != m_nview.GetZDO().GetOwner())
		{
			return;
		}
		if (!string.IsNullOrEmpty(trigger) && (Object)(object)m_formAnim != (Object)null && m_formParams.Contains(trigger))
		{
			m_formAnim.SetTrigger(trigger);
		}
		if (!string.IsNullOrEmpty(fx) && FenrirNet.IsAllowedFx(fx))
		{
			GameObject prefab = Cac